Overview
Now for the fun part: actually using our supergraph!
In this lesson, we will:
- Run queries in Apollo Explorer
- Create and use operation collections
Building and running queries
We can easily build, run, and manage GraphQL queries and mutations with the help of the Apollo Explorer. It's part of the GraphOS platform!
The Explorer IDE is easily accessible through the sidebar navigation.
Note: You can also get to the same page immediately after creating your supergraph by clicking on Query your supergraph in the modal.
If you've used Apollo Server to build your GraphQL API before, the Explorer will look very familiar. It's always available for local development and querying!
Let's run our first query.
Getting to know the Explorer
The Operation panel in the middle is where we create queries. The Explorer has already filled in a default operation! You can edit the operation directly or add fields from the Documentation sidebar.
At the top of the Operation panel is the button to run our query. Let's click it now and see what happens!
The Response panel on the right displays our list of recipe IDs. Sweet, our supergraph is up and running!
Operation collections
Operation collections help you store and organize commonly used operations so you can access them more quickly and share them with team members.
There are two types of collections: personal and shared.
Personal collections are visible only to you. Shared collections are visible to all organization members who can view the supergraph the collection belongs to.
Creating a shared operation collection
Let's get our shared collection started, this is going to be helpful for future teammates (and future us!) to get the most out of the supergraph.
Click on the bookmark icon to access the Operation Collections in the left panel.
Under the Shared section, click the + Create collection button.
We'll give the collection a name and a description.
Name: RecipesDescription: A collection of queries to retrieve content about recipes
Then click Add. We'll see the new collection show up under the Shared section.
Saving an operation to a collection
Let's add an operation to the collection!
We'll build a query to retrieve a random recipe from the API. You can try building this yourself, or copy the snippet below and paste it into the Operations section.
query GetRandomRecipe {randomRecipe {idnamecookingTimeprepTimeservingsinstructionsreadyTimeingredients {text}}}
When you run it, you should get data about a random recipe!
Click the Save icon.
We'll use the same operation name we already gave it. Then, select the collection it belongs to (the one we just created earlier!).
We'll hit Save, and success!
We can see the operation name under this shared collection, and we can see a bookmark icon in the tab that also tells us that this operation is saved. It's ready to use whenever we need it!
Practice
Key takeaways
- Operation collections help you store and organize commonly used operations so you can access them more quickly and share them with team members.
- You can save collections that are visible only for yourself (personal) or visible to the whole organization (shared).
Up next
We can send queries to our supergraph! 🥳 This is great, but we want other people to use it too. This is a public API, after all! In the next lesson, we'll learn a couple ways to enable the best API experience for our users.
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.