-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
37 lines (28 loc) · 836 Bytes
/
server.js
File metadata and controls
37 lines (28 loc) · 836 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
31
32
33
34
35
36
37
/**
* Created by ebinhon on 8/4/2016.
*/
'use strict';
import express from 'express';
import schema from './data/schema';
import { graphql } from 'graphql';
import expressGraphQL from 'express-graphql';
import bodyParser from 'body-parser';
let app = express();
let PORT = 8081;
//app.use(bodyParser.text({ type: 'application/graphql' }));
//app.post('/graphql', (req, res) => {
// graphql(schema, req.body)
// .then((result) => {
// res.send(JSON.stringify(result, null, 2));
// });
//});
app.use('/graphql', expressGraphQL(req => ({
schema,
graphiql: true,
rootValue: { request: req },
})));
let server = app.listen(PORT, function() {
let host = server.address().address;
let port = server.address().port;
console.log('GraphQL listening at http://%s:%s', host, port);
});