5. Queries and the Explorer
2m

Overview

Now for the fun part: actually using our !

In this lesson, we will:

  • Run queries in Apollo Explorer
  • Create and use collections

Building and running queries

We can easily build, run, and manage with the help of the Apollo Explorer. The Explorer IDE is part of the platform and it's easily accessible through the sidebar navigation.

https://studio.apollographql.com

The Explorer on Apollo Studio

Note: You can also get to the same page immediately after creating your by clicking on Query your supergraph in the modal.

Let's run our first .

Getting to know the Explorer

The Operation panel in the middle is where we create queries. The Explorer has already filled in a default ! You can edit the operation directly or add from the Documentation sidebar.

At the top of the Operation panel is the button to run our . Let's click it now and see what happens!

https://studio.apollographql.com

The response shows data after clicking on the Run button

The Response panel on the right displays our list of recipe IDs. Not super helpful right now, so let's spice up this .

We'll ask for a random recipe and include all the details we need to prepare it.

query GetRandomRecipe {
randomRecipe {
id
name
cookingTime
prepTime
servings
instructions
readyTime
ingredients {
text
}
}
}

When we run this , we'll get back data about a random recipe, in Poetic Plates style.

We might want to use this again, so let's save it using collections.

Operation collections

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

Click on the bookmark icon to access your collections.

https://studio.apollographql.com

Accessing the Operation Collections tab in the left panel

Under the Shared section, click the + Create collection button.

We'll give the collection a name and a description.

Name: Recipes
Description: A collection of queries to retrieve content about recipes
https://studio.apollographql.com

Creating a collection, filling in the name and description in the modal

Then click Add. We'll see the new collection show up under the Shared section.

Saving an operation to a collection

Next, let's add to our collection. Click the Save icon.

https://studio.apollographql.com

Click the Save icon in the Operation panel

We'll use the same we already gave it. Then, select the collection it belongs to (the one we just created earlier!).

https://studio.apollographql.com

Filling in the operation details in the operation collection modal

We'll hit Save, and success!

We can see the 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

Which of these are benefits of using the Explorer?
Which of these are benefits of using operation collections?

Key takeaways

  • 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

This is great, we can already send queries to our ! Now let's make sure other people can use it too. In the next lesson, we'll learn a couple ways to enable the best API experience for our users.

Previous

Share your questions and comments about this lesson

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.