Docs
Launch GraphOS Studio

Developing your supergraph locally

With the Rover CLI


While you're working on changes to one of your , you can run a version of your entire locally in your development environment! To do this, you use the rover dev command.

💡 TIP

Install the Rover CLI.

The rover dev command monitors each of your (either via server or by watching a .graphql file). Whenever it detects a change, it automatically recomposes your 's and raises any errors that might occur. This enables you iterate quickly on schema changes.

Starting your router

You run rover dev once for each in your . The first time you run it, spins up a on your local machine.

Try running rover dev with an example like so:

rover dev --url https://flyby-locations-sub.herokuapp.com/ --name locations

You'll see output like the following:

WARN: could not detect a schema in the current working directory. to watch a schema, pass the `--schema <PATH>` argument
👂 polling https://flyby-locations-sub.herokuapp.com/ every 1 second
⚠️ Do not run this command in production! ⚠️ It is intended for local development.
🛫 starting a session with the 'locations' subgraph
🎶 composing supergraph with Federation v2.1.2
🚀 your supergraph is running! head to http://localhost:3000 to query your supergraph

You can now open http://localhost:3000 in your browser and run test queries against your local using the Explorer!

You can replace the example URL and name in the above command with the details for your own subgraph. You can provide a remote URL or a localhost URL.

Adding a subgraph

To add a to your local , run rover dev again in a separate terminal window.

You can add a to this article's example with the following command:

rover dev --url https://flyby-reviews-sub.herokuapp.com/ --name reviews

This command's output is similar to the output for the initial execution, but it includes a line like the following:

🐤 adding the 'reviews' subgraph to the session

This indicates that rover dev has identified your existing session and is adding this to it.

Now if you run test queries in the Explorer, you'll see that they can include from both the locations and reviews !

Ending a rover dev session

To shut down your local , use CTRL+C to stop the first rover dev process you started. This automatically terminates all secondary rover dev processes that are part of the same session.

NOTE

If you stop a secondary rover dev process, your session remains active, and the 's schema is automatically updated to reflect the removed .

Command options

For more details on rover dev options, see the Rover documentation.

Previous
Creating a new subgraph
Next
Updating your graph
Edit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy

Company