Undefined error if Subscription starts with capital letter in roots
See original GitHub issueScreenshot
Expected Behaviour
There should not be an error if Subscription
is used in roots
.
Actual Behaviour
There is an undefined
error if Subscription
starts with a capital letter.
When using graphql server and graphql-tools, there is no such error 🤔
Debug Information
From docs, capitalize subscription
first letter:
roots: {
Subscription: {
greetings: async function* sayHiIn5Languages() {
for (const hi of ['Hi', 'Bonjour', 'Hola', 'Ciao', 'Zdravo']) {
yield { greetings: hi }
}
}
}
}
Further Information
Trying to move from deprecated subscriptions-transport-ws
🙈
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Subscription of observable returns undefined - Stack Overflow
I use a service to fill my observable with data from the backend. The backend is delievering the correct data. Now I want...
Read more >Complete Vue Router 4 Guide: Basics, Programmatic Routing ...
All undefined and illegal routes will be handled by the last routing rule. Next, we create an error component. We make a copy...
Read more >How To Use Bash Parameter Substitution Like A Pro - nixCraft
Explains how to use Bash Parameter Substitution for string matriculation and expansion - includes tons of practical examples.
Read more >GraphQL specification
A schema defines the initial root operation type for each kind of operation it supports: query, mutation, and subscription; this determines the place...
Read more >Migrating to Apollo Server 4 - Apollo GraphQL Docs
A set of core plugins (similar to Apollo Server 3's apollo-server-core package). There are no integration-specific subclasses in Apollo Server 4. Instead, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah, there should be a more communicative error message there… I guess an issue for Altair. Thanks for sharing!
My suggestion on auth is in the “ws server and client auth usage with token expiration, validation and refresh” recipe. Do check it out. 😄
The
roots
object expects lowercase operation names. Please read the documentation about theroots
option.On how the
roots
work, the detected operation type root is put directly in the execute/subscriberootValue
argument: https://github.com/enisdenjo/graphql-ws/blob/4f11c8aeec092fac21bee6c9084f1e622b5e4a41/src/server.ts#L716Furthermore, the
roots
option is just a convenience. You should absolutely use only theschema
option as you attempted. However, when usingmakeExecutableSchema
, you must nest the subscriptions iterator under thesubscribe
path: