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
45
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
73
Introduction to Flask
ngalambackend
0
130
Achieving API Performance and Scalability
ngalambackend
0
77
Interfaces in Go
ngalambackend
0
52
CSS in JS in action
ngalambackend
0
50
Productive Remote Working with Scrum
ngalambackend
0
63
Covid Tracker Kota Malang
ngalambackend
0
59
Supercharge Local Development with Docker
ngalambackend
1
110
Building Scalable and Flexible API by Leveraging GraphQL and BigTable
ngalambackend
1
290
Other Decks in Programming
See All in Programming
Outline View in SwiftUI
1024jp
1
330
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
600
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
190
CSC509 Lecture 09
javiergs
PRO
0
140
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
Quine, Polyglot, 良いコード
qnighy
4
640
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
イベント駆動で成長して委員会
happymana
1
320
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
200
Featured
See All Featured
Visualization
eitanlees
145
15k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Become a Pro
speakerdeck
PRO
25
5k
Raft: Consensus for Rubyists
vanstee
136
6.6k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Embracing the Ebb and Flow
colly
84
4.5k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Thoughts on Productivity
jonyablonski
67
4.3k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
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