graphql / graphql/graphiql

How to unsubscribe from graphql-ws subscription

Open
#1,827 12 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
16.9k
Forks
1.9k
Avg merge
22h 45m
Merged PRs (30d)
70

Description

Hello,

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

```javascript
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(
,
container
);
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.