Keep-Alive messages trigger errors
- Dominant language
- Go
- Stars
- 1.3k
- Forks
- 143
- Avg merge
- 4h 50m
- Merged PRs (30d)
- 1
Description
**Describe the bug**
I'm using the client generated by genClient with Hasura and have noticed that subscriptions are failing.
The problem is that Hasura implements keep-alive messages for the 'graphql-transport-ws' and 'graphql-ws' protocols. In the former case, it sends 'ping' messages; in the latter, 'ka' messages. Neither of these messages includes an ID, which triggers the following error: https://github.com/cheina97/genqlient/blob/6309a6ef5f325d254be1a91756b56fd9ec5441a3/graphql/websocket.go#L143-L145.
I have two possible solutions (I tested both and they work):
- Exclude messages with "ka" or "ping" type.
- Return nil instead of this error: https://github.com/cheina97/genqlient/blob/6309a6ef5f325d254be1a91756b56fd9ec5441a3/graphql/websocket.go#L143-L145.
I've noticed that the ID parameter is an optional field in both graphql-ws and graphql-transport-ws. Therefore, this solution should also solve the same error for other message types.
Do you have any other suggestions? I can open a PR and implement it.
I'm also aware that genqlient should implement a response to these messages. Do you think it would be feasible to implement this in the next PR?
**To Reproduce**
Deploy Hasura and try genqlient with it.
**Expected behavior**
Subscriptions should work with hasura graphql server.
**genqlient version**
v0.8.1
Contributor guide
Research direction
Start at graphql/websocket.go lines 143-145 and reproduce the failure with a Hasura GraphQL server using subscriptions. Compare the handling of keep-alive messages in the graphql-ws and graphql-transport-ws protocols, then verify that subscription keep-alives no longer trigger errors and subscriptions continue working.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, graphql
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100