Overview
We're almost there! Let's run through what pushing our changes to tutorial-land production looks like.
In this lesson, we will:
- Publish a schema to the schema registry using the Rover CLI
- Inspect the results of a launch in Studio
Coordinating schema and code changes
So far, we've only been talking about schema changes and how they should be published to GraphOS. But we can't forget about our codebase changes, our GraphQL subgraph server! These include the changes we made to the resolver 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 subgraphs in tutorial-land, we don't need to actually 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 subgraph schema to GraphOS.
Note: It's good practice to run a schema check and confirm it's passing before publishing the schema. This is usually handled in the CI/CD pipeline.
To do this, we'll use the Rover CLI'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 GRAPHREF@GRAPHVARIANT \--schema 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 subgraph has been published and the supergraph has been updated!
Inspecting a launch in Studio
What happens after a schema is published to the registry? A launch starts! Let's take a peek at that process in Studio.
Navigate to the Launches page. Click on the latest launch in the list.
We can see that the Launch Sequence section for this specific launch follows the steps we had talked about earlier:
Build Completed refers to the process of building a supergraph schema (also known as composition).
Schema Published refers to the supergraph schema 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 supergraph schema output and a summary of our schema changes.
If everything looks good to go, we should be able to query for the new recommendedPlaylists
field for a recipe.
🚀 Feature in production!
First, make sure your local router is running. In a new terminal window, navigate to the Router
folder, then run:
APOLLO_KEY=<APOLLO_KEY> APOLLO_GRAPH_REF=<APOLLO_GRAPH_REF> ./router --config supergraph-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.
query GetRecipeWithPlaylists {randomRecipe {namedescriptioningredients {text}instructionsrecommendedPlaylists {idnamedescriptiontracks {idnamedurationMsexplicit}}}}
You should be seeing data come back, with everything we needed. Our launch was successful! 🎉
Key takeaways
- A launch represents the complete process of making schema updates to a graph. A launch is triggered when a schema is published to GraphOS.
- To publish a subgraph schema, use the
rover subgraph publish
command. - We can inspect the results of a launch through the Studio Launches page.
Conclusion
And you've done it! Though we began with a simple GraphQL server, we used the principles of federation and GraphOS to bring a brand new API into the mix. Using entities, we connected meals to music for anyone in the mood to cook up something new. We ensured that these new and exciting changes were shipped safely using rover dev
, schema checks, and launches.
Thanks for continuing with us on this journey into Apollo Federation, GraphOS, and Hot Chocolate. Check out the other courses Odyssey has to offer—and keep on building your graph!
Share your questions and comments about this lesson
This course is currently in
You'll need a GitHub account to post below. Don't have one? Post in our Odyssey forum instead.