Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
GraphQL Schema Design @ Scale
Search
Marc-Andre Giroux
November 07, 2018
Programming
5
2.1k
GraphQL Schema Design @ Scale
GraphQL Schema Design and Tooling @ GitHub
Marc-Andre Giroux
November 07, 2018
Tweet
Share
More Decks by Marc-Andre Giroux
See All by Marc-Andre Giroux
It Depends - Examining GraphQL Myths & Assumptions
xuorig
0
81
So you Want to Distribute your GraphQL Schema?
xuorig
4
790
So you Want to Distribute your GraphQL Schema?
xuorig
0
470
Continuous Evolution of GraphQL Schemas @ GitHub
xuorig
3
2k
GraphQL à Shopify
xuorig
0
210
Exploring GraphQL
xuorig
0
250
GraphQL @ Shopify
xuorig
6
1.5k
GraphQL on Rails
xuorig
2
330
From REST to GraphQL
xuorig
9
1.2k
Other Decks in Programming
See All in Programming
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
890
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.2k
Ethereum_.pdf
nekomatu
0
460
C++でシェーダを書く
fadis
6
4.1k
Jakarta EE meets AI
ivargrimstad
0
110
ヤプリ新卒SREの オンボーディング
masaki12
0
130
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
as(型アサーション)を書く前にできること
marokanatani
10
2.7k
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
930
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
Quine, Polyglot, 良いコード
qnighy
4
650
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
140
Featured
See All Featured
Building Applications with DynamoDB
mza
90
6.1k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Gamification - CAS2011
davidbonilla
80
5k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Docker and Python
trallard
40
3.1k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Transcript
Marc-Andre Giroux @___xuorig___ GraphQL Summit - Nov 7th 2018 GraphQL
Schema Design @ scale
about { xuorig } • Montreal, Canada ☃ • My
3rd GraphQL Summit • I work at GitHub! 2
3
GraphQL @ GitHub • 200+ engineers working on GraphQL schema
• Teams have to move quickly • Public and Internal Schema + Enterprise. 4
GraphQL @ GitHub: Challenges • Keeping a high quality public
API across many teams and use cases. • Small API team • Best practices are still emerging, lots and lots of PR reviews to go through, and many new use cases appearing every week. 5
Why GraphQL? 6
A type system to express possibilities 7
Declarative: Clients select what they need and nothing more 8
Why do we design? 9
Why we design • Build APIs that are easier to
evolve: Best way to mitigate breaking changes we don't know about yet • Build APIs that are easier to reason about 10
GraphQL Schema Design 11
Misconceptions 12
In a complex application GraphQL is rarely an interface to
your database 13
Your GraphQL Schema does not need to match your existing
REST resources 14
It also does not have to be a 1:1 mapping
to your UI 15
The real power of GraphQL 16
GraphQL lets us model an interface to our core domain
17
For a lot of us, it is often an opportunity
to design from scratch (and maybe get it right this time? ) 18
To let go of our coupling to our database schema,
our REST resources or our UI 19
Major to a well designed GraphQL API 20
21
• Be an expert at your domain, understand the ins
and out 21
• Be an expert at your domain, understand the ins
and out • Be an expert at GraphQL specific design 21
But there's one problem... 22
23
Rarely the same people! 24
API First 25
Built by the product team 26
Helped by the API team! ❤ 27
Design Tips 28
Design Tips 29
Guiding Principles 30
Guiding Principles 31 (and some cool tools)
Design for behaviors or use cases over data 32
Anemic GraphQL ™ 33
34
35
36
37
38
39
40
Atomicity vs Granularity 41
42
Let's go back a few years... 43
Problem: Multiple clients with very different needs 44
45 Backend For Frontend Pattern http://philcalcado.com/2015/09/18/the_back_end_for_front_end_pattern_bff.html
46 Netflix: Client Optimized API Adapters https://medium.com/netflix-techblog/embracing-the-differences-inside-the-netflix-api-redesign
47
In a way... GraphQL is our BFF / Client Adapter
48
Declarative & Client Centric 49
Select * 50
Select * 51
type User { billingInfo: BillingInfo! email: String! login: String! fullName:
String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 52
type User { billingInfo: BillingInfo! email: String! login: String! fullName:
String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 53
type User { billingInfo: BillingInfo! email: String! login: String! fullName:
String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 54
type User { billingInfo: BillingInfo! email: String! login: String! fullName:
String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 55
type User { billingInfo: BillingInfo! email: String! login: String! fullName:
String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 56
type User { billingInfo: BillingInfo! email: String! login: String! fullName:
String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 57
type User { billingInfo: BillingInfo! email: String! login: String! fullName:
String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 58
type User { billingInfo: BillingInfo! email: String! login: String! fullName:
String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 59
type User { billingInfo: BillingInfo! email: String! login: String! fullName:
String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 60
type User { billingInfo: BillingInfo! email: String! login: String! fullName:
String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 61
type User { billingInfo: BillingInfo! email: String! login: String! fullName:
String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 62
type User { billingInfo: BillingInfo! email: String! login: String! fullName:
String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 63
type User { billingInfo: BillingInfo! email: String! login: String! fullName:
String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 64
We shouldn't be afraid of adding use cases or client
specific fields if it fits a domain use case 65
Stay away from trying to build a "One Size Fits
All" API 66
and embrace the different use cases and clients 67
Prefer highly optimized fields over generic/smart fields 68
69
70
Design @ Scale: GitHub's Tooling 71
72 Checked-in SDL
73 Checked-in SDL
74
75
76
77
78 ) GraphQL Doctor
79
80
81
Sometimes we make mistakes 82
83
84
85
86
87
88
89 Fake it 'till you make it!
90
Making the change 91
Who is using the field? 92
How much is it being used? 93
No Select *: We know exactly how our schema is
used! 94
95 query { viewer { login email } }
95 query { viewer { login email } } GitHub
API
96 query { viewer { login email } } GitHub
API
96 query { viewer { login email } } GitHub
API GraphQL Query Analytics
97 query { viewer { login email } } GraphQL
Query Analytics Type: Query Field: viewer App: xxx Type: User Field: login App: xxx ...
98 Type: Query Field: viewer App: xxx Type: User Field:
login App: xxx ...
99 Type: Query Field: viewer App: xxx Type: User Field:
login App: xxx ...
100
101
GraphQL Schema Design @ Scale 102
Talk to, (or become) domain experts 103
Think Domain over Data 104
Sometimes it's not about "One Size Fits All" 105
Use the schema to build (or use) great tools! 106
Marc-Andre Giroux @___xuorig___ GraphQL Summit - Nov 7th 2018 Thank
You!