How to detect the disconnect of GraphQLWsLink?

I am using GraphQLWsLink to connect to my graphql server in react. However, sometimes the connection is down and after a few attempts apollo client does not attempt reconnecting.

Is there a way I could detect when the websocket connection is down? What would be the best way of forcing reconnecting?

Hi Karol,
this is something that happens outside of the GraphQLWsLink - in the client instance itself.

There are a bunch of options to handle reconnects - see Interface: ClientOptions<P> – GraphQL WS

On the Apollo Client side, you will only receive an error with a “Socket closed” error message if all of those “internal” reconnects fail - at that point you would probably need to kick off the whole subscription again from your component, but if you already retried reconnecting on Client level there is probably little hope it will actually be able to connect then, either.