Docs
Launch GraphOS Studio

Setting up managed federation


This article describes how to connect your to Apollo GraphOS to enable features.

As with all changes, you should first set up in a non-production environment, such as staging. To support this, you can create multiple variants of your in . Each represents a distinct version of the same graph for different environments.

1. Get started

First, complete the Set up Apollo tools step from this tutorial, including:

  • Creating an Apollo account
  • Creating a in Studio
  • Installing and authenticating the

2. Publish all subgraph schemas

In a architecture, each of your subgraphs uses the to publish its schema to :

rover subgraph publish
rover subgraph publish
rover subgraph publish
Router
Products subgraph
Reviews subgraph
Inventory subgraph
GraphOS
Schema Registry

Do the following for each of your subgraphs:

  1. Obtain the following values, which are required for the rover subgraph publish command:

    • The name that uniquely identifies the within your graph (e.g., products).
    • The URL that your will use to communicate with the (e.g., http://products-graphql.svc.cluster.local:4001/).
  2. Run the rover subgraph publish command, providing it your 's schema in one of the ways shown:

    # Provide a local .graphql file path
    rover subgraph publish my-graph@my-variant --name products --routing-url http://products-graphql.svc.cluster.local:4001/ --schema ./schema.graphql
    # Provide an introspection result via stdin
    rover subgraph introspect http://localhost:4000 | rover subgraph publish my-graph@my-variant --name products --routing-url http://products-graphql.svc.cluster.local:4001/ --schema -

As you register your , the schema registry attempts to compose their latest versions into a single supergraph schema. Whenever succeeds, your managed can fetch the latest from .

You can also manually fetch your latest with the rover supergraph fetch command, or retrieve it from your 's Schema > SDL tab in .

3. Modify your router's startup command

If you've already set up without connecting your to , you're probably passing the --supergraph (or -s) option to the 's startup command:

./router --config ./router.yaml --supergraph ./your-local-supergraph.graphql

The --supergraph option applies in scenarios where the doesn't retrieve the by polling Apollo Uplink. These include:

  • Enabling different deployment environments to refer to a single graph variant, for example, for blue-green deployment: Use a workflow with the Platform API to compose and retrieve the for each environment. This enables each environment's to use the environment's supergraph schema, and then a single graph can capture and analyze the and traffic of either environment when deployed.

  • Unmanaged federation: The composes the and passes the schema's file path to the via the --supergraph option.

For other scenarios where the retrieves the from Apollo Uplink, remove the --supergraph option (but leave --config if it's present):

./router --config ./router.yaml

With federation managed by , is performed when are published, and the regularly polls for an updated from Apollo Uplink. This enables you to add, remove, and modify your subgraphs without needing to restart your .

4. Connect your router to GraphOS

Like your , your uses a graph API key to identify itself to .

After obtaining your API key, you set the following environment variables in your 's environment:

  • APOLLO_KEY (set this to your API key)
  • APOLLO_GRAPH_REF
    • This tells the which of which to use (for example, docs-example-graph@production). You can find your 's at the very top of its README page in .

5. Deploy the modified router

You can now deploy your modified , which can either fetch its from on startup or specify its supergraph schema for deployment in a particular environment. It can then begin executing across your .

Previous
Overview
Next
Uplink
Edit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy

Company