Set up your graph

Transform your REST APIs into a graph with GraphOS


Hello! 👋 These guides teach you to build a graph that incorporates a fictional Ecommerce REST API. A graph lets clients fetch exactly what they need in one request, even across multiple endpoints.

Let's start building!

tip
If you learn best with videos and exercises, this interactive course teaches you how to integrate REST APIs into a graph. Prefer to start with a high-level conceptual understanding? Check out the Apollo Connectors Overview.

Sign into GraphOS

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 from scratch or with an existing GraphQL API.

    Under Select your starting point, you'll follow the I'm starting from scratch path.

  1. In your terminal, create an empty directory where you want to set up your graph. In that directory, run rover init. If the init command is unrecognized, ensure you've installed Rover v0.29 or later. You can check your version by running rover --version.

  2. Make these selections for the prompts in the wizard:

    PromptSelection
    Select optionCreate a new graph
    Select organizationSelect the GraphOS organization you want to create your graph in
    Select use caseStart a graph with one or more REST APIs
    Name your graphEnter a name for your graph, for example, Ecomm example
    Confirm or modify your graph IDA graph ID is generated based on your graph name. It may contain additional characters to make it unique. Confirm or modify it.
  3. When you confirm you want to proceed, a set of starter files will be created in your current working directory. Rover init also generates APOLLO_GRAPH_REF and APOLLO_KEY credentials. Store these securely, particularly the APOLLO_KEY, as it's a graph API key. You'll need to use these credentials later in this guide. You can also set your key as an environment variable.

  4. In the directory with the generated files, run the following command, replacing the <key> and <graph-ref> with your own values:

    terminal
    APOLLO_KEY=<key> \
    rover dev --graph-ref <graph-ref> \
    --supergraph-config supergraph.yaml

    (If you set APOLLO_KEY as an environment variable, you don't need to include it in your command.)

    Once rover dev is running, your terminal should look something like this:

    terminal
    merging supergraph schema files
    supergraph config loaded successfully
    starting a session with the 'products' subgraph
    ==> Watching path/to/products.graphql for changes
    composing supergraph with Federation 2.10.0
    ==> Attempting to start router at http://localhost:4000.
    WARN: setting resource attributes is not allowed for Apollo telemetry
    ==> Health check exposed at http://127.0.0.1:8088/health
    WARN: Connector debugging is enabled, this may expose sensitive information.
    ==> Your supergraph is running! head to http://localhost:4000 to query your supergraph
    Running into errors?
    • If you receive an Error: Not connected to GraphOS., ensure you've included your APOLLO_KEY and GRAPH REF. See Graph API keys for instructions on how to obtain a new one.
    • If you receive an Error: License not found., it means you need an Apollo account with a Free or Enterprise plan. Verify your organization's plan by navigating to GraphOS Studio, clicking on Settings, then selecting the Billing tab.

🎉 Congratulations—you've successfully started a local development session where you can explore and develop your graph! Here's where the fun begins. Jump over to the next guide to start developing your graph.

Feedback

Forums