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 で変わったこと・変わらなかったこと / graphql changing an...
Search
qsona
June 02, 2020
Technology
23k
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GraphQL で変わったこと・変わらなかったこと / graphql changing and unchanging
吉祥寺.pm22
https://kichijojipm.connpass.com/event/177459/
qsona
June 02, 2020
More Decks by qsona
See All by qsona
サーバー間 GraphQL と webmock-graphql の話 / server-to-server graphql and webmock-graphql
qsona
4
640
Backend エンジニア視点からの GraphQL / GraphQL from a perspective of backend engineer
qsona
28
9.1k
3 Practices about Service-to-Service GraphQL Ruby Client
qsona
1
1.2k
いかにして GraphQL を組織に導入するか (新規開発編) / how we introduce GraphQL on scratch development
qsona
6
4.2k
Well-organized Transaction Script - リファクタリングの妥協的手法 -
qsona
4
1.6k
GraphQL と Prisma から考える次のN年を見据えた技術選定 / Architecture decision for the next N years at StudySapuri
qsona
25
17k
最高のマスターデータ管理手法考察 & VSCode Extension を活用した話 / developing masterdata management tool by using vscode extension
qsona
9
8.5k
GraphQL を活用したスキーマ駆動開発の実践 / schema-driven development with GraphQL
qsona
6
7.6k
GraphQL を利用したアーキテクチャの勘所 / Architecture practices with GraphQL
qsona
37
18k
Other Decks in Technology
See All in Technology
DBについての基礎説明(MySQL編) - コロプラ 2026年度 新卒研修
colopl
0
160
10年後、Engineering 行為を剥奪されるとして、わたしたちは、どう、何を創ればいいだろうか。 / If Engineering Is Taken Away in 10 Years, How and What Should We Create?
bitkey
PRO
1
220
Metadata - Section 2: Simple Metadata & Meta Tags
mohab1
0
110
国際カードブランドルール変更に伴うクレジットカード決済取引仕様変更について
k1style
0
140
野蛮なアジャイル [サイボウズ発!]組織の常識を覆した反骨のスクラム実践記 / Barbaric Agile - Enterprise Agile Study Group
ama_ch
0
120
Classmethod Company Deck
satoshi7
1
810
sue445's proposals 2026
sue445
0
130
From Developer Experience to Agentic Experience: The Next Evolution of APIs
benjagm
0
110
局所最適は悪ではない。壊れているのは指標です。量と質を同時に見る先行指標の設計
recruitengineers
PRO
2
270
AI駆動開発におけるハーネスエンジニアリングの勘所
tsukuboshi
1
480
顧客価値を追いかけたら、プライシングにたどり着いた
sansantech
PRO
2
400
野良MCPサーバーを排除せよ!MCPサーバーのガバナンス
yukiogawa
1
150
Featured
See All Featured
Building the Perfect Custom Keyboard
takai
2
910
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
930
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
450
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
740
The Pragmatic Product Professional
lauravandoore
37
7.5k
Site-Speed That Sticks
csswizardry
13
1.6k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
610
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
750
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.9k
Accessibility Awareness
sabderemane
1
250
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
530
Transcript
GraphQL ͰมΘͬͨ͜ͱɾ มΘΒͳ͔ͬͨ͜ͱ 2020-06-02 ٢ࣉ.pm22 @qsona
whoami • @qsona • Web Developer at Quipper Limited •
͖ͪͽʔॳࢀՃ!!! ͏Ε͍͠!!! ٢ࣉԕ͍!!!
ࠓͷ • ͜Ε·ͰԿ͔ GraphQL & Rails Ͱ API ։ൃΛͯ͠ ຊ൪ϦϦʔεͨ͠
• RESTful ࣌ͱʮมΘͬͨ͜ͱɾมΘΒͳ͔ͬͨ͜ͱʯ ʹ͍͍ͭͯͨ͠
લఏ • Web API Internal use Λఆ͢Δ • πʔϧɾΤίγεςϜͷҰ͠ͳ͍
• APIͷઃܭɾ࣮ͷ͚ͩ • ਅͷREST (Hypermedia API) ͷ͠ͳ͍
Web API ͷઃܭख๏ • Usecase ϕʔε • Resource ϕʔε
Usecase-based Web API • ΫϥΠΞϯτͷϢʔεέʔεʹ߹Θͤͯ Web API Λ࡞Δ • Ϣʔεέʔε
≒ ը໘ • • ࣅͨΑ͏ͳAPI͕ཚཱ͍͢͠ • ຖAPI࡞Δͷ͕໘ => ෳͷϢʔεέʔεʹରԠ͢Δ ਆAPI ͕Ͱ͖Δ
Resource-based Web API • ΞϓϦέʔγϣϯͦͷͷͷ༷ʹ߹Θͤͯ Web API Λ࡞Δ • (جຊతʹ
API ఏڙଆͷ߹Ͱ࡞Δ)
Resource-based Web API • : ΫϥΠΞϯτͷϢʔεέʔεʹ߹Θͳ͍͕࣌͋Δ • 1ը໘ͰෳͷAPIϦΫΤετ͕ඞཁʹͳͬͨΓ • ٯʹ1ϦΫΤετதͰෆཁͳϑΟʔϧυؚΊͯऔͬͯ͠·͏͜ͱ͕͋Δ
• (=> ύϑΥʔϚϯεͷѱԽ) • Resource ͕ࡉ͔͘ͳΓ͗ͯ͢ (ςʔϒϧ୯ҐͳͲ) ΫϥΠΞϯτ͔Β͍ʹ͍͘͜ͱ͕͋Δ
Resource • ݸਓతʹɺ Recourse-based API ʹ͓͍ͯ JSONͷ1֊͝ͱͷ෦Λ Resource ͱݺΜͰ͍·͢
RESTful ࣌ͷࢦ
RESTful ࣌ͷࢦ • جຊతʹ Resource ϕʔεΛબ͢Δ • Resource ΛదͳཻͰఏڙ͢Δ •
ςʔϒϧ୯ҐͰͳ͍ • ΞϓϦέʔγϣϯ্ͷυϝΠϯϞσϧΛߟ͠ɺͦΕʹ߹ΘͤΔ • Ͳ͏ͯ͠ඞཁͳΒผ్ Usecase ༻ͷ endpoint Λੜ͢
GraphQL • Schema ͕ Type ͷ άϥϑߏʹͳ͍ͬͯΔ • query Ͱ
field Λࢦఆ͢Δ͜ͱͰɺ άϥϑͷதͷऔಘ͢Δ෦ΛࢦఆͰ͖Δ
GraphQL ࣌ͷࢦ • GraphQL Type ͕ Resource Λද͢ • query
͕ Usecase Λද͢ • Query Type ͷ field ͕ endpoint Ͱ͋Δ • ͭ·ΓɺResource ϕʔεͷAPIͱ Usecase ϕʔεͷAPIͷ ྑ͍ͱ͜ΖΛཱ྆Ͱ͖Δ!
RESTful => GraphQL Ͱ มΘΒͳ͔ͬͨ͜ͱ
มΘΒͳ͔ͬͨ͜ͱ • ΞϓϦέʔγϣϯͷυϝΠϯΛ͖ͪΜͱߟͯ͠ɺ Resource Λదͳཻʹ͢Δ͜ͱ • Fat Controller, Fat Serializer
Λආ͚Δ͜ͱ • Model ෦ͷઃܭख๏
RESTful => GraphQL Ͱ มΘͬͨ͜ͱ
ແ
มΘͬͨ͜ͱ • ઃܭɾ࣮ϨϕϧͰมΘΔ͜ͱ΄ͱΜͲͳ͔ͬͨ • RESTful ͷͱ͖ͱରԠ͢Δ֓೦͕͋Δ • ͱ͍͑ɺසग़ͷ...? • N+1
• HTTP endpoint ͕શͯ POST /graphql ʹͳΔ
N+1 • Query.users Λ resolve • ͦͷ1݅ͣͭʹରͯ͠ User.jobs Λ resolve
N+1 • ಉ͡ RESTful Ͱى͖Δ • GraphQL ʹ͓͍ͯͳͥΫϩʔζΞο ϓ͞ΕΔ?
N+1 • GraphQL ʹ͓͍ͯӈͷΑ͏ʹɺ ΫϥΠΞϯτ͔Β2௨ΓͷऔΓํ͕γϡο ͱͰ͖Δɺͭ·Γศར • ศར͔ͩΒى͖͍ͯΔ͚ͩ • ղܾ๏:
Batch Loader ͱݺΕΔΈ • Ruby: shopify/graphql-batch
HTTP endpoint ͕શͯ POST /graphql ʹͳΔ • Persisted Query ͱݺΕΔΈͰղܾͰ͖Δ
• ࣄલ / ϥϯλΠϜ ʹΫΤϦΛొ͢Δ
ઃܭ/(୯७ͳ)࣮ΑΓ֎ͷ The NEXT of REST - onk.ninja https://blog.onk.ninja/2017/09/21/the_next_of_rest
͜͜ͰҰ۟ ා͘ͳ͍ GraphQL is Better REST