Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
RubyではじめるGraphQL
hatappi
May 29, 2019
Technology
0
440
RubyではじめるGraphQL
#ebisurb
hatappi
May 29, 2019
Tweet
Share
More Decks by hatappi
See All by hatappi
RubyでChainerつくってます!!
hatappi
2
1.2k
TDDな個人開発
hatappi
0
140
できるだけ楽して楽しくRails開発しよう
hatappi
2
250
EKSにRailsをのせた
hatappi
1
760
RubyとApache Arrow
hatappi
0
1.2k
Red Chainerを なぜ作って今後どうするのか
hatappi
2
1.6k
Fargateで夢は見られるのか
hatappi
1
1.5k
個人サービスをFargateに移行したよ
hatappi
1
440
Rails + TypeScript + React + Hypernovaで始めるSSRライフ
hatappi
1
1.4k
Other Decks in Technology
See All in Technology
UWBを使ってみた
norioikedo
0
430
Azure Arc Virtual MachineとAzure Arc Resource Bridge / VM provisioning through Azure portal on Azure Stack HCI (preview)
sashizaki
0
160
機械学習システムのアーキテクチャとデザインパターン
washizaki
1
640
Custom AppをIP制限ありのままで審査に通す方法
yusuga
0
700
現状のFedCMの動作解説と OIDCとの親和性について- OpenID TechNight vol.19
ritou
2
460
FoodTechにおける商流・金流・物流の進化/Evolution of Commercial, Financial, and Logistics in FoodTech
dskst
0
410
EKSの運用あれこれ バージョンアップ編
tetsunosato
0
100
JAWS-UG re:Habilitaion 報告 / JAWS-UG OITA rehabilitation
hiranofumio
0
130
What's Data Lake ? Azure Data Lake best practice
ryomaru0825
2
750
miisan's career talk
mii3king
0
230
How to start with DDD when you have a Monolith
javujavichi
0
350
モブに早く慣れたい人のためのガイド / A Guide to Getting Started Quickly with Mob Programming
cybozuinsideout
PRO
2
1.9k
Featured
See All Featured
Infographics Made Easy
chrislema
233
17k
The Mythical Team-Month
searls
209
39k
Writing Fast Ruby
sferik
612
57k
Stop Working from a Prison Cell
hatefulcrawdad
261
17k
Teambox: Starting and Learning
jrom
123
7.7k
The Illustrated Children's Guide to Kubernetes
chrisshort
15
36k
Bootstrapping a Software Product
garrettdimon
296
110k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
5
510
GraphQLとの向き合い方2022年版
quramy
16
8.3k
Put a Button on it: Removing Barriers to Going Fast.
kastner
56
2.3k
Rails Girls Zürich Keynote
gr2m
86
12k
Building Better People: How to give real-time feedback that sticks.
wjessup
344
17k
Transcript
RubyͰ࢝ΊΔ GraphQLೖ #23 @hatappi
Yusaku Hatanaka @hatappi Merpay Inc. Go, Ruby, etc… <<Ruby Activity>>
Roppongi.rb organizer RubyKaigi 2019
ಥવͰ͕࣭͢Ͱ͢
GET /users/1 ϦΫΤετ͠·ͨ͠ Կ͕ฦ͖ͬͯ·͔͢ʁ
ᶃ ᶄ ᶅ
ᶃ ᶄ ᶅ
༗ޮͳJSONΛฦͤΔͳΒOK ͔͠͠ϦιʔεʹΑͬͯϑΥʔϚοτ͕ҟͳΔͱɻɻɻ Τϥʔ࣌ͷϨεϙϯεϑΥʔϚοτΕ͕ͪ
userͱfriendsΛऔಘ͍ͨ͠ GET /users/1 GET /users/1/friends
ඞཁͳใΛऔಘ͢ΔͨΊʹ Կճ͔ϦΫΤετΛ͢Δ͜ͱ
GraphQL͕ ׆༂Ͱ͖Δ͔ʁʂ
GraphQL • APIͷͨΊͷΫΤϦݴޠ • ΫΤϦݴޠͷ༷ͱͯ͠ܕఆٛ͞Εͨε ΩʔϚΛఆٛͯ͠ΫΤϦΛ༻͍͍ͯ߹Θ ͤΛ͢Δ • FacebookʹΑͬͯ։ൃ͞Εͯ2015ʹOSSͱ ͯ͠ެ։͞Εͨ
• https://graphql.org/
ΫΤϦݴޠ • GraphQLͷAPIϦΫΤετΛ͢ΔͨΊͷݴޠ • σʔλऔಘܥ Query, σʔλΛ࡞ͨ͠Γߋ৽ Mutation, αʔόʔ͔ΒͷΠϕϯτ Λड͚औΔ
Subscription ͕͋Δ • GraphQL APIͷ༷Λهड़ • ֤ϑΟʔϧυʹܕΛએݴ͕ඞཁ • Int, Float, String, Boolean, IDͳͲ͕࠷ॳ͔Βఆٛ͞Ε͍ͯͯࣗͰఆٛ͢Δ͜ ͱՄೳ εΩʔϚݴޠ
GitHub GraphQL API https://developer.github.com/v4/explorer/ ۙʹࢼͤΔ!! ※ຊ൪ͷσʔλͳͷͰߋ৽ܥͳͲҙͯ͠͏ʂ
POST /graphql
ϦΫΤετ Ϩεϙϯε
ϦΫΤετ Ϩεϙϯε
͜͏͍͏ͷ͕΄͍͠!! ʹର͍ͯۙ͠ܗͰฦͯ͘͠ΕΔ
RubyͰGraphQL
graphql-ruby • GraphQLͷύʔαʔͱϥϯλΠϜͷRuby࣮ • 201905݄29 v1.9.6 ͕࠷৽ • 1.8·ͰಠࣗͷDSL͚ͩͬͨͲ1.8Ҏ߱Ϋ ϥεϕʔεͰεΩʔϚఆٛͰ͖ΔΑ͏ʹ
ͳͬͨ
RubyΒ͘͠GraphQLͷεΩʔϚΛ ఆٛ͢Δ͜ͱ͕Ͱ͖Δ
Anket + GraphQL
• Slack ্ͰΞϯέʔτΛͱΔͨΊͷαʔϏε • 2018/11ʹ βϦϦʔε • Ξϯέʔτͷ࡞ථ Slack ্͔Βߦ͏
• WEB্ͰμογϡϘʔυΛݟΔ͜ͱ͕Ͱ͖ͯ Rails 5 Ͱ࡞͞Ε͍ͯΔ • Railsͱ͔k8sͱ͔ٕज़తཁૉΛࢼ͢ͱͯ͠ϓϥΠ ϕʔτͰ࡞
ಋೖͨ݁͠Ռ
GraphiQL͕ศར • GraphQL ʹରͯ͠ΫΤϦΛൃߦ͢ΔͨΊͷπʔϧ • GithubͷAPIίϯιʔϧͰ༻͞Ε͍ͯΔ • ΫΤϦͷൃߦ͚ͩͰͳ͘ΫΤϦิAPIϦϑΝϨϯε͕͑ΔͷͰIDEͱͯ͑͠Δ • graphql-rubyΛRailsͰ͏࣌install͢Δ࣌ʹҰॹʹೖΔ
ςετ
Complexity & Depth ͷ੍ݶ͕͔͚ΒΕΔ • Complexity • 1requestʹର͢ΔComplexityΛ੍ݶ • Depth
• queryͷೖΕࢠͷ੍ݶ
Complexity fields͝ͱʹComplexityΛઃఆͰ͖ΔͷͰॏ ͍ॲཧͷੜίετΛେ͖Ίʹઃఆ͢Δͳ Ͳͷઃఆ͕Մೳ
Depth
·ͱΊ • GraphQL, graphql-rubyͷΛ͠·ͨ͠ • ୯ҰͷΤϯυϙΠϯτͳͷͰύϑΥʔϚϯεͷܭଌͳͲ͕ඞཁ • Anket ݱঢ়͖ʹ͔͠GraphQL API
Λެ։ͯ͠·ͤΜ͕ɺࠓޙ֎ ͚ʹެ։༧ఆͰ͢ʂʂ • ެ։ͨ͠ΒͥͻͬͯΈ͍ͯͩ͘͞ʂʂ