-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
41 lines (29 loc) · 711 Bytes
/
Copy pathserver.js
File metadata and controls
41 lines (29 loc) · 711 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
'use strict'
const http = require('http')
const express = require('express')
const{ ApolloServer, gql } = require('apollo-server-express')
const db = require(',/models')
const { typeDefs, resolvers } = require('./graphql')
const port = +process.env.PORT || 8080
const app = express()
const server = http.createServer(app)
const graphqlServer = new ApolloServer({
typeDefs,
resolvers,
context ({ req }){
return {
db
}
},
playground:true,
introspection: true
})
app.get('/', (req,res) => {
res.redirect('/graphql')
})
graphqlServer.applyMiddleware({
app
})
server.listen(port,() => {
console.log(`GraphQL Server running on port ${port}`)
})