Open arenevier opened 7 months ago
Hi @arenevier 👋 Appreciate the bug report! What does the error event you're receiving look like? Are you using ws
? A reproduction would be helpful to check our assumptions. We'd also love any PRs here :)
any type of error will create that. For example:
[
{
message: 'Cannot query field "eid" on type "IFooBar". Did you mean "_eid"?',
locations: [ [Object] ]
}
]
Yes, I'm using ws,
const wsLink = new GraphQLWsLink(createClient({
url: 'wss://my-url/graphql',
webSocketImpl: WebSocket,
connectionParams: {
...
}
}));
Thanks, @arenevier. You should also set that WebSocket
implementation you're passing to webSocketImpl
on globalThis
in your node environment which I would expect to resolve the error. Can you please try that and let me know how it goes?
Yes, that would work.
It looks like I am not the first to bump into this issue: https://github.com/apollographql/apollo-client/issues/11063
Should that be specified in the documentation?
Alternatively, replacing WebSocket.CLOSED by it's value (3) would also fix the issue for everyone.
Yes, that should definitely be added to the docs :) I'll look at opening that PR today.
Issue Description
I am using apollo client with GraphQLWsLink in node.
When an error happens, an exception happens during the handling of that error
Trace is
This happens because of that line. WebSocket is not defined in node environment.
return isNonNullObject(err) && err.target?.readyState === WebSocket.CLOSED;
Link to Reproduction
don't have one, but the root of the issue is obvious
Reproduction Steps
No response
@apollo/client
version3.9.10