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
OS アップデート対応の取り組み方がもっと共有されてほしい
andpad
0
110
技術的負債解消で開発者の未来を開く- AIの力でコード刷新
kmd2kmd
0
140
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
430
技術記事、 専門家としてのプログラマ、 言語化
mizchi
14
7.2k
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
460
AIで効率化できた業務・日常
ochtum
0
160
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
7
1.7k
AI 輔助遺留系統現代化的經驗分享
jame2408
1
1.1k
symfony/aiとlaravel/boost
77web
0
120
Performance Engineering for Everyone
elenatanasoiu
0
250
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
380
Featured
See All Featured
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Side Projects
sachag
455
43k
エンジニアに許された特別な時間の終わり
watany
107
250k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.1k
Designing Experiences People Love
moore
143
24k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
360
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
660
Faster Mobile Websites
deanohume
310
32k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
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__