I have a response coming from a subgraph:
{
errors: [
{
errcode: '23505',
extensions: [Object],
message: 'duplicate key value violates unique constraint "company_name_idx"',
locations: [Array],
path: [Array],
stack: [Array]
},
{
detail: 'Key (company_id)=(2eef1fbe-e2c5-4180-a6ba-2d7dd75a7613) is not present in table "company".',
errcode: '23503',
extensions: [Object],
message: 'insert or update on table "companies_persons" violates foreign key constraint "companies_persons_company_id_fkey"',
locations: [Array],
path: [Array],
stack: [Array]
}
],
data: { createCompany: null, createCompaniesPerson: null },
http: Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: { body: [Minipass], disturbed: true, error: null },
[Symbol(Response internals)]: {
url: 'http://host.docker.internal:8086/graphql',
status: 200,
statusText: 'OK',
headers: [Headers],
counter: 0,
trailer: [Promise]
}
}
}
I checked this via:
didReceiveResponse: ({ response }) => {
console.log("RESPONSE");
console.log(response);
return response;
},
But the response that is being passed from the supergraph (latest versions of js ApolloGateway / ApolloServer) is:
{
"errors": [
{
"message": "graphqlError.stack?.split is not a function",
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"stacktrace": [
"TypeError: graphqlError.stack?.split is not a function",
" at enrichError (file:///usr/src/app/node_modules/@apollo/server/dist/esm/errorNormalize.js:42:57)",
" at file:///usr/src/app/node_modules/@apollo/server/dist/esm/errorNormalize.js:12:36",
" at Array.map (<anonymous>)",
" at normalizeAndFormatErrors (file:///usr/src/app/node_modules/@apollo/server/dist/esm/errorNormalize.js:10:33)",
" at formatErrors (file:///usr/src/app/node_modules/@apollo/server/dist/esm/requestPipeline.js:288:16)",
" at processGraphQLRequest (file:///usr/src/app/node_modules/@apollo/server/dist/esm/requestPipeline.js:175:19)",
" at processTicksAndRejections (node:internal/process/task_queues:96:5)",
" at async internalExecuteOperation (file:///usr/src/app/node_modules/@apollo/server/dist/esm/ApolloServer.js:573:16)",
" at async runHttpQuery (file:///usr/src/app/node_modules/@apollo/server/dist/esm/runHttpQuery.js:115:29)",
" at async runPotentiallyBatchedHttpQuery (file:///usr/src/app/node_modules/@apollo/server/dist/esm/httpBatching.js:34:16)"
]
}
},
{
"message": "graphqlError.stack?.split is not a function",
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"stacktrace": [
"TypeError: graphqlError.stack?.split is not a function",
" at enrichError (file:///usr/src/app/node_modules/@apollo/server/dist/esm/errorNormalize.js:42:57)",
" at file:///usr/src/app/node_modules/@apollo/server/dist/esm/errorNormalize.js:12:36",
" at Array.map (<anonymous>)",
" at normalizeAndFormatErrors (file:///usr/src/app/node_modules/@apollo/server/dist/esm/errorNormalize.js:10:33)",
" at formatErrors (file:///usr/src/app/node_modules/@apollo/server/dist/esm/requestPipeline.js:288:16)",
" at processGraphQLRequest (file:///usr/src/app/node_modules/@apollo/server/dist/esm/requestPipeline.js:175:19)",
" at processTicksAndRejections (node:internal/process/task_queues:96:5)",
" at async internalExecuteOperation (file:///usr/src/app/node_modules/@apollo/server/dist/esm/ApolloServer.js:573:16)",
" at async runHttpQuery (file:///usr/src/app/node_modules/@apollo/server/dist/esm/runHttpQuery.js:115:29)",
" at async runPotentiallyBatchedHttpQuery (file:///usr/src/app/node_modules/@apollo/server/dist/esm/httpBatching.js:34:16)"
]
}
}
],
"data": {
"createCompany": null,
"createCompaniesPerson": null
}
}
Checking the code... seems as though I can thwart this error by setting includeStacktraceInErrorResponses
to false, but I want the stacktrace in development.