Skip to content

Commit

Permalink
await for all subgraphs to be up
Browse files Browse the repository at this point in the history
  • Loading branch information
dariuszkuc committed Feb 14, 2023
1 parent 247d7fd commit 7e90e16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
4 changes: 2 additions & 2 deletions packages/compatibility/src/startSupergraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import execa from 'execa';
import debug from 'debug';
import { logWithTimestamp, writeableDebugStream } from './utils/logging';
import { composeDevSupergraph, composeSupergraph } from './composeSupergraph';
import { healtcheckSupergraph } from './utils/client';
import { healthcheckSupergraph } from './utils/client';
import { normalizePath } from './utils/path';
import { resolve } from 'path';
import { readFile, writeFile } from 'fs/promises';
Expand Down Expand Up @@ -181,7 +181,7 @@ async function startSupergraphUsingDocker(config: DockerConfig) {
throw new Error('docker-compose did not start successfully');
}

const started = await healtcheckSupergraph(
const started = await healthcheckSupergraph(
`http://localhost:${config.port ?? '4001'}${config.path ?? ''}`,
);
if (started) {
Expand Down
19 changes: 7 additions & 12 deletions packages/compatibility/src/utils/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,17 @@ export function routerRequest(
return graphqlRequest(ROUTER_URL, req, headers);
}

export async function healthcheckAll(libraryName: string): Promise<boolean> {
export async function healthcheckSupergraph(url: string): Promise<Boolean> {
const routerUp = await healthcheckRouter();
if (!routerUp) {
return false;
}
const inventoryUpPromise = healthcheck('inventory', INVENTORY_URL);
const usersUpPromise = healthcheck('users', USERS_URL);
const productsUpPromise = healthcheck('products', url);

return healthcheck(libraryName, PRODUCTS_URL);
}

export async function healtcheckSupergraph(url: string): Promise<Boolean> {
const routerUp = await healthcheckRouter();
return (
routerUp &&
healthcheck('inventory', INVENTORY_URL) &&
healthcheck('users', USERS_URL) &&
healthcheck('products', url)
await inventoryUpPromise &&
await usersUpPromise &&
await productsUpPromise
);
}

Expand Down

0 comments on commit 7e90e16

Please sign in to comment.