GraphQLサーバーを作って味わった天国と地獄

14db998b47be4e3c3962b03b7c16d195?s=47 ryohysk
August 24, 2019

 GraphQLサーバーを作って味わった天国と地獄

14db998b47be4e3c3962b03b7c16d195?s=128

ryohysk

August 24, 2019
Tweet

Transcript

  1. www.companyname.com © 2016 Jetfabrik Multipurpose Theme. All Rights Reserved. 1

    GraphQLαʔόʔ Λ࡞ͬͯຯΘͬͨ ఱࠃͱ஍ࠈ גࣜձࣾϏσΦϚʔέοτ ૣࡔ ྋ Kotlin Fest 2019 2019/08/24
  2. 2 ϓϩϑΟʔϧ ɾגࣜձࣾϏσΦϚʔέοτͷαʔόʔαΠυΤϯδχΞ ɾKotlinͱGraphQLΛ࢖ͬͨAPIΛઈࢍ։ൃதʢ9্݄०ʹ ฐࣾVODαʔϏεͷiOSΞϓϦΛϦχϡʔΞϧ༧ఆʣ ɾϚονϯάΞϓϦͰ஌Γ߹ͬͨ൴ঁͱ࠷ۙผΕͯই৺த Kotlin Java Go PHP

    Ryo Hayasaka @hayaboytech
  3. www.companyname.com © 2016 Jetfabrik Multipurpose Theme. All Rights Reserved. 3

    GraphQLͱKotlinΛϓϩμΫτʹ࠾༻ͨ͠ཧ༝ ͸ͳ͢͜ͱ ఱࠃΈʢ3ͭʣ ஍ࠈΈʢ2ͭʣ
  4. 4 GraphQLͱKotlinΛϓϩμΫτʹ࠾༻ͨ͠ཧ༝ APIʹਫ਼௨͍ͯ͠ͳ͍ਓͰ΋؆୯ʹૢ࡞Մೳ ΫϥΠΞϯτπʔϧ͔Β௚ײతʹૢ࡞ GraphQLΫϥΠΞϯτͰӾཡͰ͖Δ = ࢓༷ ࢓༷ͱ࣮૷͕ζϨͳ͘ͳΔ Spring Boot༻ͷ΋͋Γ·͢

    ϥΠϒϥϦΛ࢖ͬͯߴ଎ʹ։ൃ αʔόʔαΠυKotlinΛ࢖͏͜ͱͰ ΞϓϦΤϯδχΞͱ஥ྑ͠ʹ 02 03 04 01 ୭Ͱ΋࢖͍΍͍͢ ։ൃ͠΍͍͢
  5. www.companyname.com © 2016 Jetfabrik Multipurpose Theme. All Rights Reserved. 5

    ࢼ͠ʹΫΤϦΛ౤͛ͯΈ͍ͨ৔ ߹ʹ͍͍ͪͪॻ͘ͷ͸໘౗ɻ ADD QUERY΍ADD FRAGMENT Ͱߴ଎ʹΫΤϦΛ࡞੒Ͱ͖Δɻ ⅰ) ΫΤϦͷࣗಈੜ੒͕Ͱ͖Δ LightɺDarkɺDraculaͷࡾͭͷ ςʔϚ͔Β޷͖ͳςʔϚΛઃఆ ͯ͠࢖͏͜ͱ͕Ͱ͖Δɻ ⅱ) ΧελϜςʔϚ͕ઃఆͰ͖Δ Mac΍WindowsΞϓϦɺChrome΍Firefoxͷ֦ுػೳ΋ఏڙ͍ͯ͠ΔAltair(ΞϧλΠϧ)ɻ https:/ /altair.sirmuel.design/ Altair(GraphQL ΫϥΠΞϯτ)͕༏ल ఱࠃΈ①
  6. 6 See You Next Time The Break! ͜͜Λԡ͚ͩ͢Ͱ ϦΫΤετ෦ʹ௥ Ճ͞ΕΔ

    ϦΫΤετ෦ Ϩεϙϯε෦ υΩϡϝϯτ෦
  7. www.companyname.com © 2016 Jetfabrik Multipurpose Theme. All Rights Reserved. 7

    ϑΟʔϧυʹΞΫηε͚ͨ࣌ͩ͠औಘ ॲཧ͕૸ΔΑ͏ʹͰ͖Δɻ ϚΠΫϩαʔϏεͱ૬ੑ͕͍͍ɻ graphql-spring-bootͷϥΠϒϥϦΛ࢖ ͏ͱɺGraphQLResolverΛ࢖͏͚ͩͰ ؆୯ʹ࣮૷Ͱ͖Δɻ ແବͳ௨৴Λ૸Βͤͳ͍ ఱࠃΈ② ྫ ϙΠϯτऔಘॲཧ͕ ૸Δ ϙΠϯτऔಘॲཧ͕ ૸Βͳ͍
  8. www.companyname.com © 2016 Jetfabrik Multipurpose Theme. All Rights Reserved. 8

    GraphQLΛ࢖ͬͯΈ͍ͨਓ͕݁ߏ͍ͨɻ ΫΤϦͷֶशίετ΋௿͘ɺAltairͷ࢖༻ײ΋޷ධɻ ΞϓϦΤϯδχΞ΍σβΠφʔ͔ΒϞςΔ ఱࠃΈ③
  9. www.companyname.com © 2016 Jetfabrik Multipurpose Theme. All Rights Reserved. 9

    εΩʔϚϑΝΠϧҎ֎ͰAPIͷఆٛΛͯ͠͠·͏ͱɺυΩϡϝϯτͷೋॏ؅ཧʹͳͬͯ ͠·͏ɻ GraphQLͰ͸ଞͷυΩϡϝϯτπʔϧͰ؅ཧ͠Α͏ͱ͠ͳ͍͜ͱɻ ΞϓϦΤϯδχΞ͕࢖͑ΔMockαʔόʔ͸ૣΊʹ༻ҙ͠Α͏ɻ ࢓༷ͱ࣮૷͕ζϨͨʂʁʢΞϯνύλʔϯʣ ஍ࠈΈ①
  10. www.companyname.com © 2016 Jetfabrik Multipurpose Theme. All Rights Reserved. 10

    ఱ ࠃ Έ ② Ͱ औ Γ ্ ͛ ͨ Α ͏ ͳ GraphQLResolverΛ࢖࣮ͬͨ૷Λ҆қ ʹͯ͠͠·͏ͱɺϨεϙϯεʹͦͷϑ Οʔϧυ͕ෳ਺ग़ݱ͢Δ͚ͩͰN+1ͷ ௨৴͕ൃੜͯ͠͠·͏ɻ σʔλϩʔμʔΛ࢖͓͏ɻ N+1໰୊ͷରॲ ஍ࠈΈ② ྫ ϦΫΤετ ෳ਺ͷϢʔβʔΛऔಘ Ϩεϙϯε ϙΠϯτͷ਺͚ͩ௨৴ ௨৴ ௨৴ ௨৴ ௨৴
  11. www.companyname.com © 2016 Jetfabrik Multipurpose Theme. All Rights Reserved. 11

    ⅰ) ·ͱΊͯऔಘͰ͖ΔϏδωεϩδοΫΛ࡞੒͢Δ(όϧΫϑΣον) ஍ࠈΈ② - σʔλϩʔμʔ࣮૷खॱᾜ ʲࢀߟʳ
  12. www.companyname.com © 2016 Jetfabrik Multipurpose Theme. All Rights Reserved. 12

    ⅱ) σʔλϩʔμʔʹϏδωεϩδοΫΛొ࿥͢Δ ஍ࠈΈ② - σʔλϩʔμʔ࣮૷खॱᾝ ʲࢀߟʳ
  13. www.companyname.com © 2016 Jetfabrik Multipurpose Theme. All Rights Reserved. 13

    ⅲ) ొ࿥ͨ͠σʔλϩʔμʔΛݺͼग़͢ ஍ࠈΈ② - σʔλϩʔμʔ࣮૷खॱᾞ ʲࢀߟʳ
  14. www.companyname.com © 2016 Jetfabrik Multipurpose Theme. All Rights Reserved. 14

    ·ͱΊ 9݄ʹiOSΞϓϦϦχϡʔΞϧ༧ఆ https:/ /creators.videomarket.co.jp/ ΫϦΤΠλʔζϒϩά ɾϥΠϒϥϦΛ࢖͑͹͙͢ʹ։ൃ͕Ͱ͖Δ ɾGraphQLαʔόʔΛ࡞Δͱت͹ΕΔ ɾN+1͸ཁ஫ҙ
  15. www.companyname.com © 2016 Jetfabrik Multipurpose Theme. All Rights Reserved. 15

    Thank You Ryo Hayasaka tw:@hayaboytech