-
-
Notifications
You must be signed in to change notification settings - Fork 334
Description
Hi Kévin.
I would like to reopen #162.
I would like to use mercure instead of websocket for my graphql subscriptions, but I'm actually not understanding how to properly do that. I didn't find any resource about it, neither someone who have already done it.
Disclaimer : I'm not a graphql expert, and especially totally noob in real-time stuff.
What I've understood is there is a several part in subscription: the pubsub implementation, and the transport implementation.
The documentation tells us about pubsub, but it forgets totally the transport here: https://www.apollographql.com/docs/apollo-server/data/subscriptions
I'm reading about sse transport in graphql, but I don't fully understand how to adapt it to mercure and how to implement it.
It seems really simple when reading you:
In response to the subscription query, the GraphQL server may return a corresponding topic URL. The client can then subscribe to the Mercure's event stream corresponding to this subscription by creating a new EventSource with an URL like https://example.com/.well-known/mercure?topic=https://example.com/subscriptions/ as parameter.
Updates for the given subscription can then be sent from the GraphQL server to the clients through the Mercure hub (in the data property of the server-sent event).
Also, Mercure can easily be integrated with Apollo GraphQL by creating a dedicated transport.
Could you give us some advice on how to handle that? Maybe an example? Or would you mind giving an hand on creating a transport for mercure? It can helps adoption of the protocol in graphql community.
Thanks.
Mathieu.