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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.