-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
32 lines (30 loc) · 949 Bytes
/
index.ts
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
import {
GraphQLServer,
JsonLogger
} from '@dreamit/graphql-server'
import {
userSchema,
userSchemaResolvers
} from './ExampleSchemas'
import express from 'express'
import bodyParser from 'body-parser'
import {
GraphQLServerRequest,
GraphQLServerResponse
} from '@dreamit/graphql-server-base'
const graphqlServer = new GraphQLServer(
{
schema: userSchema,
rootValue: userSchemaResolvers,
logger: new JsonLogger('expressjs-server', 'user-service')
}
)
const graphQLServerPort = 7070
const graphQLServerExpress = express()
graphQLServerExpress.use(bodyParser.text({type: '*/*'}))
graphQLServerExpress.all('/graphql',
(request: GraphQLServerRequest, response: GraphQLServerResponse) => {
return graphqlServer.handleRequest(request, response)
})
graphQLServerExpress.listen({port: graphQLServerPort})
console.info(`Starting GraphQL server on port ${graphQLServerPort}`)