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 à Shopify
Search
Marc-Andre Giroux
April 05, 2017
Programming
290
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GraphQL à Shopify
Marc-Andre Giroux
April 05, 2017
More Decks by Marc-Andre Giroux
See All by Marc-Andre Giroux
It Depends - Examining GraphQL Myths & Assumptions
xuorig
0
140
So you Want to Distribute your GraphQL Schema?
xuorig
4
880
So you Want to Distribute your GraphQL Schema?
xuorig
0
690
GraphQL Schema Design @ Scale
xuorig
5
2.2k
Continuous Evolution of GraphQL Schemas @ GitHub
xuorig
3
2.2k
Exploring GraphQL
xuorig
0
310
GraphQL @ Shopify
xuorig
6
1.8k
GraphQL on Rails
xuorig
2
400
From REST to GraphQL
xuorig
9
1.3k
Other Decks in Programming
See All in Programming
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
500
全PRの83%がAIレビューだけでマージできるようになった開発組織はその後どうなったか
athug
1
1.6k
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
920
PHP に部分適用が来るぞ!……ところで何それ?おいしいの? #phpcon / phpcon-2026
shogogg
0
660
テーブルをDELETEした
yuzneri
0
140
AIが無かった頃の素敵な出会いの話
codmoninc
1
430
今さら聞けない .NET CLI
htkym
0
190
What's New in Android 2026
veronikapj
0
260
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
210
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
4.4k
freeeにおけるEvalsの実践例の紹介
freee
PRO
0
110
改善しないと、タスクが回らない。 “てんこ盛りポジション” を引き継いだ情シスの、入社3ヶ月の業務改善録
krm963
0
260
Featured
See All Featured
Everyday Curiosity
cassininazir
0
280
Facilitating Awesome Meetings
lara
57
7.1k
Optimising Largest Contentful Paint
csswizardry
37
3.9k
A Tale of Four Properties
chriscoyier
163
24k
Designing Experiences People Love
moore
143
24k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
280
The Curious Case for Waylosing
cassininazir
1
450
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
170
Speed Design
sergeychernyshev
33
2k
Claude Code のすすめ
schroneko
67
230k
What does AI have to do with Human Rights?
axbom
PRO
1
2.3k
Transcript
GraphQL @ Shopify Marc-André Giroux @__xuorig__
None
None
None
@__xuorig__ Les APIs REST sont
@__xuorig__ Sauf quand ils sont
@__xuorig__ Des allers-retours multiples... C'est pas idéal.
@__xuorig__ GET /people/1 GET /planet/2 GET /film/3
@__xuorig__ SELECT * FROM /ENDPOINT
@__xuorig__ GET /people/1 { "person": { "name": "luke" } }
@__xuorig__ { "name": "Luke Skywalker", "height": "172", "mass": "77", "hair_color":
"blond", "skin_color": "fair", "eye_color": "blue", "birth_year": "19BBY", "gender": "male", "homeworld": "http://swapi.co/api/ planets/1/", "films": [ "http://swapi.co/api/films/6/", "http://swapi.co/api/films/3/", "http://swapi.co/api/films/2/", "http://swapi.co/api/films/1/", "http://swapi.co/api/films/7/" ],
@__xuorig__ Qu'est-ce que nos clients utilisent vraiment?
@__xuorig__ { "name": "Luke Skywalker", "height": "172", "mass": "77", "hair_color":
"blond", "skin_color": "fair", "eye_color": "blue", "birth_year": "19BBY", "gender": "male", "homeworld": "http://swapi.co/api/ planets/1/", "films": [ "http://swapi.co/api/films/6/", "http://swapi.co/api/films/3/", "http://swapi.co/api/films/2/", "http://swapi.co/api/films/1/", "http://swapi.co/api/films/7/" ],
GraphQL
@__xuorig__ Un type spécial de base de données.
@__xuorig__ Une librairie ou un framework
@__xuorig__ Pas spécifique à un langage.
@__xuorig__ Langage de requête
@__xuorig__ &
@__xuorig__ Une Specification.
@__xuorig__ Un "Hello World" GraphQL
@__xuorig__ query { film { title } }
@__xuorig__ Anatomie d'une requête GraphQL.
@__xuorig__ query MyQuery { film { title } }
@__xuorig__ query MyQuery { film { title } } Operation
Type
@__xuorig__ query MyQuery { film { title } } Operation
Name
@__xuorig__ query MyQuery { film { title } } Selection
Set
@__xuorig__ query MyQuery { film { title } } Field
@__xuorig__ "data": { "film": { "title": "A New Hope" }
}
@__xuorig__ query { film(id: "123") { title } }
@__xuorig__ query { film(id: "123") { title characters { name
} } }
@__xuorig__ "data": { "film": { "title": "A New Hope", "characters":
[ { "name": "Luke Skywalker" }, { "name": "Princess Leia" } ] } }
@__xuorig__ query MyQuery { film { title } }
@__xuorig__ curl -X POST -d '{"query": "query MyQuery { film
{ title } }"}' http:// mongraphql.com/api --header "Content-Type:application/json"
@__xuorig__ curl -X POST -d '{"query": "query MyQuery { film
{ title } }"}' http:// mongraphql.com/api --header "Content-Type:application/json"
@__xuorig__ { film(id: "123") { title characters { name }
} }
@__xuorig__ Query film title characters name
@__xuorig__ Le Type System.
@__xuorig__ { film(id: "123") { title characters { name }
} }
@__xuorig__ { film(id: "123") { title characters { name }
} } type QueryRoot { film(id: ID!): Film }
@__xuorig__ { film(id: "123") { title characters { name }
} } type Film { title: String! characters: [Character!]! }
@__xuorig__ { film(id: "123") { title characters { name }
} } type Character { name: String! }
@__xuorig__ Introspection.
@__xuorig__ { __schema { types { name } } }
@__xuorig__ { __type(name: "Film") { name description } }
@__xuorig__ Introspection == Des clients avec des super pouvoirs!
@__xuorig__ • AutoSaisie • Validation côté client. • Intégration dans
nos IDE. • Génération de code.
@__xuorig__ GraphiQL
@__xuorig__
@__xuorig__ swapi-graphql-ruby.herokuapp.com
Mutations
@__xuorig__ mutation { addFilm(name: "StarWars 8") { title } }
Fragments
@__xuorig__ query { film(id: "123") { title characters { name
} } bestRatedfilm { title characters { name } } }
@__xuorig__ query { film(id: "123") { title characters { name
} } bestRatedfilm { title characters { name } } }
@__xuorig__ fragment filmFragment on Film { title characters { name
} }
@__xuorig__ query { film(id: "123") { ...filmFragment } bestRatedfilm {
...filmFragment } } fragment filmFragment on Film { title characters { name } }
@__xuorig__ Gestion des versions.
@__xuorig__ Versioning Continuous Evolution
@__xuorig__ Sécurité?
@__xuorig__ • Maximum Depth • Query Complexity • Timeout
@__xuorig__ Je perds ma cache HTTP? ;(
@__xuorig__ POST /graphql
@__xuorig__ • Cache côté client • Requête persistées
@__xuorig__ Requêtes persistées
@__xuorig__ Requêtes persistées query MyQuery { film { title }
} Yo. c'est possible que j'utilise cette requête plus tard!
@__xuorig__ Requêtes persistées Cool pas de prob, envoie moi "abcd"
et je l'exécuterai pour toi
@__xuorig__ Requêtes persistées J'ai besoin de "abcd"!
@__xuorig__ Requêtes persistées "data": { "film": { "title": "A New
Hope" } }
@__xuorig__ GraphQL @ Shopify
@__xuorig__ Définir les types module GraphApi class Shop < GraphApi::ObjectType
field :name, :string field :currency, :string, null: false field :products, [Product], resolve: ->(shop, _, _) { shop.products } end end
@__xuorig__ type Shop { name: String currency: String! products: [Product!]
}
@__xuorig__ • Client Side Cache • Persisted Queries Le Schema
est "Checked In"
@__xuorig__ Et doit toujours être régénéré!
@__xuorig__ On prévient les "breaking changes"
@__xuorig__ Et on force les bonnes pratiques!
@__xuorig__ GraphQL est
@__xuorig__ A Un seul allez-retour pour récupérer tout se qu'un
client à besoin.
@__xuorig__ Declaratif et predictible. (plus besoin de notre fameux SELECT
*)
@__xuorig__ Le serveur exprime les possibilités.
@__xuorig__ Les clients définissent leurs besoins.
@__xuorig__ separation of concerns!
@__xuorig__ DX
@__xuorig__ DX (Developer Experience)
@__xuorig__ On "ship" plus rapidement
@__xuorig__ Et tout le monde est heureux.
Merci! Marc-André Giroux @__xuorig__