graphql-request
graphql-request copied to clipboard
GraphQLWebSocketClient should have onError and onClose events
Hi, I think the GraphQLWebSocketClient should have onError and onClose events so that somebody using that class can handle the error and reconnect later.
https://github.com/prisma-labs/graphql-request/blob/master/src/graphql-ws.ts
socket.onclose = (e) => {
this.socketState.acknowledged = false
this.socketState.subscriptions = {}
}
socket.onerror = (e) => {
console.error(e)
}
I had the problem that the graphql server went down and my graphql request client did not call complete
or error
{
next: ({ matchStartedSub }) => {
...
},
complete: () => {
resolve();
},
error(errorValue: ClientError) {
reject(errorValue);
},
})