-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (29 loc) · 777 Bytes
/
Copy pathindex.js
File metadata and controls
31 lines (29 loc) · 777 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
'use-strict'
// const { buildSchema } = require('graphql')
require('dotenv').config()
const { makeExecutableSchema } = require('graphql-tools')
const express = require('express')
const gqlMiddleware = require('express-graphql')
const { readFileSync } = require('fs')
const { join } = require('path')
const resolvers = require('./lib/resolvers')
const app = express()
const port = process.env.port || 3000
// Schema
const typeDefs = readFileSync(
join(
__dirname,
'lib',
'schema.graphql',
),
'utf-8'
)
const schema = makeExecutableSchema({typeDefs,resolvers})
app.use('/api', gqlMiddleware({
schema,
rootValue: resolvers,
graphiql: true
}))
app.listen(port, () => {
console.log(`Server is listening at http://localhost:${port}`)
})