Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
GraphQL vs. JSON:API
Search
Aimeos
September 04, 2020
Programming
250
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GraphQL vs. JSON:API
Compares how GraphQL and the JSON REST API standard fits for e-commerce and CMS applications
Aimeos
September 04, 2020
More Decks by Aimeos
See All by Aimeos
PHP Map
aimeos
1
170
Responsive E-Mails
aimeos
0
710
gigacommerce
aimeos
0
3.2k
High performance e-commerce in Laravel
aimeos
0
950
E-Commerce in TYPO3 mit Aimeos (Deutsch)
aimeos
0
480
Aimeos - high performance e-commerce in TYPO3
aimeos
0
330
Aimeos e-commerce components
aimeos
1
220
E-Commerce in TYPO3 - Reloaded
aimeos
0
340
Micro services as architectural concept
aimeos
0
710
Other Decks in Programming
See All in Programming
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
140
速習iPhone Duo対応
yuukiw00w
2
970
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
34
16k
Turning Architecture into Unit Tests in the AI Era (NSSpain XIV)
steliosf
PRO
1
140
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
220
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
750
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
1
2.3k
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
8
6.1k
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
200
すこし踏み込む CancellationToken
htkym
2
1.7k
contenteditable と日本語入力に向き合う
colorful12
0
180
自サークルのIdPからログアウトできるようになるまで
taiseiue
1
130
Featured
See All Featured
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
580
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
550
The agentic SEO stack - context over prompts
schlessera
0
970
ラッコキーワード サービス紹介資料
rakko
1
5.3M
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Ethics towards AI in product and experience design
skipperchong
2
420
Scaling GitHub
holman
464
140k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
700
How to Talk to Developers About Accessibility
jct
2
570
Transcript
GraphQL vs. JSON:API
Aimeos E-Commerce framework
None
GraphQL
Invented by Facebook
Retrieve graph data efficiently
For complex queries
Minimize response data
{ product { name media { url } } }
Queries
{"data": { "product": { "name": "Simple product", "media": [{ "url":
"http://localhost/img/simple1.jpg" },{ "url": "http://localhost/img/simple2.jpg" }] } }} Response
Advantages
One API for all client requirements
Efficient requests including related resources
Retrieve only the data you really need
Writing several (related) resources at once
Exact schema definition provided by the server
type Product { id: ID label: String status: Boolean }
Schema
Well defined query language
{ product(code: '1000.001') { label attribute(type: 'variant') { id name
} } Query
Many client side libraries available
Disvantages
No caching by CDNs or proxies possible
Optimizing queries can be hard
Clients can build deep and complex queries
Client and server are thighly coupled
All application state must be maintained by the client
Query language adds more complexity
curl -X POST -H 'Content-Type: application/json' -d '{ "query": "{
products { name } }" }' http://localhost/graphql Query
Client side caching necessary may introduce additional points of failure
{ json:api }
Invented by Ember.js
Reduce the amount of client code
Easy client and server code
Use best practices
curl -H 'Content-Type: application/json' http://localhost/jsonapi/product Query
{"data": [{ "id": 1, "type": "product", "attributes": { "uid": "1",
"code": "SP01", "name": "Simple product", } }]} Response
Advantages
Efficient requests including related resources http://localhost/jsonapi/product?include=price
{"data": [{ "id": 1, "type": "product", "attributes": { … }
"relationships": { "price": [{"id": "123"}] }}], "included": [{ "id": 123, "type": "price", "attributes": { … } }]} Response
Retrieve only the data you really need http://localhost/jsonapi/product?fields=id,name
Caching by CDNs, proxies and browsers
Client and server are decoupled
Application state managed by the server
Hypermedia As The Engine Of Application State "links": { "self":
"http://localhost/jsonapi/product/13", "next": "http://localhost/jsonapi/product/21", "basket/product": "http://localhost/jsonapi/basket/default/product" } HATEOAS
Queries can be optimized for the required use cases
API interaction is plain simple
Disvantages
Only single resource can be updated at once
No specification of the query language
No schema returned by the server
No automatic schema validation
Conclusion
GraphQL
Best for internal APIs
Perfect as single endpoint for clients
Lacks of scalability
{ json:api }
Clients and servers can evolve independently
Can scale infinitely
Not for write heavy usage
None
JSON:API Keep for the frontend
GraphQL Use for the admin backend
Aimeos aimeos.org Twitter: @aimeos facebook.com/Aimeos