5m
🎯 Your goal is to build a single query for the Module page and confirm that it's returning live data using the Explorer.
To achieve this goal, you'll be implementing new resolvers and updating the data source.
The REST API for our data is located here: https://odyssey-lift-off-rest-api.herokuapp.com/
Data source Tasks
Data Source Solution
In datasources/track-api.js
, add the following method inside the TrackAPI
class:
getModule(moduleId) {return this.get(`module/${moduleId}`);}
Resolver Tasks
Resolver Solution
In resolvers.js
, inside the Query
object:
// get a single module by ID, for the module detail pagemodule: (_, { id }, { dataSources }) => {return dataSources.trackAPI.getModule(id);};
Testing on Studio
Query Solution
This query should be working on Studio:
query getModuleAndParentTrack($moduleId: ID!, $trackId: ID!) {module(id: $moduleId) {idtitlecontentvideoUrl}track(id: $trackId) {idtitlemodules {idtitlelength}}}
Test these values in the Variables
panel:
{"trackId": "c_0","moduleId": "l_0"}
Check your work!
After running the query in Studio, I can see that the title of module with id , and its . The module's parent track id and it has modules.
l_0
is videoUrl
's last 2 characters are c_0
has the title Drag items from this box to the blanks above
Xo
8
10
Kitty space suit, all you need to know
Ox
Exploring Time and Space
Ab
Cat-stronomy, an introduction
4
The Night Sky