envelop
envelop copied to clipboard
@envelop/extended-validation: "TypeError: Cannot read property 'map' of undefined" with Apollo Server
Describe the bug
I'm seeing a "TypeError: Cannot read property 'map' of undefined" response to a simple query when I use the "@envelop/extended-validation" plugin.
To Reproduce Steps to reproduce the behavior:
https://codesandbox.io/s/happy-franklin-gbwov
Query
query ExampleQuery {
hello
}
Response
{
"errors": [
{
"message": "Cannot read property 'map' of undefined",
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"stacktrace": [
"TypeError: Cannot read property 'map' of undefined",
" at onExecute (/sandbox/node_modules/@envelop/extended-validation/index.js:35:59)",
" at /sandbox/node_modules/@envelop/core/index.js:616:37",
" at /sandbox/node_modules/@envelop/core/index.js:200:54",
" at Object.executor (/sandbox/index.js:42:12)",
" at processTicksAndRejections (internal/process/task_queues.js:95:5)",
" at async execute (/sandbox/node_modules/apollo-server-express/node_modules/apollo-server-core/dist/requestPipeline.js:201:20)",
" at async Object.processGraphQLRequest (/sandbox/node_modules/apollo-server-express/node_modules/apollo-server-core/dist/requestPipeline.js:138:28)",
" at async processHTTPRequest (/sandbox/node_modules/apollo-server-express/node_modules/apollo-server-core/dist/runHttpQuery.js:179:30)"
]
}
}
}
]
}
Expected behavior
No error.
Environment:
- OS:
@envelop/...:- NodeJS:
Additional context
Apollo Server doesn't completely support envelop see https://github.com/dotansimha/envelop/issues/1112
I am seeing a similar error/behaviour using envelop with apollo. All the datasources are undefined. I'm not overriding the parse function per the docs, that I know of. Does anyone know of a fix to get any datasources working with apollo and envelop? I'm using almost verbatim the example - I've added the NewRelic plugin.
The schema pre and post envelop context are identical with exception of the addition of an empty validationErrors array.
@matt-halliday as mentioned in #1112
Apollo-Server does not allow overwriting the parse and validate functions.
We have this open discussion with Apollo Server https://github.com/apollographql/apollo-server/discussions/5541 but looks like they aren't planning to add support anytime soon. Are there specific things that you use Apollo Server for? We maintain GraphQL yoga and currently it is in beta but coming weeks we will land a stable release I would encourage you to try it out and let us know how we can improve it.
Also would be great if you can share a reproduction.