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
Solve N+1 Problem in GraphQl API
Search
Ngalam Backend Community
April 28, 2019
Programming
2
50
Solve N+1 Problem in GraphQl API
Ngalam Backend Community
April 28, 2019
Tweet
Share
More Decks by Ngalam Backend Community
See All by Ngalam Backend Community
Web_Scraping_with_Scrapy.pdf
ngalambackend
0
79
Introduction to Flask
ngalambackend
0
170
Achieving API Performance and Scalability
ngalambackend
0
87
Interfaces in Go
ngalambackend
0
57
CSS in JS in action
ngalambackend
0
56
Productive Remote Working with Scrum
ngalambackend
0
87
Covid Tracker Kota Malang
ngalambackend
0
62
Supercharge Local Development with Docker
ngalambackend
1
120
Building Scalable and Flexible API by Leveraging GraphQL and BigTable
ngalambackend
1
320
Other Decks in Programming
See All in Programming
CSC509 Lecture 06
javiergs
PRO
0
240
Local Peer-to-Peer APIはどのように使われていくのか?
hal_spidernight
2
450
Django Ninja による API 開発効率化とリプレースの実践
kashewnuts
0
930
デミカツ切り抜きで面倒くさいことはPythonにやらせよう
aokswork3
0
190
GraphQL×Railsアプリのデータベース負荷分散 - 月間3,000万人利用サービスを無停止で
koxya
1
1.1k
Back to the Future: Let me tell you about the ACP protocol
terhechte
0
130
私はどうやって技術力を上げたのか
yusukebe
43
17k
育てるアーキテクチャ:戦い抜くPythonマイクロサービスの設計と進化戦略
fujidomoe
1
150
2分台で1500examples完走!爆速CIを支える環境構築術 - Kaigi on Rails 2025
falcon8823
3
3.1k
アメ車でサンノゼを走ってきたよ!
s_shimotori
0
140
SpecKitでどこまでできる? コストはどれくらい?
leveragestech
0
520
CSC509 Lecture 05
javiergs
PRO
0
290
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
49
14k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
30
2.9k
Learning to Love Humans: Emotional Interface Design
aarron
274
40k
Side Projects
sachag
455
43k
YesSQL, Process and Tooling at Scale
rocio
173
14k
Build your cross-platform service in a week with App Engine
jlugia
232
18k
Rails Girls Zürich Keynote
gr2m
95
14k
The Power of CSS Pseudo Elements
geoffreycrofte
79
6k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
2.6k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
19
1.2k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
Transcript
Solve N+1 Problem in GraphQL API Disyam Adityana Putra Team
Leader @ Hash Rekayasa Teknologi
Ask The Audience • Raise Your Hand • Know GraphQL
• Try GraphQL • Use GraphQL
N+1 Problem
dataloader to the rescue
dataloader • batching • caching • per request • fetch
data modification
dataloader const DataLoader = require('dataloader') const userLoader = new DataLoader(keys
=> myBatchGetUsers(keys));
dataloader input = [2, 1, 5, 3, 4]; output =
[ { id: 2, name: "two" }, { id: 1, name: "one" }, { id: 5, name: "five" } { id: 3, name: "three" } { id: 4, name: "four" } ];
batching • The Array of values must be the same
length as the Array of keys • Each index in the Array of values must correspond to the same index in the Array of keys
caching const userLoader = new DataLoader(...) const result1 = await
userLoader.load(1) const result2 = await userLoader.load(1) assert(result1 === result2)
Other implementations PHP: DataLoaderPHP Ruby: Dataloader, BatchLoader ReasonML: bs-dataloader Java:
java-dataloader Elixir: dataloader Golang: Dataloader
Question?
Thank You code: https://github.com/disyam/graphql-loader