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
71
Introduction to Flask
ngalambackend
0
98
Achieving API Performance and Scalability
ngalambackend
0
59
Interfaces in Go
ngalambackend
0
48
CSS in JS in action
ngalambackend
0
38
Productive Remote Working with Scrum
ngalambackend
0
57
Covid Tracker Kota Malang
ngalambackend
0
55
Supercharge Local Development with Docker
ngalambackend
1
93
Building Scalable and Flexible API by Leveraging GraphQL and BigTable
ngalambackend
1
280
Other Decks in Programming
See All in Programming
AWS Application Composerで始める、 サーバーレスなデータ基盤構築 / 20240406-jawsug-hokuriku-shinkansen
kasacchiful
1
260
CA.swift19 恋するAIアプリ開発の裏側
oskmr
0
360
AWS CDKコントリビュートTIPS / aws-cdk-contribution-tips
gotok365
2
190
VSCodeでのDatabricks開発もお勧めしたい/I would also recommend Databricks development with VSCode.
kazumain
0
250
Ruby Function Composition
bkuhlmann
1
330
What We Can Learn From OSS
inouehi
0
420
ゆるい個人開発のススメ
kuroppe1819
10
990
Let's learn code review
riofujimon
2
340
VS Code をプロダクトにどう取り込むか
onomax
1
360
デフォルトにして至高、RubyMineの大好きな所
ruzia
0
380
Fragment Composition of GraphQL
quramy
7
1k
try!Swift Tokyo 2024 参加報告 LT
akidon0000
1
220
Featured
See All Featured
Docker and Python
trallard
34
2.7k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
14
1.6k
Building a Scalable Design System with Sketch
lauravandoore
456
32k
BBQ
matthewcrist
80
8.8k
Automating Front-end Workflow
addyosmani
1356
200k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
7
1k
Writing Fast Ruby
sferik
621
60k
Fashionably flexible responsive web design (full day workshop)
malarkey
398
65k
StorybookのUI Testing Handbookを読んだ
zakiyama
13
4.6k
The MySQL Ecosystem @ GitHub 2015
samlambert
243
12k
Statistics for Hackers
jakevdp
789
220k
Adopting Sorbet at Scale
ufuk
68
8.6k
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