Closed gabrielschulhof closed 11 months ago
Everything is working fine for me when using GraphiQL, so maybe there is something odd in your client?
@mcollina yeah, I think that was it. Critically, I wanted to make sure subscriptions work when subscribing using something other than the UI generated by the server itself. Looks like Altair may be faulty in this case. I installed the Electron-wrapped graphql playground and was able to connect to the endpoint just fine. Thanks for doing a quick check!
Note that there are two protocols for GraphQL over websockets, so your client might be using the other one. I think we support both of them via an option, check it out.
The example at https://github.com/mercurius-js/mercurius/blob/master/docs/subscriptions.md#subscription-support-simple does not seem to result in notifications getting pushed to the client.
Steps to reproduce
Step 1
Flesh out the example into a full-fledged server:
Step 2
Run the server (Node.js 20.0.0, fastify 4.21.0, mercurius 13.1.0)
Step 3
Connect to the server with altair graphql client, setting the request URL to http://localhost:9999/graphql and creating three tabs:
Tab 1:
Tab 2:
variables:
Tab 3:
URL: ws://localhost:9999/graphql/subscriptions
Step 4
Run the query. This returns a single result.
Step 5
Run the subscription.
Step 6
Run the mutation.
Expected outcome
The subscription tab has a single line on the right-hand-side showing the message that was added.
Actual outcome
Although the query tab, when executed after the mutation, shows two messages in the list, the subscription tab shows no activity.