Apollo Router usage and config
For installation instructions, see the quickstart.
You run Apollo Router with the following command (assuming you're in the same directory as the
./router --config configuration.yaml --supergraph supergraph-schema.graphql
Options are described below.
The absolute or relative path to the router's supergraph schema.
To learn how to compose your supergraph schema with the Rover CLI, see the Federation quickstart.
Required unless you provide this value via the
The absolute or relative path to the router's optional YAML configuration file.
You can also provide this value via the
Log level which may be one of:
If you attempt to query Apollo Router from a browser-based client, your request might be rejected due to CORS policies.
You can configure CORS in the YAML configuration file you can provide to Apollo Router.
Here's an example configuration for adding
localhost to the list of approved origins:
# examples/nodejs/configuration.yaml server: listen: 127.0.0.1:4000 cors: origins: - https://studio.apollographql.com - http://localhost
Apollo Router detects if the stdout is a TTY and enables JSON logging only if it is not.
Apollo Router takes an optional YAML configuration file as input via the
--config option. All supported configuration options are listed below:
# Configuration of the router's HTTP server server: # The socket address and port to listen on # Defaults to 127.0.0.1:4000 listen: 127.0.0.1:4000 # Cross origin request headers cors: # Set to false to disallow any origin and rely exclusively on `origins` # Defaults to true allow_any_origin: true # List of accepted origins origins: - https://studio.apollographql.com # Set to true to add the `Access-Control-Allow-Credentials` header allow_credentials: false # The headers to allow. # Defaults to the required request header for Apollo Studio: Content-Type allow_headers: [ Content-Type ] # Allowed request methods # Defaults to GET, POST, OPTIONS. methods: [ GET, POST, OPTIONS ] # Which response headers should be made available to scripts running in the browser, # in response to a cross-origin request. expose_headers: # Names and URLs of all subgraphs # By default, this information is parsed from the supergraph schema # Provide it here to override subgraph names or URLs subgraphs: # Defines a subgraph named "accounts" accounts: # The URL of the accounts subgraph's GraphQL endpoint routing_url: http://localhost:4001/graphql # Defines a second subgraph named "products" products: routing_url: http://localhost:4003/graphql # OpenTelemetry configuration. Choose either jaeger or otlp opentelemetry: # Configuration to send traces and metrics to a Jaeger service jaeger: # optional url of the jaeger collector collector_endpoint: "http://example.org" # name of the service used in traces # defaults to router service_name: "router" # the username and password are obtained from the environment variables # JAEGER_USERNAME and JAEGER_PASSWORD # Configuration to send traces and metrics to an OpenTelemetry Protocol compatible service otlp: tracing: exporter: # 'http' for OTLP/HTTP, 'grpc' for OTLP/gRPC http: # URL of the exporter endpoint: # Possible options: 'Grpc' for GRPC protocol and 'HttpBinary' for HTTP protocol with binary protobuf protocol: Grpc # timmeout in seconds timeout: 60 metadata: - foo: bar - foo: baz - bar: baz trace_config: sampler: ParentBased: TraceIdRatioBased: 0.42 max_events_per_span: 1 max_attributes_per_span: 2 max_links_per_span: 3 max_attributes_per_event: 4 max_attributes_per_link: 5 resource: attrs: key1: String: value key2: Bool: true key3: I64: 42 key4: F64: 42.0 key5: Array: String: - value1 - value2