Federation Nation
GraphQL at Scale

Eve Porcello
@eveporcello
eve@moonhighway.com
Agenda
📍 Intro to Federation
📍 Working in Isolation
📍 Federated Products
📍 Lab: Snowtooth Graph
Schedule
9:00 - Start
10:00 - 10:10 - Break
11:00 - 11:10 - Break
12:00 - End





Scaling Instances


The Scale Cube

The Scale Cube

instances
The Scale Cube

microservices
The Scale Cube

partitioning
The Scale Cube

microservices
instances
partitioning
The Scale Cube
Cloning





instances
The Scale Cube

instances
The Scale Cube

Multiple on One Machine



Scaling Data





sharding
(horizontal partitioning)
The Scale Cube
Scaling Microservices






microservices
The Scale Cube








{ }





Query
Response





{ }



Query
Response



Gateway







{ }



Query
Response



supergraph













Reviews
Colors
Accounts
GraphOS
- A platform for building, managing, and scaling a supergraph
- Docs
Rover
- A CLI tool that allows you to manage schemas
- Replaces the Apollo CLI
- Docs
Apollo Studio
- A platform for managing your graph
- Docs





{ }



Query
Response



Router













Reviews
Colors
Accounts


Lifts

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.
Trails

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.

Lifts & Trails Lab
REQUIREMENTS
- Create Lifts Subgraph
- Create Trails Subgraph
- Stand up the router using rover dev
- Send a query to both lifts and trails
In this activity, we'll create federated lifts and trails.




Lifts go up.
Trails go down.

LIFT
TRAIL

A Lift can take you to multiple trails.
{
"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

Trails can be accessed by multiple Lifts.
{
"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

Each Lift has a
Trail that is the
"Easy Way Down".
const waysDown = trails.filter(
trail => trail.lift.includes(lift.id)
);
return findEasiestTrail(waysDown);Hint: Use findEasiestTrail.js and use in the resolver...
Connecting Lifts & Trails Lab
REQUIREMENTS
- Extend the Trail Entity to include liftAccess field
- Resolve trailAccess field on Lift
- Add easyWayDown to Lift
In this activity, we'll connect the two data types.


Hue Review
Account
Service
Review
Service
Color
Service
What We Did
Hue Review
Lift
Service
Trail
Service
What We Want to Do
Review
Service
Account
Service
Color
Service
Hue
Review
Snowtooth

What's Next

Thank You!
- Alex Banks, @moontahoe
- Eve Porcello, @eveporcello
- Website: www.moonhighway.com
- Mailing List: bit.ly/moonhighway

Apollo Federation
By Moon Highway
Apollo Federation
- 1,073