Apollo GraphOS Quickstart
Orchestrate API calls with a graph
⏱️ Estimated time: 15 minutes
Welcome! 👋 By completing the tutorial, you'll build a fully functional graph that:
Combines multiple REST endpoints from a fictional ecommerce API into a single GraphQL endpoint
Handles the orchestration of API calls automatically
Can be expanded with additional data sources
Let's get started! 🚀
Prerequisites
To get started, you need:
A GraphOS Studio account. Sign up for a Free plan if needed.
The latest version of the Rover CLI. Install or update it like so:
terminalcurl -sSL https://rover.apollo.dev/nix/latest | sh
Authentication for Rover with your Studio account. Set it up like so:
terminalrover config auth
Step 1. Create a graph
This quickstart uses Rover to create a graph with Apollo Connectors—the fastest way to integrate REST APIs. Though this graph uses REST, graphs work with any data source or combination of sources.
In your terminal, create a working directory for your graph:
terminalmkdir my-apollo-graph && cd my-apollo-graph
Initialize your graph:
terminalrover init
Follow the prompts, selecting Create a new graph and one or more REST APIs as your starting point. Store the generated credentials securely, particularly the
APOLLO_KEY
, as it's a graph API key.
Explore example
The best way to explore the example is to run a test request in Apollo Sandbox, a local GraphQL server. To get it started:
In your terminal, follow the Next steps presented by
rover init
:terminalAPOLLO_KEY=<key> \ APOLLO_GRAPH_REF=<graph-ref> \ rover dev --supergraph-config supergraph.yaml
Once
rover dev
is running, the output in your terminal should end with something like this:terminal==> Attempting to start router at http://localhost:4000. ==> 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 yourAPOLLO_KEY
andGRAPH 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 a GraphOS account with a current Free or Enterprise plan. Verify your organization's plan by navigating to GraphOS Studio, clicking on Settings, then selecting the Billing tab. Sign up for a new Free plan if necessary.
The router is the single entry point to the graph. It lets clients fetch exactly what they need with one request, even across multiple APIs.
- If you receive an
To make requests to your router, open
http://localhost:4000
in your browser.Copy and paste the following query in the central Operation panel to get all products:
GraphQLExample queryquery Products { products { id name description } }
Run the request by clicking the ▶️ Products button.
Your response should show a list of space-related products.
That's it—a fully functional graph! Next, you'll connect a new endpoint to grow your graph.
Step 2. Add a new endpoint
To display a product detail page with reviews, clients normally have to make a request first to one endpoint for product details and then another endpoint for product reviews. With a graph, clients can make one request, asking for all the information simultaneously. Behind the hood, the graph orchestrates the calls to each endpoint to produce a single response.
To integrate new endpoints, you update the GraphQL schema:
Open the
products.graphql
file and read the comments to get a brief overview of the file.Copy and paste these additions to your
products.graphql
:GraphQLproducts.graphqltype Product { id: ID! name: String description: String reviews: [Review] @connect( source: "ecomm" http: { GET: "/products/{$this.id}/reviews" } selection: """ $.reviews { id rating comment } """ ) } type Review { id: ID! rating: Float comment: String }
This addition:
Adds a new
Review
typeAdds a
reviews
field to theProduct
type that returns a list ofReview
objects.Adds a Connector to the
reviews
field in theProduct
type to retrieve the reviews
Run a new query in your Sandbox to get product and review information:
GraphQLSandbox requestquery ProductsWithRating { products { name reviews { rating } } }
Wahoo! Your response should now include review ratings. The Sandbox offers additional views in the right panel to help you understand what's happening behind the scenes.
Explore orchestration flow
Click Response and select Query Plan to inspect a visual representation of the steps taken to resolve a request.
A query plan is created by the query planner—the part of the router that breaks down a request into multiple coordinated calls to various endpoints and services. Despite its name, the query planner handles all types of GraphQL operations—not just queries.
Because the request requires two calls to two endpoints, the query planner automatically sequences API calls (the two Fetch
nodes in the diagram) and then combines the results (the Flatten
node).
Try modifying your query to request different data fields to see how the query plan changes. When you're finished, stop the development server in your terminal.
Step 3. Publish updates
Publish your updated graph to GraphOS using the rover subgraph publish
command:
Copy the following multi-line command. Replace
<APOLLO_KEY>
and<GRAPH_REF>
with the credentials generated fromrover init
.terminalAPOLLO_KEY=<APOLLO_KEY> \ rover subgraph publish <GRAPH_REF> \ --schema ./products.graphql \ --name products \ --no-url
Paste and run your updated multi-line command. Once the command completes, you'll see the following in your terminal:
terminalThe supergraph schema for <GRAPH_REF> was updated, composed from the updated 'products' subgraph Monitor your schema delivery progression on studio: <STUDIO_URL>
Go to the
<STUDIO_URL>
provided to land on your graph's Launches page in GraphOS Studio.
Explore Studio
You can use Studio to help analyze the structure of a graph and determine how best to evolve your schemas. For example, from the Schema page, your team can view a Visualization of the types and relationships in your graph.
The visualization tool truly shines as your graph grows, transforming complex webs of types and services into an intuitive, navigable map of your data.
Studio also provides detailed information about your operations usage and performance on the Insights page. You should see the Products
and ProductsWithRating
queries you ran:
As your application scales, these insights help you optimize performance by highlighting slow-resolving fields, tracking error rates, and identifying opportunities to improve your schema based on usage patterns.
Studio empowers teams of developers with observability, management, and governance features, transforming your graph into a collaborative workspace.
Next steps
Depending on your goals, you have several options for learning more:
Learn more about Connectors by checking out the Connectors documentation.
Learn more about GraphOS's features by checking out the GraphOS platform documentation.
Learn to deploy your graph so clients can make requests to it by checking out the Router deployment guides.