Subscriptions on the Apollo Client

As with the back end code, we also need to make adjustments to the Apollo Client configuration before using subscriptions. In Chapter 4, Integrating React into the Back end with Apollo, we set up the Apollo Client with the normal HttpLink. Later, we exchanged it with the createUploadLink function, which enables the user to upload files through GraphQL.

We are going to extend our Apollo Client by using WebSocketLink as well. This allows us to use subscriptions through GraphQL. Both links work side by side. We use the standard HTTP protocol to query data, such as the chat list or the news feed; all of these are real-time updates to keep the UI up to date rely on WebSockets.

To configure the Apollo Client correctly, ...

Get Hands-On Full-Stack Web Development with GraphQL and React now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.