How to unsubscribe from graphql-ws subscription
See original GitHub issueHello,
When I do a subscription (using graphql-ws fetcher), it works, the results are well printed in the result panel but when I push the stop button, the results stop to be printed on the panel but it seems that nothing is done on the wsClient. GraphiQL does not tell to the wsClient to unsubscribe and events are still sent by the ws server. If I repush the play button, a second subscription using a different UUID is sent to the server on the same websocket connection which if I’m not mistaken is illegal. Is there a way to unsubscribe when the stop button is pressed ? Thx
const URL = "http://debian9acu:8000/graphql";
const URLws = "ws://debian9acu:8000/graphql-ws";
var fetcher = createGraphiQLFetcher( {url:URL,subscriptionUrl:URLws} );
const container = document.getElementById("graphiql");
const defaultQuery = `
{
}
`
render(
<GraphiQL fetcher={fetcher} defaultQuery={defaultQuery} />,
container
);
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Subscriptions - Apollo GraphQL Docs
Apollo Client supports both graphql-ws and subscriptions-transport-ws . ... Determines if your subscription should be unsubscribed and subscribed again.
Read more >Cancel / Unsubscribe GraphQL Subscription
We use GraphQL subscriptions for the real-time metrics data and show some graphs. ... So the requirement is to cancel the subscription (aka....
Read more >Handle unsubscribe GraphQL subscription - Stack Overflow
I have an issue with subscription can't be unsubscribe. Before we start, this is my setup: Apollo Client(graphql-ws) <-> Apollo ...
Read more >Subscriptions | urql Documentation
For backends supporting graphql-ws , we recommend using the graphql-ws client. ... unsubscribe: wsClient.subscribe(operation, sink),.
Read more >Graphql-ws NPM
Check Graphql-ws 5.11.2 package - Last release 5.11.2 with MIT licence at our NPM ... let unsubscribe = () => { /* complete...
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 FreeTop 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
Top GitHub Comments
Hey, this is indeed right,
@n1ru4l/push-pull-async-iterable-iterator
did not correctly dispose of the sink. I created https://github.com/n1ru4l/push-pull-async-iterable-iterator/pull/54 which should address this. I also published v2.1.3 which has the fix included https://github.com/n1ru4l/push-pull-async-iterable-iterator/releases/tag/v2.1.3In the meantime, the discussion here will clear whether push-pull-async-iterable-iterator should stay in GraphiQL or not https://github.com/graphql/graphiql/pull/1841#pullrequestreview-639229360
Unfortunately I don’t have time to simulate a subscription error that GaphiQL should display but yes it was working when I tested it. With the new client, it the subscription is ok and if you don’t get any ws frame, If I remember well, the interface will stay blank and this is what I expect. Once it receives a ws frame, it decodes it and display it. You can find an exemple of what I can see here: https://gitlab.com/tango-controls/TangoGraphQL/-/tree/master/#subscribing-to-tango-event
Concerning the documentation, a simple client using createGraphiQLFetcher() (as mine) could be useful.