6. Local development with rover dev


Excited to start connecting soundtrack data directly to recipes? (Finding music for the meal, so to speak!) First, let's make sure we're set up for local development.

In this lesson, we will:

  • Review the development kit provides
  • Use rover dev to do local development with our

From development to production

Though our and soundtracks are both running locally (with recipes running at a remote location), we're emulating the same exchange that would occur when we host everything in a live, traffic-ready environment.

As with developing any application, we need a workflow that allows us to make changes locally, test them out, and feel confident that we've taken care of any problems before pushing our changes to production. (Or at least, our version of production, in tutorial-land!)

But short of rolling new changes directly into our running, production , how do we actually test that our API will keep functioning?

The GraphOS supergraph development kit

provides a supergraph development kit that helps developers build and play with within a architecture quickly and easily.

And—as you might have guessed—we've already been using parts of the development kit!


The Sandbox Explorer

Sandbox is one such tool, a special mode of that provides us with Explorer (the IDE we've been using to build and run queries against our locally-running ), a schema reference, , and diffs.

Rover template options shown as Java plus GraphQL, .NET plus GraphQL, and Go plus GraphQL

Though we didn't create it ourselves, the recipes was bootstrapped using rover template, providing a starting point for a with JavaScript.

Note: Curious about other templates for different languages bootstrapping a new ? Check out rover template in the Apollo documentation.

The last piece of our development kit is rover dev.

rover dev for local development

So far, we've seen data from both come together by running a local . Let's envision now that our router—and both subgraphs—are running somewhere live within our cloud infrastructure.

The time has come to make some changes. We want to make some tweaks in our local copy of soundtracks, and have real-time validation as we code that our can still compose when those changes are merged.

The rover dev command, showing a router receiving a request and splitting it between two subgraphs

A special command in the takes care of this scenario exactly. Let's see how rover dev fits into our development workflow.

Using rover dev

rover dev lets us start a local —right on your computer!—that can across one or more . Each subgraph can be run locally or remotely. It's a in our local development environment! This lets us implement and test changes before we publish them to .

Now you might be thinking: didn't we already run a locally? In Lesson 4: Running the router, we downloaded a and ran it locally.

The key difference? That was connected to our registry on , whereas the router we're about to run with rover dev will connect to our local changes—even when those changes haven't been published to the registry! This lets us play around with new features and schema updates; we can enjoy the safety of our development environment, while simulating how our changes will work when composed with the and other subgraphs.

To get started, we'll need the soundtracks running. If you haven't already, start the soundtracks locally by running the following command:

npm run dev

The config file

The easiest way to start a rover dev session with multiple is to use a YAML file listing the details for each subgraph.

Create a new file within the router directory called supergraph-config.yaml and paste the contents below:

federation_version: =2.7.0
routing_url: http://localhost:4000
file: ../soundtracks/src/schema.graphql # Schema provided via file
recipes: # Schema downloaded from GraphOS registry
subgraph: recipes

The first line defines the version of federation we're using.

The properties under subgraphs are all the names of in the . Let's look at each one.

soundtracks is running locally, and we're passing the relative path from the root of the router directory to the schema.graphql file in the soundtracks directory. Depending on your project structure, this line might differ: check that the path is correct!


Next up is recipes. This one is pointing to the recipes stored in . If we were making changes to the recipes as well, we'd probably point to a locally-running server and schema, similar to how we've set up soundtracks.

Important to note is the graphref property beneath recipes and schema. Make sure that you provide your APOLLO_GRAPH_REF value that we stored in the router/.env file.


We're ready to start up rover dev!

Running rover dev

Open up a new terminal in the root of the router directory. Let's run rover dev and pass in the config file with the --supergraph-config flag.

Note: By default, rover dev runs the on port 4000. Because this port has already been taken by our soundtracks , we've added the --supergraph-port flag to our rover dev command, and passed 4001 as the port to use instead.

rover dev --supergraph-port 4001 --supergraph-config ./supergraph-config.yaml

After running it, we'll get the following output:

⚠️ Do not run this command in production! ⚠️ It is intended for local development.
👂 polling http://localhost:4000 every 1 second
🛫 starting a session with the 'recipes' subgraph
🛫 starting a session with the 'soundtracks' subgraph
🎶 composing supergraph with Federation v2.7.1
🚀 your supergraph is running! head to http://localhost:4001 to query your supergraph
🎶 composing supergraph with Federation v2.7.1
✅ successfully composed after adding the 'soundtracks' subgraph

Awesome, looks like our is running at http://localhost:4001. Let's check it out!

In the browser, navigate to http://localhost:4001. We'll see Sandbox connected to port 4001, ready for us to the local spawned from rover dev.

In the Documentation panel, we can see familiar-looking from our soundtracks . Test out a for a random recipe, along with featured playlists and their tracks.

query GetRecipeAndPlaylists {
randomRecipe {
featuredPlaylists {
tracks {

Run the query and... data! 🎉

We're now free to make any changes we'd like to in the soundtracks , and see for ourselves how the would handle them. We can even spin up a whole new subgraph and add it to our local .

This is your playground to explore in, to test new concepts, and dream up new features—all without impacting the production !


Which of the following does rover dev not do?

Key takeaways

  • The development kit includes the following: Sandbox, rover template and rover dev.
  • rover dev lets us start a local that can across one or more .
  • To use rover dev, we need each 's name, the URL where it's running, and (optionally) the path to the schema file. The easiest way to do this is with a config file.

Up next

We have everything we need to get started on our changes! Let's turn our focus back to that dream that connects data between a recipe and some recommended playlists to set the mood. For this, we'll need to dive into the architecture and how the handles coordination across .


Share your questions and comments about this lesson

This course is currently in

. Your feedback helps us improve! If you're stuck or confused, let us know and we'll help you out. All comments are public and must follow the Apollo Code of Conduct. Note that comments that have been resolved or addressed may be removed.

You'll need a GitHub account to post below. Don't have one? Post in our Odyssey forum instead.