Runtime Configuration Overview
Configure GraphOS Router to customize Apollo Connectors
In this guide, you'll learn how to configure the GraphOS Router for Apollo Connectors by configuring connectors
and other options in your router's configuration.
Configuration
Configuring a self-hosted router for Connectors requires setting options in the router's YAML configuration file.
When using Rover, you can call rover dev
to start a router locally and use its --router-config
option to pass your configuration file. For example:
APOLLO_KEY=... \
APOLLO_GRAPH_REF=... \
APOLLO_ROVER_DEV_ROUTER_VERSION=2.0.0 \
rover dev --supergraph-config supergraph.yaml
--router-config router.yaml
Connectors configuration are nested under the connectors
key.
Some configurations are applicable globally to all Connectors, some are applicable to specific Connector sources, and some can be configured for both.
For example, you can apply request limits both globally across all Connectors and on specific Connector sources.
connectors:
# This applies globally to all Connectors
max_requests_per_operation_per_source: 100
# This applies to Connectors with the "v1" source in the "example" subgraph
sources:
example.v1:
max_requests_per_operation: 50
To specify a source, you must include the subgraph name and source name, separated by a .
—for example, subgraph_name.connector_name
.
To learn more about other router configurations, go to the router configuration reference.
Accessing router configuration in Connectors
You may want to use a configuration value or environment variable as part of a request. You can do this per source in the router configuration using the $config
section.
connectors:
sources:
example.v1:
# These configurations apply to Connectors with the "v1" source in the "example" subgraph
$config:
my.config.value: true
example.v2:
# These configurations apply to Connectors with the "v2" source in the "example" subgraph
$config:
another.config.value: true # Applies to the "v2" source
You can then access the value using the $config
variable in the schema, for example in the URL template or header of a
connector:
type Query {
something: String!
@connect(
http: {
GET: "https://api.example.com/products/{$config.name_of_the_variable}"
headers: [{ name: "Authorization", value: "Bearer {$config.name_of_variable_containing_token}" }]
}
selection: ""
)
}
You can also access nested values using dot notation. For example $config.nested.value
would refer to:
connectors:
sources:
example.v1:
$config:
nested:
value: "some value"
Router configuration also lets you inject environment variables like this:
connectors:
sources:
example.v1:
$config:
name_of_the_variable: ${env.VARIABLE_NAME}
Next steps
Explore all router configuration options in the router configuration reference
See the other pages in this section for Connectors-specific security, performance, and observability configurations