Skip to content

Commit

Permalink
Step 7.2: Provide a new instance of PubSub to context
Browse files Browse the repository at this point in the history
  • Loading branch information
DAB0mB authored and Urigo committed May 20, 2020
1 parent 8990384 commit 5d81bbf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApolloServer, gql } from 'apollo-server-express';
import { ApolloServer, gql, PubSub } from 'apollo-server-express';
import cors from 'cors';
import express from 'express';
import schema from './schema';
Expand All @@ -12,7 +12,11 @@ app.get('/_ping', (req, res) => {
res.send('pong');
});

const server = new ApolloServer({ schema });
const pubsub = new PubSub();
const server = new ApolloServer({
schema,
context: () => ({ pubsub }),
});

server.applyMiddleware({
app,
Expand Down

0 comments on commit 5d81bbf

Please sign in to comment.