Authentication with Apollo Subscriptions

In Chapter 6, Authentication with Apollo and React, of this book, we implemented authentication through the localStorage of your browser. The back end generates a signed JWT that the client sends with every request inside the HTTP headers. In Chapter 9, Implementing Server-side Rendering, we extended this logic to support cookies to allow server-side rendering. Now that we've introduced WebSockets, we need to take care of them separately, as we did with the server-side rendering and our GraphQL API.

How is it possible for the user to receive new messages when they aren't authenticated on the back end for the WebSocket transport protocol?

The best way to figure this out is to have a look at your browser's ...

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.