Hive Gateway CLI Reference

An overview of all the CLI arguments and environment variables for the hive-gateway CLI. Get started with the CLI.

Usage

You can get help with using the CLI by appending the --help argument:

hive-gateway --help

which will print out the following:

Usage: hive-gateway [options] [command]

serve GraphQL federated architecture for any API service(s)

Options:
  --fork <count>                          count of workers to spawn. defaults to "os.availableParallelism()" when NODE_ENV is "production", otherwise only one (the main) worker
                                          (default: 1 (env: FORK)
  -c, --config-path <path>                path to the configuration file. defaults to the following files respectively in the current working directory: gateway.config.ts,
                                          gateway.config.mts, gateway.config.cts, gateway.config.js, gateway.config.mjs, gateway.config.cjs (env: CONFIG_PATH)
  -h, --host <hostname>                   host to use for serving (default: "127.0.0.1" (default: "127.0.0.1")
  -p, --port <number>                     port to use for serving (default: 4000 (env: PORT)
  --polling <duration>                    schema polling interval in human readable duration (default: "10s") (env: POLLING)
  --no-masked-errors                      don't mask unexpected errors in responses
  --masked-errors                         mask unexpected errors in responses (default: true)
  --hive-registry-token <token>           Hive registry token for usage metrics reporting (env: HIVE_REGISTRY_TOKEN)
  --apollo-graph-ref <graphRef>           Apollo graph ref of the managed federation graph (<YOUR_GRAPH_ID>@<VARIANT>) (env: APOLLO_GRAPH_REF)
  --apollo-key <apiKey>                   Apollo API key to use to authenticate with the managed federation up link (env: APOLLO_KEY)
  --help                                  display help for command

Commands:
  supergraph [options] [schemaPathOrUrl]  serve a Federation supergraph provided by a compliant composition tool such as GraphQL Mesh or Apollo Rover
  subgraph [schemaPathOrUrl]              serve a Federation subgraph that can be used with any Federation compatible router like Hive Gateway or Apollo Router
  proxy [options] [endpoint]              serve a proxy to a GraphQL API and add additional features such as monitoring/tracing, caching, rate limiting, security, and more
  help [command]                          display help for command
💡
All arguments can also be configured in the config file.

Environment Variables

In addition to the env vars showcased in the CLI usage, more are available.

These are usually used for easier usage with these two schema registry services. You don’t need any configuration file if you provide these environment variables.

Hive Registry

  • HIVE_CDN_ENDPOINT: The endpoint of the Hive Registry CDN
  • HIVE_CDN_KEY: The API key provided by Hive Registry to fetch the schema
  • HIVE_REGISTRY_TOKEN: The token to push the metrics to Hive Registry

Learn more about Hive Registry integration here

Apollo GraphOS

  • APOLLO_KEY: The API key provided by Apollo GraphOS to fetch the supergraph.
  • APOLLO_GRAPH_REF: The API key provided by Apollo GraphOS to fetch the supergraph.
  • APOLLO_SCHEMA_CONFIG_DELIVERY_ENDPOINT: The URL of the managed federation up link. By default, it uses the first uplink in the list.

Learn more about GraphOS integration here