I have a federated graph, and I’m querying for two fields from two different subgraphs, in one query. Something like
query X {
fieldFromSubgraphA
fieldFromSubgraphB
}
When fieldFromSubgraphA fails, but fieldFromSubgraphB fails, I get an error which doesn’t indicate which field failed to load:
errors: [
{
"message": "Expected JSON response body, but received: {\"errors\":[{\"message\":\"...\"}],\"data\":null}",
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"stacktrace": [
"Error: Expected JSON response body, but received: {\"errors\":[{\"message\":\"...\"}],\"data\":null}",
" at AuthenticatedDataSource.sendRequest (gateway/node_modules/@apollo/gateway/src/datasources/RemoteGraphQLDataSource.ts:165:15)",
" at runMicrotasks (<anonymous>)",
" at processTicksAndRejections (internal/process/task_queues.js:95:5)",
" at AuthenticatedDataSource.process (gateway/node_modules/@apollo/gateway/src/datasources/RemoteGraphQLDataSource.ts:124:22)",
" at sendOperation (gateway/node_modules/@apollo/gateway/src/executeQueryPlan.ts:307:22)",
" at executeFetch (gateway/node_modules/@apollo/gateway/src/executeQueryPlan.ts:248:37)",
" at executeNode (gateway/node_modules/@apollo/gateway/src/executeQueryPlan.ts:176:9)",
" at executeNode (gateway/node_modules/@apollo/gateway/src/executeQueryPlan.ts:160:17)",
" at executeNode (gateway/node_modules/@apollo/gateway/src/executeQueryPlan.ts:128:32)",
" at Object.executeQueryPlan (gateway/node_modules/@apollo/gateway/src/executeQueryPlan.ts:65:23)"
]
}
}
}
]
With apollo client, I’m querying with errorPolicy: 'all'
.
Both fields are nullable, so I can’t tell from null data which field errored.
How do I know which field errors here? I need to check because one error is fatal and the other is just a warning.