-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
35 lines (31 loc) · 863 Bytes
/
Copy pathserver.js
File metadata and controls
35 lines (31 loc) · 863 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
import Express from 'express';
import GraphHTTP from 'express-graphql';
import GraphQLQuerySchema from './schema';
// Express server config
const APP_PORT = 3000;
// Express server instance
const app = Express();
/**
* Run GraphQLHTTP as Middleware whenever go to given route.
* GraphHTTP initialisaton accepts Options options including the
* GraphQLQuerySchema.
* Options include:
* - Pretty print GraphQL Query so human readable
* - GraphiQL is browser-based IDE allows GraphQL Queries, view Responses,
* view GraphQL Structure Docs/Linting
*/
app.use(
'/graphql',
GraphHTTP({
schema: GraphQLQuerySchema,
rootValue: {
message: 'Welcome to GraphQL Sequelize App'
},
pretty: true,
graphiql: true
})
);
// Express server spawn
app.listen(APP_PORT, () => {
console.log(`App listening on port ${APP_PORT}`);
});