7. Exercise: Convert your data map to SDL


Goal: Convert the data map you created earlier into SDL. (Don't worry about mutations for now.)

  • Create types Track, Author, and Module.
  • Add fields to the Query type to get the data needed on each page.

See solution below if you need help.

type Query {
"Query to get tracks array for the homepage grid"
tracksForHome: [Track!]!
"Fetch a specific track, provided a track's ID"
track(id: ID!): Track!
"Fetch a specific module, provided a module's ID"
module(id: ID!): Module!
"A track is a group of Modules that teaches about a specific topic"
type Track {
id: ID!
"The track's title"
title: String!
"The track's main Author"
author: Author!
"The track's illustration to display in track card or track page detail"
thumbnail: String
"The track's approximate length to complete, in seconds"
length: Int
"The number of modules this track contains"
modulesCount: Int
"The track's complete description, can be in markdown format"
description: String
"The number of times a track has been viewed"
numberOfViews: Int
"The track's complete array of Modules"
modules: [Module!]!
"The number of likes a track has received"
numberOfLikes: Int
"Author of a complete Track or a Module"
type Author {
id: ID!
"Author's first and last name"
name: String!
"Author's profile picture"
photo: String
"A Module is a single unit of teaching. Multiple Modules compose a Track"
type Module {
id: ID!
"The module's title"
title: String!
"The module's length in seconds"
length: Int
"The module's text-based description, can be in markdown format. In case of a video, it will be the enriched transcript"
content: String
"The module's video url, for video-based modules"
videoUrl: String

Check your work

Run the following query that the client needs for the homepage. You should get back some mock data as a response.

query GetTracksForHomepage {
tracksForHome {
author {