-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
23 lines (19 loc) · 757 Bytes
/
server.js
File metadata and controls
23 lines (19 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import express from 'express';
import bodyParser from 'body-parser';
import { graphqlExpress, graphiqlExpress } from 'apollo-server-express';
import { makeExecutableSchema } from 'graphql-tools';
import typeDefs from './schema/user';
import resolvers from './resolver/user';
import Collection from './config/connection'
import mongoose from 'mongoose';
mongoose.connect('mongodb://localhost/test');
const app = express();
const schema = makeExecutableSchema({
typeDefs,
resolvers,
});
app.use('/graphql', bodyParser.json(), graphqlExpress({ schema , context : { Collection } }));
app.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql' }));
app.listen(3000, () => {
console.log('Go to http://localhost:3000/graphiql to run queries!');
});