5. Exercise: Build queries in Sandbox
1m

Goal: Build the queries we need for the tracks homepage and track details page, using Apollo Sandbox.

  1. Under Connection Settings, set the endpoint to the GraphQL API URL:

    https://workshop-catstronauts-api.herokuapp.com/

    Already built your own Catstronauts API from the Backend Workshop? Feel free to connect to that one instead!

  2. Review the tracks homepage mock-up and build the query needed to satisfy it.

    query GetTracksForHomepage {
    tracksForHome {
    id
    title
    thumbnail
    length
    modulesCount
    author {
    id
    name
    photo
    }
    }
    }
  3. Review the track details page mock-up and build the query needed to satisfy it.

    query GetTrackDetails($trackId: ID!) {
    track(id: $trackId) {
    id
    title
    author {
    id
    name
    photo
    }
    thumbnail
    length
    modulesCount
    numberOfViews
    modules {
    id
    title
    length
    }
    description
    }
    }

Bonus: Build a query for the module details page

query GetModuleAndParentTrack($moduleId: ID!, $trackId: ID!) {
module(id: $moduleId) {
id
title
content
videoUrl
}
track(id: $trackId) {
id
title
modules {
id
title
length
}
}
}

Bonus: Save the query to an operation collection

For instructions on how to save an operation to a collection, refer to the Apollo documentation.

Previous
Next