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
280
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
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
350
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
290
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
2.4k
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
750
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
320
Webフレームワークの ベンチマークについて
yusukebe
0
130
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
2.8k
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.3k
GitHub Copilot CLIのいいところ
htkym
2
1.3k
oxlintはeslint/typescript-eslintを置き換えられるのか
shomafujita
2
320
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
150
運用エージェントは "作る" から "育てる" へ - 記憶と自己進化の3層設計パターン / self-evolving-agents-three-layer-agent-design
gawa
12
3.5k
Featured
See All Featured
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
170
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
150
Optimising Largest Contentful Paint
csswizardry
37
3.7k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Designing for Performance
lara
611
70k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
Become a Pro
speakerdeck
PRO
31
6k
Navigating Team Friction
lara
192
16k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
220
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
600
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
550
Color Theory Basics | Prateek | Gurzu
gurzu
0
350
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__