2. Creating a supergraph


In this section, we'll cover:

  • Cloning the Workshop repository
  • Creating a in GraphOS
  • Publishing your schemas using Managed Federation


  • You will need a tool to clone the Github repository, either Github CLI (gh) or plain git
  • an email address to create your account
  • Apollo Rover installed in your local machine

Getting started

✏️ Clone the repository

In the directory of your choice with your preferred terminal, clone the workshop repository, which can be found at https://github.com/apollosolutions/fed-workshop-subgraphs-js.

git clone https://github.com/apollosolutions/fed-workshop-subgraphs-js

✏️ Set up your GraphOS account

1. Join the KBT Threads organization

To get started with our journey, we need to login to the KBT Threads account. You should have an email inviting you to join the account:

Invitation Email screenshot


Click the link to join the organization. If you already have a account, you can add this new organization to your existing account. If you don't have an account, you can create one with your email.


Apollo Studio Getting started screenshot


2. Create your Supergraph

Once the account is created, click on the Create New Graph button to create a new inside this organization.

Name your new something distinct, such as <yourname>-supergraph, and then create the with the default type.


Apollo Studio - Create new supergraph screenshot


✏️ Publishing schemas

With your created, but not yet setup, you should see something similar to the screenshot below:


Apollo Studio - Publish your schema

Important: Copy the APOLLO_KEY value and the GRAPH_REF value and save them for later. The GRAPH_REF in the screenshot above is graphosworkshop-supergraph@current.

Now that we have the API key and graph ref, it is time to add subgraphs to our . KBT Threads has two already built and ready to go, the Customer and the Product .

Let's add those to the in . We will do that on our local machine from the command line using Rover. is Apollo's command-line interface for managing and maintaining with the management plane.


You will need to authenticate with your account. To do that, you will need an API key. You can use the APOLLO_KEY mentioned above or you can head to your personal settings in and create an API key. Copy either and then execute the following command in a terminal:

rover config auth

will then prompt you to paste the key you just copied, and make sure your pasted key is valid.


Publishing the subgraph schemas

Let's quickly recap the components in our diagram:

High level components diagram

As you can see in the components above, we have the following :

  • Orders retrieves data from a REST API,
  • Products retrieves data from a NoSQL database,
  • Customers retrieves data from a SQL database

Each of these provide their own GraphQL schema. Therefore, we need to publish them so they can be composed in our through Federation.

Your project structure should look similar to this (only folders are listed):

📦 fed-workshop-subgraphs-js/
┣ 📂 deploy/
┣ 📂 final/
┣ 📂 nosql-products/
┣ 📂 rest-orders/
┣ 📂 sql-products/
┣ 📂 website/
┣ 📂 rest-orders/
┣ 📂 router/
┗ 📂 website/

✏️ Publishing the Products schema

In your terminal,

  1. from your project root folder, navigate to ./final/nosql-products/
  2. execute the following command:
rover subgraph publish <GRAPH_REF> \
--schema ./schema.graphql \
--name products \
--routing-url https://subgraph-products-j3nprurqka-ue.a.run.app

Remember to replace the <_REF> value with your own, which should have been copied in a previous step (should be in the form of <your-graph-name>@current).


✏️ Publishing the Customers schema

Back in your terminal,

  1. from your project root folder, navigate to ./final/sql-customers/
  2. execute the following command:
rover subgraph publish <GRAPH_REF> \
--schema ./schema.graphql \
--name customers \
--routing-url https://subgraph-customers-j3nprurqka-ue.a.run.app

Remember to replace the <_REF> value with your own, which should have been copied in a previous step (should be in the form of <your-graph-name>@current).


With the successfully published, you should the following updated page:


Studio showing successful publish of a schema

We can see that the schema has been successfully published. Let's review the schema changes: click the See schema changes button. This takes us to the launches tab inside .


Studio showing the Launches view

On the tab, we get our first view of what is happening to support our inside . When we publish a to our GraphOS account via rover, the schema registry takes that and generates a new automatically.

After that,

  • runs checks on the schema to verify that it will work for current consumers,
  • the is published to the schema registry, and
  • this new is now available to our KBT supergraph

Now, to dive into our schema in more detail, we can go to the schema tab on the left navigation bar.


Apollo Studio Schema Viewer

From here, we can view the schema in Schema Design Language () or in a more human readable reference format. Browse both versions, where you can see both the that have been used to generate this along with the generated supergraph schema itself.

Up next

In the next section, Building the subgraphs we will build a that accesses a REST API.