Practice with these Queries!
query {
allLifts {
name
status
capacity
night
elevationGain
}
}
query liftsAndTrails {
lifts: allLifts {
name
status
capacity
night
elevationGain
}
trails: allTrails {
trailName:name
trailDifficulty:difficulty
}
}
query liftsAndTrails {
lifts: allLifts {
name
status
capacity
night
elevationGain
trailAccess {
name
status
}
}
trails: allTrails {
trailName:name
trailDifficulty:difficulty
accessedByLifts {
name
night
}
}
}
query {
Trail(id:"grandma") {
name
status
trees
night
}
Lift(id:"panorama") {
name
capacity
}
liftCount(status:"HOLD")
trailCount(status:"OPEN")
}
query openLiftsTrails($status: String!) {
liftCount(status: $status)
trailCount(status: $status)
}
{
"status": "OPEN"
}
query {
allLifts {
...LiftDetails
elevationGain
trailAccess {
...TrailDetails
}
}
allTrails {
...TrailDetails
night
accessedByLifts {
...LiftDetails
}
}
}
fragment LiftDetails on Lift {
name
status
capacity
}
fragment TrailDetails on Trail {
name
difficulty
groomed
}
- Run the Mutation
mutation PanoramaUpdate {
setLiftStatus(id: "panorama" status: "CLOSED") {
name
status
}
}
- Test the Query
query {
Lift(id: "panorama") {
name
status
}
}
- Replace with an input type
mutation PanoramaUpdate($id:ID! $status: String!) {
setLiftStatus(id: $id status: $status) {
name
status
}
}
- input JSON
{
"id": "panorama",
"status": "HOLD"
}
Using SWAPI: http://graphql.org/swapi-graphql/
- List all of the films with id, title, and director
query {
allFilms {
films {
id
title
director
}
}
}
- Extra Credit: Send a query to find a person with an personID of 5. Find their name, year they were born, and height.
{
person(personID:5) {
name
birthYear
height
}
}
- Extra, extra credit: Once you know which person has an ID of 5 from the query, name the query with the person's name:
{
princessLeia:person(personID:5) {
name
birthYear
height
}
}