Skip to main content

Apollo Router

Inigo distributes a custom build of the open-source Apollo Router that includes the Inigo Agent compiled an open-source Rust plugin. This distribution makes it easy to gain all of the observability, security, and Apollo Federation schema management of Inigo when using the open-source Apollo Router. The Inigo distribution of Apollo Router is available as a Docker image.

Using Inigo's Apollo Federation schema management is recommended for the Inigo distribution of Apollo Router, but nothing prevents one from using Apollo's Rover and GraphOS for schema management instead. Additionally, Inigo's private schema registry can optionally be used with Inigo's schema management.

Note: Existing capabilities of the open-source Apollo Router code are not overridden or disabled by the Inigo Rust plugin. The Apollo Router is configured via input variables to achieve the desired behavior when used with Inigo.

Note: The Inigo distribution of Apollo Router can be freely deployed to your infrastructure per the terms of the Apollo Router Elastic License.

Run Apollo Router in Docker with Locally Composed Supergraph

The simplest way to get started with the Inigo distribution of Apollo Router is to run it locally with docker run and a locally composed supergraph schema, which can be accomplished using the following steps:

1. Create a Gateway Configuration

In a local project, create a local.gateway.yaml that will configure a Gateway that points to the local subgraph services. Because Apollo Router is running inside a Docker container, host.docker.internal must be used for the service URLs rather than localhost. The Gateway can be configured as shown in the following example:

Note: The Gateway should have the same name and label as the Service that was created with the token.

kind: Gateway
name: apollo-router-fed-2-demo
label: local
spec:
composition: ApolloFederation_v2
services:
- name: accounts
url: "http://host.docker.internal:4001/graphql"
schema_files:
- ../services/accounts/schema.graphql
- name: reviews
url: "http://host.docker.internal:4002/graphql"
schema_files:
- ../services/reviews/schema.graphql
- name: products
url: "http://host.docker.internal:4003/graphql"
schema_files:
- ../services/products/schema.graphql
- name: inventory
url: "http://host.docker.internal:4004/graphql"
schema_files:
- ../services/inventory/schema.graphql

2. Compose the Local Supergraph Schema

Note: Please see Local Composition for further information for configuring and composing local supergraph schemas.

inigo compose inigo/local.gateway.yaml > supergraph.yaml

3. Configure the router.yaml for Apollo Router

Apollo Router requires a YAML configuration to run.

The router.yaml for use with docker run :

supergraph:
introspection: true
listen: 0.0.0.0:8080
health_check:
listen: 0.0.0.0:8088
homepage:
enabled: false
sandbox:
enabled: false
include_subgraph_errors:
all: true
headers:
all:
request:
- propagate:
matching: .*
cors:
allow_any_origin: true
origins: []
plugins:
inigo.middleware: {}

4. Run docker run for the Inigo distribution of Apollo Router

The following docker run command will mount a router.yaml, mount the local supergraph.graphql, and run the Inigo distribution of Apollo Router listening on port 4000:

IMPORTANT: An INIGO_SERVICE_TOKEN variable (-e) must be passed to the docker run command.

echo $INIGO_SERVICE_TOKEN

docker run --rm -p 4000:8080 \
-v ${PWD}/router.yaml:/dist/config/router.yaml \
-v ${PWD}/supergraph.graphql:/dist/config/supergraph.graphql \
-e APOLLO_ROUTER_CONFIG_PATH=/dist/config/router.yaml \
-e APOLLO_ROUTER_SUPERGRAPH_PATH=/dist/config/supergraph.graphql \
-e INIGO_REGISTRY_ENABLED=false \
-e INIGO_SERVICE_TOKEN=$INIGO_SERVICE_TOKEN \
--name apollo_router_local inigohub/inigo_apollo_router:latest

Note: The variable INIGO_REGISTRY_ENABLED=false is set because a locally composed supergraph schema is being used instead of a published schema retrieved from the Inigo Schema Registry.

Run Apollo Router in Docker using the Inigo Schema Registry

The Inigo distribution of Apollo Router can also be run locally with docker run and be configured to pull down a published schema from the Inigo Schema Registry. This does not require a locally-composed supergraph schema file to be present.

Note: A Private Schema Registry can also be run if Inigo's cloud-hosted Schema Registry does not meet your requirements.

1. Create a Gateway Configuration

The Gateway configuration from the previous example still applies and can be reused.

2. Publish the Supergraph Schema

By default, the composed supergraph schema will be auto_published to the Schema Registry, and no further action is required. If auto_published is set to false, a manual publish of the composed schema is necessary.

3. Configure the router.yaml for Apollo Router

Apollo Router requires a YAML configuration to run, and the previous example still applies.

4. Run docker run for the Inigo distribution of Apollo Router

IMPORTANT: An INIGO_SERVICE_TOKEN variable (-e) must be passed to the docker run command.

echo $INIGO_SERVICE_TOKEN

docker run --rm -p 4000:8080 \
-v ${PWD}/router.yaml:/dist/config/router.yaml \
-e APOLLO_ROUTER_CONFIG_PATH=/dist/config/router.yaml \
-e APOLLO_ROUTER_SUPERGRAPH_PATH=/dist/config/supergraph.graphql \
-e INIGO_SERVICE_TOKEN=$INIGO_SERVICE_TOKEN \
--name apollo_router inigohub/inigo_apollo_router:latest

After Apollo Router starts up, the composed schema will be downloaded from the Schema Registry and dynamically applied. Additionally, each time a new schema is published, it will be automatically downloaded and dynamically applied to the Apollo Router.