Using GraphQL with WebSockets
In Chapter 1, Preparing Your Development Environment, I explained all the main features that make GraphQL so useful. We mentioned that HyperText Transfer Protocol (HTTP) is the standard network protocol when using GraphQL. The problem with regular HTTP connections, however, is that they are one-time requests. They can only respond with the data that exists at the time of the request. If the database receives a change concerning the posts or the chats, the user won't know about this until they execute another request. The UI shows outdated data in this case.
To solve this issue, you can refetch all requests in a specific interval, but this is a bad solution because there's no time range that makes polling efficient. Every user would make unnecessary HTTP requests, which neither you nor the user wants.
The best solution relies on WebSockets instead of HTTP requests. As with HTTP, WebSockets are also based on the Transmission Control Protocol...