GraphQL at Scale
Eve Porcello
@eveporcello
eve@moonhighway.com
📍 Intro to Federation
📍 Working in Isolation
📍 Federated Products
📍 Lab: Snowtooth Graph
9:00 - Start
10:00 - 10:10 - Break
11:00 - 11:10 - Break
12:00 - End
instances
microservices
partitioning
microservices
instances
partitioning
instances
instances
sharding
(horizontal partitioning)
microservices
Query
Response
Query
Response
Gateway
Query
Response
supergraph
Reviews
Colors
Accounts
Query
Response
Router
Reviews
Colors
Accounts
type Lift {
id: ID!
name: String!
status: LiftStatus!
capacity: Int!
night: Boolean!
elevationGain: Int!
}
enum LiftStatus {
OPEN
HOLD
CLOSED
}This Lift isn't open now but might open later.
type Trail {
id: ID!
name: String!
status: TrailStatus!
difficulty: Difficulty!
groomed: Boolean!
trees: Boolean!
night: Boolean!
}
enum TrailStatus {
OPEN
CLOSED
}Only two options.
A Trail can't be on Hold.
REQUIREMENTS
In this activity, we'll create federated lifts and trails.
LIFT
TRAIL
{
"name": "Astra Express",
"capacity": 3,
"status": "OPEN",
"night": false,
"elevationGain": 899,
"time": "8 minutes",
"trails": [
"blue-bird",
"blackhawk",
"ducks-revenge",
"ice-streak",
"parachute",
"goosebumps"
],
"id": "astra-express"
}lift.trails.map((id) => ({ __typename: "Trail", id }))LIFT
Trail IDs
{
"name": "Goosebumps",
"lift": ["astra-express", "jazz-cat"],
"difficulty": "ADVANCED",
"status": "OPEN",
"groomed": false,
"snowmaking": false,
"trees": true,
"night": false,
"id": "goosebumps"
}TRAIL
Might have more than one Lift ID
const waysDown = trails.filter(
trail => trail.lift.includes(lift.id)
);
return findEasiestTrail(waysDown);REQUIREMENTS
In this activity, we'll connect the two data types.
Hue Review
Account
Service
Review
Service
Color
Service
Hue Review
Lift
Service
Trail
Service
Review
Service
Account
Service
Color
Service
Hue
Review
Snowtooth