10. Publishing to GraphOS
5m

Overview

We're nearing the finish line! To bring our development workflow full circle, we need to account for our schema changes in .

In this lesson, we will:

  • Publish a schema to the schema registry using the
  • Inspect the results of a in Studio

Coordinating schema and code changes

So far, we've only been talking about schema changes and how they should be published to . But we can't forget about our codebase changes, our ! These include the changes we made to the functions to make our schema work and the schema file itself. We need to deploy our local changes to production.

Because we're just working with local in tutorial-land, we don't need to deploy any of our changes. You can learn more about coordinating schema and code changes in a production environment in this Apollo tech note.

Publishing schema changes

We do need to publish our new to .

To do this, we'll use the 's rover subgraph publish command again. We don't need to include the routing URL this time, since it hasn't changed.

rover subgraph publish <GRAPH_REF> \
--schema ./src/schema.graphql \
--name <SUBGRAPH_NAME>

Note: Remember, you can find your erence in Studio, at the top of the graph's README page, or in your .env file.

Let's do it! In a terminal window, paste in the rover subgraph publish command. Make sure you replace the parameters with your own values.

rover subgraph publish Music-Matcher@current \
--schema ./src/schema.graphql \
--name soundtracks

You'll need to confirm that we're publishing a localhost URL. If all goes well, we should see the terminal output with a message confirming that the has been published and the has been updated!

Inspecting a launch in Studio

What happens after a schema is published to the registry? A starts! Let's take a peek at that process in Studio.

Navigate to the Launches page. Click on the latest in the list.

https://studio.apollographql.com

The Studio Launches page showing the results of the latest launch

We can see that the Launch Sequence section for this specific follows the steps we had talked about earlier:

  • Build Completed refers to the process of building a (also known as ).
  • Schema Published refers to the made available to Apollo Uplink.
  • Launch Completed is self-explanatory! Our launch successfully completed! 🎉

On the right-hand side, we can also take a look at the output and a summary of our schema changes.

https://studio.apollographql.com

The Studio Launches page showing the supergraph schema button and a summary of changes

If everything looks good to go, we should be able to for the new recommendedPlaylists for a recipe.

First, make sure that you've stopped your rover dev process, and booted up your . Remember that the router binary we downloaded connects to the —so we're ready to test out our published changes "in production"! (Well, as close to production as we'll get in this tutorial!)

In a new terminal window, navigate to the router folder, then run:

Router
APOLLO_KEY=<APOLLO_KEY> APOLLO_GRAPH_REF=<APOLLO_GRAPH_REF> ./router --config config.yaml

Note: Remember, you can find the values to APOLLO_KEY and APOLLO_GRAPH_REF in your .env file.

Next, let's go to Explorer (in Studio this time, not Sandbox!) and run that dream .

query GetRecipeWithPlaylists {
recipe(id: "rec3j49yFpY2uRNM1") {
name
description
ingredients {
text
}
instructions
recommendedPlaylists {
id
name
description
tracks {
explicit
id
name
uri
durationMs
}
}
}
}

You should be seeing data come back! Our launch was successful! 🎉

Key takeaways

  • A launch represents the complete process of making schema updates to a . A is triggered when a schema is published to .
  • To publish a , use the rover subgraph publish command.
  • We can inspect the results of a through the Studio Launches page.

Up next

And you've done it! Though we began with a simple , we used the principles of federation and to bring a brand new API into the mix. Using entities, we connected meals to music, and rolled out a whole new music search feature for anyone in the mood to cook up something new. We ensured that these new and exciting changes were safe using rover dev, , and .

Thanks for continuing with us on this journey into , , and TypeScript. Check out the other courses has to offer—and keep on building your graph!

Previous

Share your questions and comments about this lesson

This course is currently in

beta
. 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.