Chapter 10: Real-Time Subscriptions
The GraphQL application programming interface (API) we have built is very advanced, as is the frontend. In the previous chapter, we introduced server-side rendering (SSR) to our application. We provided the user with a lot of information through the news feed, chats, and profile pages. The problem we are facing now, however, is that the user currently has to either refresh the browser or we have set a pollInterval
property to Apollo Hooks to keep the display up to date. A better solution is to implement Apollo subscriptions through WebSockets. This allows us to refresh the user interface (UI) of the user with the newest user information in real time without manual user interaction or polling.
This chapter covers the following topics:
- Using GraphQL with WebSockets
- Implementing Apollo subscriptions
- JWT authentication with subscriptions
- Notifications with Apollo subscriptions