Notifications with Apollo Subscriptions

In this section, I'll quickly guide you through the second use case for subscriptions. Showing notifications to a user are traditional events that a user should see as you know from Facebook. Instead of relying on the subscribeToMore function, we use the Subscription component that's provided by Apollo. This component works like the Query and Mutation components, but for subscriptions.

Follow these steps to get your first Subscription component running:

  1. Create a subscriptions folder inside the client's components folder. You can save all subscriptions that you implement using Apollo's Subscription component inside this folder.
  2. Insert a messageAdded.js file into the folder and paste in the following ...

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.