What are subscriptions for?
GraphQL subscriptions are a feature of the GraphQL query language that allows clients to receive real-time updates from a server when specific events or data changes occur. They are useful for building interactive and responsive applications, as they eliminate the need for clients to continuously poll the server for updates. Subscriptions work by establishing a long-lived connection between the client and server, enabling the server to push data to the client as soon as it becomes available, making them a more efficient and scalable way to handle real-time data synchronization in applications. The Cosmo Router comes with subscription support out of the box without any limitations. We support multiple different protocols to enable the most versatile and efficient real-time data synchronization for your applications: WebSockets, Server-Sent Events, and Multipart HTTP Protocol, among others.- graphql-ws: (default) Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client.
-
Server-Sent Events (SSE): One-Way Messaging. Both with
GET
andPOST
requests. Recommended for unidirectional updates. More resource efficient than WebSockets. - Multipart HTTP: Multi-part GraphQL subscriptions allow data to be delivered in chunks over time, enabling efficient streaming of large or frequently updated data in real-time applications.
-
subscriptions-transport-ws: Legacy transport to WebSocket-based GraphQL subscriptions. Please use
graphql-ws
orSSE
if you have the choice. - absinthe: Legacy transport for Clients that still use the Absinthe (Phoenix) protocol.

The Router connects your Clients and Subgraphs to establish a Real-time connection.
Multiplexing

The Clients and Subgraphs can speak different protocols depending on their abilities.
Whenever your router updates its config at runtime, it terminates all active subscriptions. Clients should be built in a way that reconnects automatically on disconnect.