apollographql / apollographql/apollo-client
Subscriptions no longer initialize after replacing WebSocketLink by GraphQLWsLink
- Dominant language
- TypeScript
- Stars
- 19.8k
- Forks
- 2.9k
- Avg merge
- 11h 14m
- Merged PRs (30d)
- 18
Description
I followed docs and replaced WebSocketLink by GraphQLWsLink
**Intended outcome:**
Using WebSocketLink, the connection is established (101, protocols switched)
Using GraphQLWsLink it fails instantly

**Actual outcome:**
I'm getting such error

What I did was
```diff
- const wsLink = new WebSocketLink({
- options: { reconnect: true },
- uri: graphQLWsUri,
- });
+ const wsLink = new GraphQLWsLink(
+ createClient({ url: graphQLWsUri }),
+ );
```
That's pretty much it. I double checked apollo docs and graphql-ws.
**Versions**
@apollo/client 3.6.2
Contributor guide
Research direction
Start by reproducing the subscription setup shown in the migration diff, comparing WebSocketLink with GraphQLWsLink and createClient at the reported @apollo/client 3.6.2 version. Inspect the GraphQLWsLink and createClient integration paths to identify why the connection fails instantly; done means subscriptions initialize successfully with the documented replacement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100