|
1 | 1 | /* eslint-disable @typescript-eslint/no-var-requires */ |
2 | 2 | require('esbuild-register') |
3 | 3 | const { makeExecutableSchema } = require('@graphql-tools/schema') |
4 | | -const { tables: arcTables } = require('@architect/functions') |
| 4 | +const { tables: arcTables, ws } = require('@architect/functions') |
5 | 5 | const { makeServer, subscribe } = require('../../../lib') |
6 | | -const { ApiGatewayManagementApi } = require('aws-sdk') |
7 | 6 | const { GraphQLError } = require('graphql') |
8 | 7 |
|
9 | | -const makeManagementAPI = () => { |
10 | | - const ARC_WSS_URL = process.env.ARC_WSS_URL |
11 | | - const port = process.env.ARC_INTERNAL || '3332' |
12 | | - |
13 | | - if (process.env.NODE_ENV === 'testing') { |
14 | | - return new ApiGatewayManagementApi({ |
15 | | - apiVersion: '2018-11-29', |
16 | | - endpoint: `http://localhost:${port}/_arc/ws`, |
17 | | - region: process.env.AWS_REGION || 'us-west-2', |
18 | | - }) |
19 | | - } |
20 | | - return new ApiGatewayManagementApi({ |
21 | | - apiVersion: '2018-11-29', |
22 | | - endpoint: `${ARC_WSS_URL.replace(/$ws/, 'http')}`, |
23 | | - }) |
24 | | -} |
25 | | - |
26 | 8 | const typeDefs = ` |
27 | 9 | type Query { |
28 | 10 | hello: String |
@@ -183,7 +165,7 @@ const subscriptionServer = makeServer({ |
183 | 165 | dynamodb: arcTables.db, |
184 | 166 | schema, |
185 | 167 | tableNames: fetchTableNames(), |
186 | | - apiGatewayManagementApi: makeManagementAPI(), |
| 168 | + apiGatewayManagementApi: ws._api, |
187 | 169 | onError: err => { |
188 | 170 | console.log('onError', err.message) |
189 | 171 | }, |
|
0 commit comments