GraphQL Subscriptions: Why we use SSE/Fetch over Websockets
Blog post from Wundergraph
GraphQL Subscriptions are a powerful feature in GraphQL that allow clients to receive updates in real-time. However, implementing them over WebSockets is not ideal due to several problems such as statefulness, security issues, bidirectional communication, and usability problems with Server-Side Rendering (SSR). We've chosen SSE/Fetch to implement GraphQL Subscriptions instead, which offers a modern, easy-to-use API that's performant, secure, and allows for SSR. The SSE/Fetch approach is stateless, disallows the client from sending arbitrary data, can be easily secured with the Token Handler Pattern, and supports HTTP/2. It also enables simple implementation of SSR for GraphQL Subscriptions. With 93.76% of all browsers supporting HTTP/2, 94.65% supporting SSE, and 93.62% supporting Fetch, it's time to migrate from WebSockets to SSE/Fetch for GraphQL Subscriptions.
| Trend | Post Mentions | Total Month Mentions | Posts | Companies | MoM |
|---|---|---|---|---|---|
| Real-time | 3 | 1,315 | 365 | 127 | -4% |
Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.