data._entities elements amount is not correct
scottming opened this issue · 5 comments
While I was exploring absinthe_federation to try to solve the good first issue, I found another bug.
When you query this
query getAllProducts {
allProducts {
createdBy {
email
name
}
id
}
}
it returns this error
{
"errors": [
{
"message": "Expected \"data._entities\" to contain 2 elements",
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"stacktrace": [
"Error: Expected \"data._entities\" to contain 2 elements",
" at /Users/scott.mingcrypto.com/Code/federation_poc/gateway/node_modules/@apollo/gateway/dist/executeQueryPlan.js:222:27",
" at processTicksAndRejections (node:internal/process/task_queues:96:5)",
" at async executeNode (/Users/scott.mingcrypto.com/Code/federation_poc/gateway/node_modules/@apollo/gateway/dist/executeQueryPlan.js:132:17)",
" at async executeNode (/Users/scott.mingcrypto.com/Code/federation_poc/gateway/node_modules/@apollo/gateway/dist/executeQueryPlan.js:120:27)",
" at async executeNode (/Users/scott.mingcrypto.com/Code/federation_poc/gateway/node_modules/@apollo/gateway/dist/executeQueryPlan.js:103:40)",
" at async /Users/scott.mingcrypto.com/Code/federation_poc/gateway/node_modules/@apollo/gateway/dist/executeQueryPlan.js:29:35",
" at async /Users/scott.mingcrypto.com/Code/federation_poc/gateway/node_modules/@apollo/gateway/dist/index.js:126:38",
" at async execute (/Users/scott.mingcrypto.com/Code/federation_poc/gateway/node_modules/apollo-server-core/dist/requestPipeline.js:201:20)",
" at async processGraphQLRequest (/Users/scott.mingcrypto.com/Code/federation_poc/gateway/node_modules/apollo-server-core/dist/requestPipeline.js:138:28)",
" at async processHTTPRequest (/Users/scott.mingcrypto.com/Code/federation_poc/gateway/node_modules/apollo-server-core/dist/runHttpQuery.js:187:30)"
]
}
}
}
],
"data": {
"allProducts": [
{
"createdBy": {
"email": "support@apollographql.com",
"name": null
},
"id": "apollo-federation"
},
{
"createdBy": {
"email": "support@apollographql.com",
"name": null
},
"id": "apollo-studio"
}
]
}
}
The reason is the localhost:4002
returns only one elements:
query ($representations: [_Any!]!) {
_entities(representations: $representations) {
... on User {
name
email
}
}
}
{
"representations":
[
{
"__typename": "User",
"email": "support@apollographql.com"
}
]
}
You can reproduce the bug with this repository
I took a look at this yesterday and there is definitely something weird going on. @SvenW do you know why we need that uniq_by
seems to be deduping other resolutions that we do want to resolve. I have a failing test for this right now I can push up
I took a look at this yesterday and there is definitely something weird going on. @SvenW do you know why we need that
uniq_by
seems to be deduping other resolutions that we do want to resolve. I have a failing test for this right now I can push up
We can probably do that part differently. The reason, if I remember correctly, was to make sure we only get the dataloader for a specific entity once and populate that middleware with all ids we want to resolve. But we can do that uniq part in a different stage of course
@SvenW
Can you push some test cases about this thing? Then I can try to implement it.
@scottming this should be fixed in 0.1.8 if you want to give it a try