So, I decided to give a go at updating our stack to use v6 and since I was using a custom lambda link I'll start with @graphql-tools/link module to ease the transition (eventually I want to replace my custom link but for now just wanted to see everything working).
After a few hours of refactoring a few imports and schema transformations, I got everything working EXCEPT errors.
Example of a subschema definition:
import { typeDefs } from '@tma/lambda-auth/modules/typedefs';
const link = split(
({ query }) => {
const definition = getMainDefinition(query);
return definition.kind === 'OperationDefinition' && definition.operation === 'subscription';
},
createLambdaLink('lambda-auth', 'graphqlSubscriptionServer'),
createLambdaLink('lambda-auth', 'graphqlServer'),
);
export const authSchema = wrapSchema({
executor: linkToExecutor(link),
schema: makeExecutableSchema({ typeDefs }),
subscriber: linkToSubscriber(link),
});
Example of a mutation:
mutation {
login(input: {
password: "whatever"
username: "whatever"
}) {
accessToken
}
}
Example of a RAW successful response from the downstream service (logged from the custom link):
{
data: {
login: {
accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTEwMjY4MjUsInNpZCI6IndManpYQ1piZmhrczdHaHZ6OEY4IiwidWlkIjoiMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAxIn0.G5YFfv3vRL85AcPzmdr8YvavIV1Wpvy-mQu9LUn9Cf0'
}
}
}
Example of a RAW error response from the downstream service (logged from the custom link):
{
errors: [
{
message: 'INVALID_CREDENTIALS',
locations: [Array],
path: [Array],
extensions: [Object]
}
],
data: null
}
This error output leads to this response to the client:
{
"errors": [
{
"message": "Cannot return null for non-nullable field LoginPayload.accessToken.",
"locations": [
{
"line": 3,
"column": 5
}
],
"path": [
"login",
"accessToken"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"stacktrace": [
"Error: Cannot return null for non-nullable field LoginPayload.accessToken.",
" at completeValue (/var/task/src/handlers/graphql-server.js:71953:13)",
" at completeValueCatchingError (/var/task/src/handlers/graphql-server.js:71888:19)",
" at resolveField (/var/task/src/handlers/graphql-server.js:71830:10)",
" at executeFields (/var/task/src/handlers/graphql-server.js:71671:18)",
" at collectAndExecuteSubfields (/var/task/src/handlers/graphql-server.js:72106:10)",
" at completeObjectValue (/var/task/src/handlers/graphql-server.js:72096:10)",
" at completeValue (/var/task/src/handlers/graphql-server.js:71984:12)",
" at completeValue (/var/task/src/handlers/graphql-server.js:71950:21)",
" at /var/task/src/handlers/graphql-server.js:71885:16",
" at Promise.propagateAslWrapper (/var/task/src/handlers/graphql-server.js:40168:23)",
" at Promise.__asl_wrapper (/var/task/src/handlers/graphql-server.js:39356:31)",
" at proxyWrapper (/var/task/src/handlers/graphql-server.js:40193:23)",
" at /var/task/src/handlers/graphql-server.js:40205:70",
" at /var/task/src/handlers/graphql-server.js:39356:31",
" at processTicksAndRejections (internal/process/task_queues.js:97:5)"
]
}
}
}
],
"data": null
}
Because there is an error, obviously LoginPayload.accessToken is null, so I'm not sure why it's giving that response... This works as expected with graphql-tools v4
Thanks for reporting! Do you think you could put together a minimally reproducing example with the typedefs, schemas? Thanks!
@yaacovCR I've done a PR with a reproduction that should emulate my setup accurately. Let me know if you need anything else or if you can suggest a different way of doing things.
Thanks, awesome, my comment there...
Available in v6.0.6 !