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

  1. When first accessing Studio, you'll see this screen. Follow its instructions to install Rover and authenticate it with GraphOS.

    GraphOS Studio when an organization hasn't created any graphs. The screen prompts users to install the Rover CLI, connect it to GraphOS, and select a starting point: either a REST or GraphQL API.
  2. Under Select your starting point, click Connect an existing GraphQL API.

  1. In the modal that appears, enter a Graph title, for example Ecomm Example. Leave the Graph Architecture as Supergraph (Default). Click Next.

  2. A modal titled Publish your schema using Federation appears. Copy the entire example code block to a local text file using the copy button.

    A modal from GraphOS Studio displays a hidden API key and graph ref.

    It should look something like this:

    terminal
    APOLLO_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 with service: 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.

    caution
    API 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.
  3. 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.

  1. Download or clone it from its GitHub repository.

  2. To ensure you can run it locally in the next step, install the latest LTS version of Node.js.

note
While the retail demo uses Node.js for all its services, Apollo Federation is compatible with many GraphQL server libraries. You can also federate services that use different programming languages and different server libraries.

Next steps

Here's where the fun begins. Jump over to the next guide to start developing your graph.

Feedback

Forums