-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.connect.js
37 lines (29 loc) · 883 Bytes
/
server.connect.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
31
32
33
34
35
36
37
import connect from 'connect';
import { apolloConnect, graphiqlConnect } from 'apollo-server';
import { makeExecutableSchema, addMockFunctionsToSchema } from 'graphql-tools';
import bodyParser from 'body-parser';
import Schema from './data/schema';
import Mocks from './data/mocks';
import Resolvers from './data/resolvers';
const PORT = 8080;
const app = connect();
const executableSchema = makeExecutableSchema({
typeDefs: Schema,
resolvers: Resolvers,
});
/*addMockFunctionsToSchema({
schema: executableSchema,
mocks: Mocks,
preserveResolvers: false,
});*/
app.use('/graphql', bodyParser.json());
app.use('/graphql', apolloConnect({
schema: executableSchema,
context: {},
}));
app.use('/graphiql', graphiqlConnect({
endpointURL: '/graphql',
}));
app.listen(PORT, () => console.log(
`GraphQL Server is now running on http://localhost:${PORT}/graphql`
));