profusion / sgqlc

Simple GraphQL Client
https://sgqlc.readthedocs.io/
ISC License
506 stars 85 forks source link

Add support for the GraphQL-WS Subprotocol #238

Open artran opened 1 year ago

artran commented 1 year ago

Add support for the GraphQL-WS Subprotocol

Reason for request

The current implementation of the WebSocket endpoint can only handle the Apollo-WS transport, which has been deprecated. As new server libraries are moving over to the GrapQL-WS transport it would be really helpful if the WebSocket endpoint could also support the newer protocol.

What is required

The two protocols are actually very similar and supporting both is quite trivial. In order to prove it was possible I have implemented a fix in a fork of this project and used it against a new server.

Reference implementation

I've started a discussion about this, which includes all the details: https://github.com/profusion/sgqlc/discussions/237

The single commit to implement my changes are here: https://github.com/artran/sgqlc/commit/60a93b5ff74325d3b38a4090af7de29034da9422