-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
39 lines (28 loc) · 923 Bytes
/
Copy pathtest.js
File metadata and controls
39 lines (28 loc) · 923 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
38
39
const fs = require('fs')
const Server = require('../turbo-http2')
const GraphQL = require('./main')
const options = {
key: fs.readFileSync('../localhost-key.pem'),
cert: fs.readFileSync('../localhost.pem')
}
const app = new Server()
app.static('/public')
// GraphQL config
// Parse GraphQL Schema
const RawSchema = fs.readFileSync('schema.graphql', { encoding: 'utf8' })
const Schema = GraphQL.SchemaParser(RawSchema)
console.log(Schema)
// Test GraphQL OperationDefinition parser
const RawOperation = fs.readFileSync('test_query.graphql', { encoding: 'utf8' })
const Operation = GraphQL.operationDefinitionParser(RawOperation)
console.log(Operation)
app.get('/', (req, res) => {
res.body = 'Hello World, from GeekSkool.'
return res
})
app.post('/graphql-api', (req, res) => {
console.log(GraphQL.operationDefinitionParser(req.body.query))
res.body = 'pong'
return res
})
app.listen(3100, options)