Join us for GraphQL Summit, October 10-12 in San Diego. Use promo code ODYSSEY for $400 off your pass.
Launch GraphOS Studio

Moving to the Apollo Router from @apollo/gateway

If you have a federated that currently uses the Node.js @apollo/gateway library, this article describes how to move that to the Rust-based Apollo . We recommend the Apollo Router over @apollo/gateway for all s, because it provides significant performance improvements.

Moving to the Apollo from @apollo/gateway requires zero changes to your s!

What's different?

Unlike @apollo/gateway, the Apollo is packaged as a static, standalone binary. To customize its behavior, you pass it a YAML configuration file at startup. If you start the with the --hot-reload flag (or set the APOLLO_ROUTER_HOT_RELOAD environment to true), you can even modify that configuration without a restart.

You can download the Apollo source and use it as a library in a larger project. However, our goal is to remove the need to write custom code in your graph router (which is always necessary with @apollo/gateway). Instead, the Apollo exposes the most common critical features via declarative configuration.

Take inventory of your gateway configuration

The @apollo/gateway library is an extension to the Apollo Server library, and you need to consider your existing configuration of both libraries when moving to the Apollo . For example, you might be customizing which HTTP headers your s receive from client requests, or passing specific headers back to the client from specific s.

Because the Apollo uses an entirely different configuration mechanism, you should make a checklist of your gateway's custom behaviors to make sure those behaviors all remain when your migration is complete.

Start by looking for configuration and customizations in these places:

  • Environment s
  • Non-Apollo telemetry and instrumentation (e.g., OpenTelemetry or Datadog)
  • Constructor options passed to new ApolloGateway({ ... })
  • Constructor options passed to new ApolloServer({ ... })
  • Specific plugins passed to new ApolloServer({ plugins: [ ... ] })
  • Custom middleware (e.g., Express, Koa, Fastify)

The sections below provide more details on what to look for in each of these categories.

Environment variables

Many Apollo tools use environment s prefixed with APOLLO_ to set certain values, such as an API key for communicating with Apollo Studio.

Make sure to note any environment s you set in your existing gateway's environment, especially those prefixed with APOLLO_

The Apollo supports the following environment s used by @apollo/gateway:


The Apollo renames the following environment s used by @apollo/gateway:

ApolloGateway constructor options

The number of options you currently provide to your ApolloGateway constructor varies depending on whether you're using managed federation. If you are using managed federation, you might even be providing zero options to this constructor!


The supergraphSdl option is used in non-managed federation to provide a composed via a file or other string. Usually, that schema is composed using the Rover CLI.

You can achieve this option's effect with the Apollo in one of the following ways:

  • Move to managed federation with your move to the Apollo .

  • Provide the --supergraph command-line to the Apollo on startup:

    ./router --supergraph supergraph-schema.graphql

    The watches this file and hot-reloads it whenever it changes.

serviceList / IntrospectAndCompose

If you provide one of these constructor options, your gateway performs its own composition on startup. The Apollo Router does not support this in-process composition.

Instead, you need to perform composition using managed federation or the Rover CLI. With either of these methods, the Apollo can hot-reload its without restarting, and you avoid the possibility of a composition failure that results in downtime.


The buildService function enables you to customize the HTTP requests that the gateway sends to your s.

Common use cases include:

  • Overriding URLs at runtime
  • Propagating headers to s via RemoteGraphQLDataSource


The logger constructor option enables you to specify a different logger for messages that are produced by the ApolloGateway. By default, it inherits from the logger used by your ApolloServer instance. This option is also useful for changing logging verbosity.

In the Apollo , logging is JSON-structured in production environments by default, and you can adjust the verbosity. More advanced logging can be enabled through the use of plugins.

For more information, see Logging in the Apollo Router.

ApolloServer constructor options

The ApolloServer constructor supports a large variety of options, but for the purposes of moving to the Apollo , we'll focus on the following:

  • context
  • plugins

For the full list of options, see ApolloServer options. If you're using other options, additional steps might be necessary to replicate the same behavior. Please open a discussion on our GitHub repository so we can understand your needs and help you with a solution.


This constructor option is an object that enables you to propagate information across the request lifecycle. Use cases include:

  • Authentication information
  • Header propagation

The Apollo provides similar functionality.


This constructor option is an array of built-in or custom plugins that extend Apollo Server's functionality. If you provide plugins to your ApolloServer instance, take note of each plugin's functionality and add it to your migration checklist.

Before you attempt to replicate a plugin's functionality via an Apollo customization, check whether any configuration options provide that same functionality. For example, the supports options for propagating HTTP headers to s and enabling OpenTelemetry instrumentation.

If one of your @apollo/gateway plugins does require a corresponding customization, we encourage you to describe your use case in the Router repo's GitHub discussions. It might represent core functionality that the Apollo should provide out of the box, and we can help discuss the design.

For less common use cases, we also want to help build an ecosystem of shared customizations for the Apollo , enabling teams to more quickly add the functionality they need before native support is available.

Supported customizations

The Apollo currently supports two types of customizations that hook into the request-handling pipeline:

Examples for each are provided in their respective documentation, and in the Router repo.

Reporting migration issues

If you encounter a migration issue that isn't resolved by this article, please search for existing GitHub discussions and start a new discussion if you don't find what you're looking for.

Federation version support
Edit on GitHubEditForumsDiscord