forked from benawad/graphql-express-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (24 loc) · 628 Bytes
/
Copy pathindex.js
File metadata and controls
30 lines (24 loc) · 628 Bytes
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 'graphql-server-express';
import { makeExecutableSchema } from 'graphql-tools';
import typeDefs from './schema';
import resolvers from './resolvers';
import models from './models';
const schema = makeExecutableSchema({
typeDefs,
resolvers,
});
const app = express();
app.use(
'/graphiql',
graphiqlExpress({
endpointURL: '/graphql',
}),
);
app.use(
'/graphql',
bodyParser.json(),
graphqlExpress({ schema, context: { models } }),
);
models.sequelize.sync().then(() => app.listen(3000));