diff --git a/.changeset/dull-mayflies-allow.md b/.changeset/dull-mayflies-allow.md new file mode 100644 index 000000000..92de40ebc --- /dev/null +++ b/.changeset/dull-mayflies-allow.md @@ -0,0 +1,5 @@ +--- +'@graphql-hive/gateway': patch +--- + +Fix the regression causing `port`, `host` and `pollingInterval` in the configuration is overriden by the default values of CLI parameters diff --git a/e2e/polling/gateway.config.ts b/e2e/polling/gateway.config.ts index 86919024d..6987c68d1 100644 --- a/e2e/polling/gateway.config.ts +++ b/e2e/polling/gateway.config.ts @@ -8,5 +8,4 @@ export const gatewayConfig = defineConfig({ console.log(`[${new Date().toISOString()}]`, 'Reading ' + SUPERGRAPH_PATH); return fs.promises.readFile(SUPERGRAPH_PATH, 'utf8'); }, - pollingInterval: 5_000, }); diff --git a/packages/gateway/src/cli.ts b/packages/gateway/src/cli.ts index bb5f78a81..705ede212 100644 --- a/packages/gateway/src/cli.ts +++ b/packages/gateway/src/cli.ts @@ -225,10 +225,9 @@ let cli = new Command() .addOption( new Option( '--fork ', - `count of workers to spawn. uses "${maxFork}" (available parallelism) workers when NODE_ENV is "production", otherwise "1" (the main) worker`, + `count of workers to spawn. uses "${maxFork}" (available parallelism) workers when NODE_ENV is "production", otherwise "1" (the main) worker (default: ${defaultOptions.fork})`, ) .env('FORK') - .default(defaultOptions.fork) .argParser((v) => { const count = parseInt(v); if (isNaN(count)) { @@ -249,15 +248,17 @@ let cli = new Command() ).env('CONFIG_PATH'), ) .addOption( - new Option('-h, --host ', `host to use for serving`).default( - defaultOptions.host, - defaultOptions.host, + new Option( + '-h, --host ', + `host to use for serving (default: ${defaultOptions.host})`, ), ) .addOption( - new Option('-p, --port ', `port to use for serving`) + new Option( + '-p, --port ', + `port to use for serving (default: ${defaultOptions.port})`, + ) .env('PORT') - .default(defaultOptions.port) .argParser((v) => { const port = parseInt(v); if (isNaN(port)) { @@ -269,9 +270,8 @@ let cli = new Command() .addOption( new Option( '--polling ', - `schema polling interval in human readable duration`, + `schema polling interval in human readable duration (default: 10s)`, ) - .default(10_000, '10s') .env('POLLING') .argParser((v) => { const interval = parseDuration(v) as number; diff --git a/packages/gateway/src/commands/proxy.ts b/packages/gateway/src/commands/proxy.ts index cd58c5a6e..318d3b193 100644 --- a/packages/gateway/src/commands/proxy.ts +++ b/packages/gateway/src/commands/proxy.ts @@ -121,7 +121,12 @@ export const addCommand: AddCommand = (ctx, cli) => ...defaultOptions, ...loadedConfig, ...opts, - pollingInterval: opts.polling, + pollingInterval: + opts.polling || + ('pollingInterval' in loadedConfig + ? loadedConfig.pollingInterval + : undefined) || + defaultOptions.pollingInterval, ...(hiveRegistryToken ? { reporting: { @@ -175,7 +180,7 @@ export const addCommand: AddCommand = (ctx, cli) => config.pollingInterval < 10_000 ) { process.stderr.write( - `error: polling interval duration too short, use at least 10 seconds\n`, + `error: polling interval duration too short ${config.pollingInterval}, use at least 10 seconds\n`, ); process.exit(1); } diff --git a/packages/gateway/src/commands/subgraph.ts b/packages/gateway/src/commands/subgraph.ts index 77979f61b..08331c7c6 100644 --- a/packages/gateway/src/commands/subgraph.ts +++ b/packages/gateway/src/commands/subgraph.ts @@ -82,7 +82,12 @@ export const addCommand: AddCommand = (ctx, cli) => ...defaultOptions, ...loadedConfig, ...opts, - pollingInterval: opts.polling, + pollingInterval: + opts.polling || + ('pollingInterval' in loadedConfig + ? loadedConfig.pollingInterval + : undefined) || + defaultOptions.pollingInterval, ...(hiveRegistryToken ? { reporting: { @@ -135,7 +140,7 @@ export const addCommand: AddCommand = (ctx, cli) => config.pollingInterval < 10_000 ) { process.stderr.write( - `error: polling interval duration too short, use at least 10 seconds\n`, + `error: polling interval duration too short ${config.pollingInterval}, use at least 10 seconds\n`, ); process.exit(1); } diff --git a/packages/gateway/src/commands/supergraph.ts b/packages/gateway/src/commands/supergraph.ts index 3b24ec2be..d5cfa9dd5 100644 --- a/packages/gateway/src/commands/supergraph.ts +++ b/packages/gateway/src/commands/supergraph.ts @@ -206,7 +206,12 @@ export const addCommand: AddCommand = (ctx, cli) => ...defaultOptions, ...loadedConfig, ...opts, - pollingInterval: opts.polling, + pollingInterval: + opts.polling || + ('pollingInterval' in loadedConfig + ? loadedConfig.pollingInterval + : undefined) || + defaultOptions.pollingInterval, ...registryConfig, supergraph, logging: ctx.log, @@ -251,7 +256,7 @@ export const addCommand: AddCommand = (ctx, cli) => config.pollingInterval < 10_000 ) { process.stderr.write( - `error: polling interval duration too short, use at least 10 seconds\n`, + `error: polling interval duration too short ${config.pollingInterval}, use at least 10 seconds\n`, ); process.exit(1); }