RubyではじめるGraphQL
by
hatappi
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
RubyͰ࢝ΊΔ GraphQLೖ #23 @hatappi
Slide 2
Slide 2 text
Yusaku Hatanaka @hatappi Merpay Inc. Go, Ruby, etc… <> Roppongi.rb organizer RubyKaigi 2019
Slide 3
Slide 3 text
ಥવͰ͕࣭͢Ͱ͢
Slide 4
Slide 4 text
GET /users/1 ϦΫΤετ͠·ͨ͠ Կ͕ฦ͖ͬͯ·͔͢ʁ
Slide 5
Slide 5 text
ᶃ ᶄ ᶅ
Slide 6
Slide 6 text
ᶃ ᶄ ᶅ
Slide 7
Slide 7 text
༗ޮͳJSONΛฦͤΔͳΒOK ͔͠͠ϦιʔεʹΑͬͯϑΥʔϚοτ͕ҟͳΔͱɻɻɻ Τϥʔ࣌ͷϨεϙϯεϑΥʔϚοτΕ͕ͪ
Slide 8
Slide 8 text
userͱfriendsΛऔಘ͍ͨ͠ GET /users/1 GET /users/1/friends
Slide 9
Slide 9 text
ඞཁͳใΛऔಘ͢ΔͨΊʹ Կճ͔ϦΫΤετΛ͢Δ͜ͱ
Slide 10
Slide 10 text
GraphQL͕ ׆༂Ͱ͖Δ͔ʁʂ
Slide 11
Slide 11 text
GraphQL • APIͷͨΊͷΫΤϦݴޠ • ΫΤϦݴޠͷ༷ͱͯ͠ܕఆٛ͞Εͨε ΩʔϚΛఆٛͯ͠ΫΤϦΛ༻͍͍ͯ߹Θ ͤΛ͢Δ • FacebookʹΑͬͯ։ൃ͞Εͯ2015ʹOSSͱ ͯ͠ެ։͞Εͨ • https://graphql.org/
Slide 12
Slide 12 text
ΫΤϦݴޠ • GraphQLͷAPIϦΫΤετΛ͢ΔͨΊͷݴޠ • σʔλऔಘܥ Query, σʔλΛ࡞ͨ͠Γߋ৽ Mutation, αʔόʔ͔ΒͷΠϕϯτ Λड͚औΔ Subscription ͕͋Δ • GraphQL APIͷ༷Λهड़ • ֤ϑΟʔϧυʹܕΛએݴ͕ඞཁ • Int, Float, String, Boolean, IDͳͲ͕࠷ॳ͔Βఆٛ͞Ε͍ͯͯࣗͰఆٛ͢Δ͜ ͱՄೳ εΩʔϚݴޠ
Slide 13
Slide 13 text
GitHub GraphQL API https://developer.github.com/v4/explorer/ ۙʹࢼͤΔ!! ※ຊ൪ͷσʔλͳͷͰߋ৽ܥͳͲҙͯ͠͏ʂ
Slide 14
Slide 14 text
POST /graphql
Slide 15
Slide 15 text
ϦΫΤετ Ϩεϙϯε
Slide 16
Slide 16 text
ϦΫΤετ Ϩεϙϯε
Slide 17
Slide 17 text
͜͏͍͏ͷ͕΄͍͠!! ʹର͍ͯۙ͠ܗͰฦͯ͘͠ΕΔ
Slide 18
Slide 18 text
RubyͰGraphQL
Slide 19
Slide 19 text
graphql-ruby • GraphQLͷύʔαʔͱϥϯλΠϜͷRuby࣮ • 201905݄29 v1.9.6 ͕࠷৽ • 1.8·ͰಠࣗͷDSL͚ͩͬͨͲ1.8Ҏ߱Ϋ ϥεϕʔεͰεΩʔϚఆٛͰ͖ΔΑ͏ʹ ͳͬͨ
Slide 20
Slide 20 text
RubyΒ͘͠GraphQLͷεΩʔϚΛ ఆٛ͢Δ͜ͱ͕Ͱ͖Δ
Slide 21
Slide 21 text
Anket + GraphQL
Slide 22
Slide 22 text
• Slack ্ͰΞϯέʔτΛͱΔͨΊͷαʔϏε • 2018/11ʹ βϦϦʔε • Ξϯέʔτͷ࡞ථ Slack ্͔Βߦ͏ • WEB্ͰμογϡϘʔυΛݟΔ͜ͱ͕Ͱ͖ͯ Rails 5 Ͱ࡞͞Ε͍ͯΔ • Railsͱ͔k8sͱ͔ٕज़తཁૉΛࢼ͢ͱͯ͠ϓϥΠ ϕʔτͰ࡞
Slide 23
Slide 23 text
ಋೖͨ݁͠Ռ
Slide 24
Slide 24 text
GraphiQL͕ศར • GraphQL ʹରͯ͠ΫΤϦΛൃߦ͢ΔͨΊͷπʔϧ • GithubͷAPIίϯιʔϧͰ༻͞Ε͍ͯΔ • ΫΤϦͷൃߦ͚ͩͰͳ͘ΫΤϦิAPIϦϑΝϨϯε͕͑ΔͷͰIDEͱͯ͑͠Δ • graphql-rubyΛRailsͰ͏࣌install͢Δ࣌ʹҰॹʹೖΔ
Slide 25
Slide 25 text
ςετ
Slide 26
Slide 26 text
Complexity & Depth ͷ੍ݶ͕͔͚ΒΕΔ • Complexity • 1requestʹର͢ΔComplexityΛ੍ݶ • Depth • queryͷೖΕࢠͷ੍ݶ
Slide 27
Slide 27 text
Complexity fields͝ͱʹComplexityΛઃఆͰ͖ΔͷͰॏ ͍ॲཧͷੜίετΛେ͖Ίʹઃఆ͢Δͳ Ͳͷઃఆ͕Մೳ
Slide 28
Slide 28 text
Depth
Slide 29
Slide 29 text
·ͱΊ • GraphQL, graphql-rubyͷΛ͠·ͨ͠ • ୯ҰͷΤϯυϙΠϯτͳͷͰύϑΥʔϚϯεͷܭଌͳͲ͕ඞཁ • Anket ݱঢ়͖ʹ͔͠GraphQL API Λެ։ͯ͠·ͤΜ͕ɺࠓޙ֎ ͚ʹެ։༧ఆͰ͢ʂʂ • ެ։ͨ͠ΒͥͻͬͯΈ͍ͯͩ͘͞ʂʂ