-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
27 lines (22 loc) · 814 Bytes
/
server.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
const express = require("express")
const cors = require("cors")
const { makeExecutableSchema } = require('@graphql-tools/schema')
const { typeDefs, resolvers } = require('./graphql')
const { permissions } = require('./guards')
const { createApolloServer } = require('./apollo/createApolloServer')
require('dotenv').config()
const startApolloServer = async () => {
const app = express()
app.use(cors())
app.use(express.json())
const schema = makeExecutableSchema({
typeDefs,
resolvers,
});
const server = createApolloServer([permissions], { app, schema })
await server.start()
server.applyMiddleware({ app });
app.listen(3000)
console.log(`🚀 Apollo Server ready at http://localhost:3000${server.graphqlPath}`);
}
module.exports = { startApolloServer }