Set up your graph
Build a federated GraphQL API with GraphOS
Hello! 👋 These guides teach you to build a supergraph using fictional Ecommerce GraphQL APIs. A supergraph lets clients fetch exactly what they need in one request, even across multiple endpoints.
Let's start building!
Sign into GraphOS Studio
Sign into GraphOS Studio. If you don't have an account yet, sign up for a Free plan at studio.apollographql.com.
Create a graph
When first accessing Studio, you'll see this screen. Follow its instructions to install Rover and authenticate it with GraphOS.
Under Select your starting point, click Connect an 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 modal 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 modal 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.