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 vs. JSON:API
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
160
Responsive E-Mails
aimeos
0
700
gigacommerce
aimeos
0
3.2k
High performance e-commerce in Laravel
aimeos
0
940
E-Commerce in TYPO3 mit Aimeos (Deutsch)
aimeos
0
470
Aimeos - high performance e-commerce in TYPO3
aimeos
0
330
Aimeos e-commerce components
aimeos
1
220
E-Commerce in TYPO3 - Reloaded
aimeos
0
330
Micro services as architectural concept
aimeos
0
710
Other Decks in Programming
See All in Programming
PostgreSQL 18で考えるUUID主キー
kazuhiro1982
0
380
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
170
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
200
信頼性について考えてみる(SRE NEXT 2026 miniLT)
hayama17
0
210
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
500
ビデオ通話が繋がる0.2秒で何が起きているのか
supurazako
2
150
継続モナドとリアクティブプログラミング
yukikurage
3
640
今さら聞けない .NET CLI
htkym
0
130
【やさしく解説 設計編・中級 #1】一つの車に、運転手は一人 ~ある倉庫システムの事例から~
panda728
PRO
0
190
What's New in Android 2026
veronikapj
0
190
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
1.2k
自作OSでスライド発表する
uyuki234
1
3.9k
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
55
10k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.6k
KATA
mclloyd
PRO
35
15k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
260
Embracing the Ebb and Flow
colly
88
5.1k
Scaling GitHub
holman
464
140k
[SF Ruby Conf 2025] Rails X
palkan
2
1.2k
Mind Mapping
helmedeiros
PRO
1
290
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