-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@defer: error related to a field in a deferred fragment appears in chunk for non-deferred fragment #1818
Comments
It's a bit worse if the field is not nullable: because of bubbling up we never get the actual:
whereas in theory we should be able to get it in the first chunk. expected:
|
Could you add this to the config so we see xhat error is really sent?: include_subgraph_errors:
all: true Are all fields returned by a single subgraph request? That might be the reason here: the primary response aggregates errors from its subgraph calls and returns it, then deferred responses do the same from their own subgraph calls, but if they did not call a subgraph and instead return data from the primary's subgraph call, the error is probably not returned. If that's the case, I think that could be fixed by transmitting to the deferred fragment execution the errors previously generated, then when creating the response, we would filter which errors are supposed to be returned |
Yes, in my test I actually have only one subgraph. Here's the result with the full errors: Nullable field: {
"data": {
"computer": {
"id": "Computer1"
}
},
"errors": [
{
"message": "Error field",
"locations": [
{
"line": 1,
"column": 93
}
],
"path": [
"computer",
"errorField"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"stacktrace": [
"Error: Error field",
" at Object.errorField (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/computers.js:23:19)",
" at field.resolve (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/node_modules/apollo-server-core/dist/utils/schemaInstrumentation.js:56:26)",
" at executeField (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/node_modules/graphql/execution/execute.js:481:20)",
" at executeFields (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/node_modules/graphql/execution/execute.js:413:20)",
" at completeObjectValue (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/node_modules/graphql/execution/execute.js:914:10)",
" at completeValue (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/node_modules/graphql/execution/execute.js:635:12)",
" at executeField (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/node_modules/graphql/execution/execute.js:489:19)",
" at executeFields (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/node_modules/graphql/execution/execute.js:413:20)",
" at executeOperation (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/node_modules/graphql/execution/execute.js:344:14)",
" at execute (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/node_modules/graphql/execution/execute.js:136:20)"
]
}
}
}
]
} Non nullable field: {
"data": {
"computer": null
},
"errors": [
{
"message": "Error field",
"locations": [
{
"line": 1,
"column": 93
}
],
"path": [
"computer",
"nonNullErrorField"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"stacktrace": [
"Error: Error field",
" at Object.nonNullErrorField (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/computers.js:26:19)",
" at field.resolve (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/node_modules/apollo-server-core/dist/utils/schemaInstrumentation.js:56:26)",
" at executeField (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/node_modules/graphql/execution/execute.js:481:20)",
" at executeFields (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/node_modules/graphql/execution/execute.js:413:20)",
" at completeObjectValue (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/node_modules/graphql/execution/execute.js:914:10)",
" at completeValue (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/node_modules/graphql/execution/execute.js:635:12)",
" at executeField (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/node_modules/graphql/execution/execute.js:489:19)",
" at executeFields (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/node_modules/graphql/execution/execute.js:413:20)",
" at executeOperation (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/node_modules/graphql/execution/execute.js:344:14)",
" at execute (/Users/bod/gitrepo/apollo-kotlin-1/tests/defer/router/subgraphs/computers/node_modules/graphql/execution/execute.js:136:20)"
]
}
}
}
]
} |
👋 I'm still seeing the same issue with v1.2.1. To reproduce:
query: query HandlesErrorsThrownInDeferredFragmentsQuery {
computer(id: "Computer1") {
id
...ComputerErrorField @defer
}
}
fragment ComputerErrorField on Computer {
errorField
} Expected:
Actual:
|
Fix #1818 Fix #2185 Blocked by #2109 (waiting for the router-bridge update) When errors are generated during the primary execution, some of them can be affected to deferred responses. To handle that, we need to: - transmit errors from the primary query to deferred node execution along with the primary fetches - be able to check if an error path belongs to a deferred query Since the error path may belong to a part of the response that was nullified, we need to follow the error path through the primary or deferred queries Co-authored-by: Jeremy Lempereur <[email protected]>
I can still reproduce on 1.6.0 with the same steps as above |
thank you for testing it, I'll check |
I just tested on the branch And I get this:
so this looks like the expected result? Are you sure this is using the 1.6 router? |
Odd! It does says 1.6.0 when starting it. Wait the behavior is different with Without:
With:
|
I am testing without |
my guess here is that without |
I confirm. with |
alright, that should be an easy fix |
Fix #1818 the path is used to decide whether to assign the error on the primary or deferred response
Describe the bug
Using the graphql test suite as an inspiration, I am selecting a field that resolves to an error, in a deferred fragment:
I am receiving the error in the first chunk (along with
id
) and no errors in the second chunk, whereas I would have expected the opposite (error in the 2nd chunk alongerrorField
), as graphql-js apparently does.Unsure if this is the spec really mandates this, it may be just a different and acceptable implementation, if so feel free to close!
To Reproduce
The text was updated successfully, but these errors were encountered: