Installation

This section details how to set up a GraphQL server to support subscriptions based on graphql subscriptions and subscriptions-transport-ws.

We will use the PubSub implementation from graphql-subscriptions, and we will connect it to subscribe executor of graphql, and publish the data using subscriptions-transport-ws (a WebSocket server and client library for GraphQL that can be used directly in a JavaScript app or wired up to a fully-featured GraphQL client like Apollo or Relay.

The process of setting up a GraphQL subscriptions server consist of the following steps:

Declaring subscriptions in the GraphQL schema

Setup a PubSub instance that our server will publish new events to

Hook together PubSub event and GraphQL subscription.

Setting up SubscriptionsServer, a transport between the server and the clients