-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
48 lines (40 loc) · 1.11 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { config } from 'dotenv'
import * as gcp from '@pulumi/gcp'
import { ApolloServer } from 'apollo-server-cloud-functions'
import neo4j from 'neo4j-driver'
// eslint-disable-next-line
const neo4jGraphqlJs = require('neo4j-graphql-js')
const { makeAugmentedSchema } = neo4jGraphqlJs
config()
function factory() {
const typeDefs = `
type Person {
name: String
}
`
const schema = makeAugmentedSchema({ typeDefs })
const driver = neo4j.driver(
'bolt://18.208.119.122:32864',
neo4j.auth.basic('neo4j', 'floor-custody-directions')
)
const server = new ApolloServer({
schema,
introspection: true,
playground: {
endpoint: '/dev/graphql',
},
context: { driver },
})
const cb = server.createHandler()
return cb
}
const apiFunction = new gcp.cloudfunctions.HttpCallbackFunction('apiFunction', {
callbackFactory: factory,
})
// eslint-disable-next-line
const apiInvoker = new gcp.cloudfunctions.FunctionIamMember('apiInvoker', {
cloudFunction: apiFunction.function.id,
member: 'allUsers',
role: 'roles/cloudfunctions.invoker',
})
export const url = apiFunction.httpsTriggerUrl