Router Configuration

Configure a router via environment variables, command-line options, and YAML


Learn how to customize the behavior of your GraphOS Router or Apollo Router Core with environment variables, command-line commands and options, and YAML file configuration.

Environment variables

If you're using the GraphOS Router with managed federation and GraphOS Studio, set these environment variables in the startup command:

Bash
1APOLLO_KEY="..." APOLLO_GRAPH_REF="..." ./router
Environment Variable Description
APOLLO_GRAPH_REF
The graph ref for the GraphOS graph and variant that the router fetches its supergraph schema from (e.g., docs-example-graph@staging).Required when using managed federation, except when using an offline license to run the router.
APOLLO_KEY
The graph API key that the router should use to authenticate with GraphOS when fetching its supergraph schema.Required when using managed federation, except when using an offline license to run the router or when using APOLLO_KEY_PATH.
APOLLO_KEY_PATH
⚠️ This is not available on Windows.A path to a file containing the graph API key that the router should use to authenticate with GraphOS when fetching its supergraph schema.Required when using managed federation, except when using an offline license to run the router or when using APOLLO_KEY.

Command-line options

After installing the Apollo Router Core in your current working directory, you can run the router with the following example command:

Bash
1./router --config router.yaml --supergraph supergraph-schema.graphql

This reference lists and describes the options supported by the router binary. Where indicated, some of these options can also be provided via an environment variable. If an option is provided both ways, the command-line value takes precedence.

Option / Environment Variable Description
-s / --supergraph
APOLLO_ROUTER_SUPERGRAPH_PATH, APOLLO_ROUTER_SUPERGRAPH_URLS
The supergraph schema of a router. Specified by absolute or relative path (-s / --supergraph <supergraph_path>, or APOLLO_ROUTER_SUPERGRAPH_PATH), or a comma-separated list of URLs (APOLLO_ROUTER_SUPERGRAPH_URLS).
💡 Avoid embedding tokens in APOLLO_ROUTER_SUPERGRAPH_URLS because the URLs may appear in log messages.
Setting this option disables polling from Apollo Uplink to fetch the latest supergraph schema.To learn how to compose your supergraph schema with the Rover CLI, see the Federation quickstart.Required if you are not using managed federation. If you are using managed federation, you may need to set this option when following advanced deployment workflows.