What if your app could get updates the moment they happen, without asking again and again?
Why WebSocket transport in GraphQL? - Purpose & Use Cases
Imagine you want to get live updates from a server, like new chat messages or stock prices, but you have to keep asking the server again and again if there is anything new.
Manually asking the server repeatedly is slow and wastes resources. It can miss updates between checks and makes your app feel laggy and unresponsive.
WebSocket transport keeps a constant connection open between your app and the server. This way, the server can instantly send updates as they happen, making your app fast and smooth.
while(true) { fetch('/updates'); await new Promise(resolve => setTimeout(resolve, 5000)); }
const ws = new WebSocket('wss://server'); ws.onmessage = (msg) => handleUpdate(msg);It enables real-time, instant communication between client and server without delays or wasted effort.
Live sports scores updating on your phone as the game happens, without you refreshing the page.
Manual polling is slow and inefficient.
WebSocket transport keeps a live connection open.
This allows instant, real-time updates from server to client.