forked from prismake/typegql
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
28 lines (24 loc) · 742 Bytes
/
index.ts
File metadata and controls
28 lines (24 loc) · 742 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
import { ApolloServer } from 'apollo-server-express'
import { ApolloServerPluginDrainHttpServer } from 'apollo-server-core'
import express from 'express'
import http from 'http'
import { schema } from './schema.js'
async function startApolloServer() {
const app = express()
const httpServer = http.createServer(app)
const server = new ApolloServer({
schema,
plugins: [ApolloServerPluginDrainHttpServer({ httpServer })]
})
await server.start()
server.applyMiddleware({
app,
path: '/'
})
// Modified server startup
await new Promise<void>((resolve) =>
httpServer.listen({ port: 4000 }, resolve)
)
console.log(`🚀 Server ready at http://localhost:4000${server.graphqlPath}`)
}
startApolloServer()