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
RubyではじめるGraphQL
Search
hatappi
May 29, 2019
Technology
0
790
RubyではじめるGraphQL
#ebisurb
hatappi
May 29, 2019
Tweet
Share
More Decks by hatappi
See All by hatappi
RubyでChainerつくってます!!
hatappi
2
1.3k
TDDな個人開発
hatappi
0
270
できるだけ楽して楽しくRails開発しよう
hatappi
2
300
EKSにRailsをのせた
hatappi
1
1.1k
RubyとApache Arrow
hatappi
0
2.2k
Red Chainerを なぜ作って今後どうするのか
hatappi
2
2.2k
Fargateで夢は見られるのか
hatappi
1
2k
個人サービスをFargateに移行したよ
hatappi
1
630
Rails + TypeScript + React + Hypernovaで始めるSSRライフ
hatappi
1
2k
Other Decks in Technology
See All in Technology
今年一年で頑張ること / What I will do my best this year
pauli
1
220
Docker Desktop で Docker を始めよう
zembutsu
PRO
0
180
[IBM TechXchange Dojo]Watson Discoveryとwatsonx.aiでRAGを実現!事例のご紹介+座学②
siyuanzh09
0
110
完全自律型AIエージェントとAgentic Workflow〜ワークフロー構築という現実解
pharma_x_tech
0
350
TSのコードをRustで書き直した話
askua
2
190
embedパッケージを深掘りする / Deep Dive into embed Package in Go
task4233
1
220
AWSマルチアカウント統制環境のすゝめ / 20250115 Mitsutoshi Matsuo
shift_evolve
0
120
2024AWSで個人的にアツかったアップデート
nagisa53
1
110
AIアプリケーション開発でAzure AI Searchを使いこなすためには
isidaitc
1
120
データ基盤におけるIaCの重要性とその運用
mtpooh
4
530
テストを書かないためのテスト/ Tests for not writing tests
sinsoku
1
170
Goで実践するBFP
hiroyaterui
1
120
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
40
2.5k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
3
360
Bash Introduction
62gerente
610
210k
Documentation Writing (for coders)
carmenintech
67
4.5k
The Language of Interfaces
destraynor
155
24k
Side Projects
sachag
452
42k
YesSQL, Process and Tooling at Scale
rocio
170
14k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
Mobile First: as difficult as doing things right
swwweet
222
9k
Building Your Own Lightsaber
phodgson
104
6.2k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
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
Λެ։ͯ͠·ͤΜ͕ɺࠓޙ֎ ͚ʹެ։༧ఆͰ͢ʂʂ • ެ։ͨ͠ΒͥͻͬͯΈ͍ͯͩ͘͞ʂʂ