Fix watcher endpoints check in gateway server (#19)
This commit is contained in:
parent
86fe1c03af
commit
c420078ad5
@ -1,3 +1,9 @@
|
||||
# gateway-server
|
||||
|
||||
Reference: https://github.com/ardatan/schema-stitching/blob/master/examples/combining-local-and-remote-schemas
|
||||
GQL server to proxy queries to their respective watchers
|
||||
|
||||
Queries from a watcher are prefixed according to the [watchers.json](./src/watchers.json) file
|
||||
|
||||
## References
|
||||
|
||||
- https://github.com/ardatan/schema-stitching/blob/master/examples/combining-local-and-remote-schemas
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
|
||||
import { createYoga } from 'graphql-yoga';
|
||||
import isReachable from 'is-reachable';
|
||||
import assert from 'assert';
|
||||
import { URL } from 'url';
|
||||
|
||||
import { buildHTTPExecutor } from '@graphql-tools/executor-http';
|
||||
import { stitchSchemas } from '@graphql-tools/stitch';
|
||||
@ -13,7 +15,14 @@ import watchers from './watchers.json';
|
||||
|
||||
async function makeGatewaySchema () {
|
||||
// Check that watcher endpoints are reachable.
|
||||
await isReachable(watchers.map(watcher => watcher.endpoint));
|
||||
for (const watcher of watchers) {
|
||||
const url = new URL(watcher.endpoint);
|
||||
|
||||
assert(
|
||||
await isReachable(`${url.hostname}:${url.port}`),
|
||||
`Watcher endpoint ${watcher.endpoint} is not reachable.`
|
||||
);
|
||||
}
|
||||
|
||||
const subSchemaPromises = watchers.map(async watcher => {
|
||||
// Make remote executor:
|
||||
@ -44,6 +53,6 @@ export const gatewayApp = createYoga({
|
||||
schema: makeGatewaySchema(),
|
||||
maskedErrors: false,
|
||||
graphiql: {
|
||||
title: 'Azimuth watchers'
|
||||
title: 'Azimuth Watchers'
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user