Set up your graph
Build a federated GraphQL API with GraphOS
Hello! 👋 This set of guides gets you up and running with a graph that integrates data from products, users, and inventory services. A graph is network of interconnected data that enables clients to traverse relationships and fetch exactly what they need in a single request.
When a graph is made of several underlying services—sometimes called subgraphs—the entire graph is sometimes called a supergraph. Clients make requests to the federated graph's single entry point called the router.
In this and the following guides, you will:
Set up a supergraph
Learn how to use Apollo's tools like GraphOS Studio, Rover CLI and Apollo Sandbox
Let's start building!
🧰 Meet your tools
Throughout this guide you'll be using the following Apollo tools:
GraphOS Studio is the primary web interface for GraphOS. Studio helps you monitor, manage, and collaborate on your GraphQL APIs.
The Rover CLI is the primary command-line interface for GraphOS.
None of these tools requires a paid plan.
Create a GraphOS account
You need an account to work with GraphOS. Sign up for a Free plan at studio.apollographql.com.
Create a graph
If your organization hasn't created any graphs in Studio yet, Studio presents the following screen that encourages you to get started with the Rover CLI. Follow the instructions on the screen to install Rover and authenticate it with your GraphOS account. Then, under Select your starting point, click Connect existing GraphQL API.
This guide shows how to use a retail demo graph as the existing GraphQL API.
If you already have existing graphs, you won't see this screen, but it's still helpful to start by installing Rover with the appropriate command for your system:
terminalMacOS / Unix-likecurl -sSL https://rover.apollo.dev/nix/latest | sh
terminalWindowsiwr 'https://rover.apollo.dev/win/latest' | iex
Then, click Add new graph on the upper right of the Studio homepage and select Connect existing GraphQL API.
In the modal that appears, enter a Graph title, for example
Ecomm Example
. Leave the Graph Architecture asSupergraph (Default)
. Click Next.A dialog titled Publish your schema using Federation appears. Copy the entire example code block to a local text file using the copy button.
It should look something like this:
terminalAPOLLO_KEY=service:Ecomm-Example:••••••••••••••••••••• \ rover subgraph publish Ecomm-Example@current \ --schema ./products-schema.graphql \ --name your-subgraph-name \ --routing-url http://products.prod.svc.cluster.local:4001/graphql
The protected value that appears after
APOLLO_KEY=
and begins withservice:
is your graph API key.The value that appears after
rover subgraph publish
is your graph ref. By default, it ends with@current
.The
--schema
option specifies the path to the schema file to publish.The
--name
option specifies the name of the subgraph.The
--routing-url
is the address the router should send subrequests for this particular subgraph to.
cautionAPI keys are secret credentials. Never share them outside your organization or commit them to version control. Delete and replace API keys that you believe are compromised.Leave the dialog open. This guide now shifts to the demo graph and local development. You'll complete setup with Rover and return to Studio for the final steps in this guide.
Set up retail demo graph
Apollo's retail demo graph is a demonstration supergraph for a retail business containing services for checkout, discovery, inventory, orders, products, reviews, shipping, and users. It includes prebuilt schema and server code. Download or clone it from its GitHub repository.
To ensure you can run it locally in the next step, install the latest LTS version of Node.js.
Next steps
Here's where the fun begins. Jump over to the next guide to start developing your graph.