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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
AIで効率化できた業務・日常
ochtum
0
150
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.3k
ふつうのFeature Flag実践入門
irof
8
4.2k
Oxcを導入して開発体験が向上した話
yug1224
4
340
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
320
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
210
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
21
7.1k
技術記事、 専門家としてのプログラマ、 言語化
mizchi
13
6.6k
ローカルLLMを使ってB2Bサービスを作っていての学び
yaotti
0
220
任せる範囲はこう広がった / How the Scope of AI Delegation Has Expanded
nrslib
0
160
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
300
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
200
Featured
See All Featured
Producing Creativity
orderedlist
PRO
348
40k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
290
New Earth Scene 8
popppiees
3
2.4k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
Prompt Engineering for Job Search
mfonobong
0
350
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
Google's AI Overviews - The New Search
badams
0
1k
Agile that works and the tools we love
rasmusluckow
331
22k
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__