graphql-editor / graphql-zeus

GraphQL client and GraphQL code generator with GraphQL autocomplete library generation ⚡⚡⚡ for browser,nodejs and react native ( apollo compatible )
https://graphqleditor.com/docs/tools/zeus/index/
MIT License
1.93k stars 103 forks source link

web socket protocol confusion #388

Open tintin10q opened 8 months ago

tintin10q commented 8 months ago

Hey there, I have generated a client with --subscriptions graphql-ws . I am also using hasura subscription and I want to migrate from my apolo subscription client to the zeus one.

When I look at the messages that this client generates I get:

{"id":"c1a9e1a2-60b6-4cad-b6a8-b031449f8280","type":"subscribe","payload":"..........."}

But the old apolloclient actually sends a message like this:

{"id":"1","type":"start","payload":"...."}

So instead of a message with type subscribe it sends a message with type start.

I looked in the protocol description: https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md

But the zeus actually seems to be the right one. There is no mention of a start message. So it seems that apollo used a different protocol.

So can someone please tell me what protocol the protocol using the start message is. I tried to look but I couldn't find it.

gthau commented 6 months ago

Be wary of the confusing names of the protocols and libraries...

There are 2 graphql subscriptions protocols over WebSocket:

Which one to use depends what your gql server implements and whether you are limited by 3rd party libs that support one or the other, e.g. older versions of apollo client don't support graphql-transport-ws, or Zeus doesn't support graphql-ws. Note that on the server-side, you can support both of them (it might require a fair amount of debugging to get it right depending on your server's solution). If you use Zeus generated client, then you have to support graphql-transport-ws on your server-side (I haven't looked at stucco, I don't how standard/non-standard it is).

The first part of this article does a good job presenting the differences between both protocols.