14. Exercise: Query the supergraph1m

Exercise: Query the supergraph

🎯 Goal: Build a query that enables the client to display the data needed for the mockup below.

Mockup of the homepage

Bonus

  • Find the Explorer settings that shows you which subgraph is responsible for resolving each field.
  • How can you view the query plan for your query?
Task!

Solution

  1. Head over to Explorer.

  2. We can now see the new fields available in the Documentation tab.

  3. Build the query:

    query HomepageWithLocationsAndActivities {
    ... @defer {
    featuredLocation {
    id
    name
    photo
    }
    }
    locations {
    id
    name
    photo
    description
    }
    activities {
    id
    name
    photo
    terrain
    stats {
    groupSize
    averageTemperature
    gravity
    }
    }
    }

Bonus:

  1. Click the settings icon in the left panel and turn on Editor hints.

  2. Turn on Subgraph source. Now you can see which subgraphs are responsible for which fields in your query!

  3. Click the arrow beside Response and change to Query Plan Preview.

Previous
Next

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. Note that all comments are public and must follow the Apollo Code of Conduct. You'll need a GitHub account to post below. Don't have one? Post in our Odyssey forum.