-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
30 lines (27 loc) · 816 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import express from 'express';
import bodyParser from 'body-parser';
import {graphiqlExpress, graphqlExpress} from 'apollo-server-express';
import expressPlayground from 'graphql-playground-middleware-express';
import morgan from 'morgan';
import {client, pubsub} from './data/redis';
import schema from './data/schema';
const logger = morgan('dev');
const app = express();
app.use(logger);
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.use('/graphql', graphqlExpress({
schema: schema,
context: {
client,
pubsub,
}
}));
app.get('/graphiql', graphiqlExpress({
endpointURL: '/graphql',
subscriptionsEndpoint: 'ws://localhost:3000/subscriptions'
}));
app.get('/playground', expressPlayground({
endpoint: '/graphql',
}));
export default app;