Snowtooth Mountain lift ops team has created a Lift
service that provides lift status reporting for skiers and the ability to change the lift status for ski patrollers. The mountain ops team has created their own service to report on Trail
status. These are completely separate GraphQL API's, and it is our job to turn them into federated apis that work under one gateway.
We have two services that run independently of one another on two different endpoints. We need to take these services and make them apollo federated services so that they can run behind a federated gateway.
Now that we have federated services, we need to access them both from a single endpoint. Create a gateway services that allows me to query allLifts
and allTrails
from the same endpoint. The following query should work when sent to the gateway:
query {
allLifts {
id
name
}
allTrails {
id
name
}
}
From the lifts
service, we need to extend the Trail
entity. Add a field to Trail
called liftAccess
and resolve the lift
types that access that trail. Hint: the data for each lift contains a trails
array. Once complete the following query should work form the gateway:
query {
allTrails {
id
name
liftAccess {
id
name
status
}
}
}
From the lifts
service, we need to extend the Lift
type to resolve Trail
entities. The following query should work from the gateway:
query {
allLifts {
id
name
trailAccess {
name
difficulty
status
}
}
}
The mountain ops team wants to provide an easyWayDown
field for every lift so skiers will know the easiest route to the bottom no matter what lift they are on. The trail services has an algorithm for this, so we need to add an easyWayDown
field to Lift
entity from the trail service.
query {
allLifts {
id
name
easyWayDown {
name
difficulty
status
}
}
}