-
I am getting "Cannot return null for non-nullable field Subscription.greeting" returned to Postman when I invoke a subscription: Schema looks like this:
The resolver looks like this:
The full code of the example can be found here: https://github.com/jmc420/graphql_examples/blob/main/graphql-ws/src/server.ts |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 11 replies
-
Try changing your root resolver to use the const rootValue = {
subscription: {
- greeting: async function* () {
- for (const hi of ['Hi', 'Bonjour', 'Hola', 'Ciao', 'Zdravo']) {
- yield { greetings: hi };
- }
- }
+ greeting: {
+ subscribe: async function* () {
+ for (const hi of ['Hi', 'Bonjour', 'Hola', 'Ciao', 'Zdravo']) {
+ yield { greetings: hi };
+ }
+ }
+ }
}
} |
Beta Was this translation helpful? Give feedback.
-
Its was because of yielding the field "greetings" while the actual field is called just "greeting" (singular). const rootValue = {
subscription: {
greeting: async function* () {
for (const hi of ['Hi', 'Bonjour', 'Hola', 'Ciao', 'Zdravo']) {
- yield { greetings: hi };
+ yield { greeting: hi };
}
}
}
} |
Beta Was this translation helpful? Give feedback.
From #460 (reply in thread)
Its was because of yielding the field "greetings" while the actual field is called just "greeting" (singular).