Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GraphQL を活用したスキーマ駆動開発の実践 / schema-driven development with GraphQL

942bb606679caf4c57b38927f83178e1?s=47 qsona
September 08, 2021

GraphQL を活用したスキーマ駆動開発の実践 / schema-driven development with GraphQL

MIDAS TECH STUDY #2

942bb606679caf4c57b38927f83178e1?s=128

qsona

September 08, 2021
Tweet

Transcript

  1. GraphQL Λ׆༻ͨ͠ εΩʔϚۦಈ։ൃͷ࣮ફ @qsona 2021-09-08 MIDAS TECH STUDY #2

  2. whoami • @qsona • Web Engineer at Quipper Ltd •

    Microservices / Rails / Node.js / GraphQL
  3. ࠓճͷςʔϚ: ϑϩϯτΤϯυ։ൃޮ཰Խ

  4. ։ൃʹ͓͚Δʮޮ཰Խʯͱ͸?

  5. Ϧιʔεޮ཰ͱϑϩʔޮ཰ • ΞδϟΠϧ։ൃͷจ຺ͰΑ͘ొ৔͢Δ֓೦ • ʮޮ཰ʯ(Efficiency) Λೋͭͷଆ໘͔Βఆ͍ٛͯ͠Δ

  6. Ϧιʔεޮ཰ γεςϜ։ൃͷจ຺ʹ͓͍ͯɺେࡶ೺ʹ͍͏ͱ: • ਓతϦιʔεͷྔ (ਓ਺ɾ೔਺) ʹରͯ͠ɺੜΈग़ͤΔػೳͷྔ • Ϧιʔεޮ཰͕ѱ͍ྫ • ϑϩϯτΤϯυͷ։ൃ͕։࢝Ͱ͖Δͷ͸ɺ


    όοΫΤϯυͷ։ൃ͕ऴΘ͔ͬͯΒ
 => όοΫΤϯυͷ։ൃ׬ྃ·ͰɺϑϩϯτΤϯδχΞ͕Ջ͍ͯ͠Δ
  7. ϑϩʔޮ཰ γεςϜ։ൃͷจ຺ʹ͓͍ͯɺେࡶ೺ʹ͍͏ͱ: • Ϣʔβʔʹػೳ͕ϦϦʔε͞ΕΔ·Ͱͷɺ࣌ؒͷ୹͞ • ϦϦʔε͞Εͳ͍ͱՁ஋ʹ͸ͳΒͳ͍ɻ
 Ձ஋ʹͳΔ·Ͱͷ଴͕ͪ࣌ؒ௕͍ͱޮ཰͕ѱ͍ɺͱ͍͏ߟ͑ํ • ϑϩʔޮ཰͕ѱ͍ྫ •

    ػೳͷ͏ͪόοΫΤϯυͷ։ൃ͸͕ͨ͠ɺϑϩϯτΤϯυͷ։ൃ͕·ͩɻ
 όοΫΤϯυࢹ఺Ͱ͸ϦϦʔε଴ͪͷঢ়ଶ͕௕͘ଓ͍͍ͯΔ
  8. εΩʔϚۦಈ։ൃͱ ։ൃޮ཰

  9. લఏɾԾఆ • ࠷ۙͷΞϓϦέʔγϣϯ։ൃ͸೉͍͠
 શһ͕͢΂ͯͷྖҬΛ͜ͳ͢ͷ͸ࠔ೉ • େ͖͘ϑϩϯτΤϯυɾόοΫΤϯυͰ
 εΩϧηοτ͕෼͔ΕΔ܏޲ʹ͋Δ • ࠓճ͸ όοΫΤϯυνʔϜ

    ͱ
 ϑϩϯτΤϯυνʔϜ ͕ଘࡏ͢Δঢ়گΛԾఆ͢Δ
  10. ґଘؔ܎͕͋Δ • ґଘؔ܎͸ ϑϩϯτΤϯυ => όοΫΤϯυ • όοΫΤϯυ͕ఏڙ͢Δ API Λ


    ϑϩϯτΤϯυ͕ར༻͢Δ • ૉ௚ʹߟ͑ΔͱɺόοΫΤϯυ => ϑϩϯτΤϯυͷॱͰ։ൃ ͢Δ͜ͱʹͳΔ => ޮ཰͕ѱ͍ (࣍ϖʔδ͔Βઆ໌)
  11. (1) ϑϩʔޮ཰͕ѱ͍ • όοΫΤϯυͰ࣮૷͞Εͨػೳ͕ɺ σϓϩΠ͞ΕΔ·Ͱʹ
 ଴͕ͪ࣌ؒͰ͖Δ

  12. (2) Ϧιʔεޮ཰͕ѱ͍ • ϑϩϯτΤϯδχΞ͕࣮૷଴ͪͷؒɺՋʹͳͬͯ͠·͏

  13. (2) Ϧιʔεޮ཰͕ѱ͍ • ෳ਺ͷػೳΛॱʹճ͢͜ͱͰվળՄೳ • ͕ɺݱ࣮ʹ͸͜Μͳʹ៉ྷʹ͸͍͔ͳ͍ • όοΫΤϯυͷ࣮૷͕গ͠Ͱ΋஗ΕΔͱɺϑϩϯτΤϯυͷՋ͕ൃੜͯ͠͠·͏

  14. ͦ͜Ͱ εΩʔϚۦಈ։ൃ

  15. εΩʔϚۦಈ։ൃ • ͸͡Ίʹ API ͷεΩʔϚΛఆΊɺ
 ϑϩϯτΤϯυ - όοΫΤϯυ ؒͰ߹ҙ͢Δ •

    ϑϩϯτΤϯυ͸ɺόοΫΤϯυͷ API ͷ࣮૷Λ଴ͨͣʹ
 API εΩʔϚΛར༻࣮ͯ͠૷։࢝͢Δ • ΫϥΠΞϯτ্Ͱͷ੩తܕɺϞοΫαʔόʔͳͲ͕ಘΒΕɺ
 ͋Δఔ౓͸ෆ౎߹ͳ͘։ൃͰ͖Δ
  16. εΩʔϚۦಈ։ൃͱ։ൃޮ཰ • (1) ϑϩʔޮ཰΁ͷد༩ • (2) Ϧιʔεޮ཰΁ͷد༩

  17. (1) ϑϩʔޮ཰΁ͷد༩ • όοΫΤϯυͱϑϩϯτΤϯυ͕ฒྻͰ։ൃͰ͖ΔͷͰɺ
 ϑϩϯτΤϯυͷ଴ͪ࣌ؒΛͳͤ͘Δ

  18. (2) Ϧιʔεޮ཰΁ͷد༩ • όοΫΤϯυͱϑϩϯτΤϯυͷ։ൃͷґଘؔ܎Λͳͤ͘ΔͷͰɺ
 ͦΕͧΕͷ։ൃͷॱং͕ࣗ༝ʹͳΔ • ݁Ռͱͯ͠ɺϦιʔεޮ཰Λ௥͍ٻΊΔ͜ͱ͕ՄೳʹͳΔ

  19. ελσΟαϓϦʹ͓͚Δ GraphQLɾεΩʔϚۦಈ։ൃͷ ࣮ફࣄྫ

  20. None
  21. ৽ن։ൃϓϩδΣΫτʹ͍ͭͯ • ։ൃ͢Δ΋ͷ • iOS / Android / PC Web

    Apps • Backend APIs • ίϯςϯπΛ؅ཧ͢ΔγεςϜ • ։ൃظؒ: > 1೥ • ։ൃऀͷਓ਺: > 10ਓ
  22. ৽ن։ൃʹ GraphQL Λશ໘࠾༻ • client => gateway => backends
 શମͰ

    GraphQL Λ࠾༻ • gateway ͸ schema stitching Λར༻͍ͯ͠Δ • ͦͷଞར༻ٕज़ • Ruby on Rails • Node.js + TypeScript + Apollo Server + Prisma 2 • React, Apollo Client
  23. εΩʔϚۦಈ։ൃͷԸܙ • ίϛϡχέʔγϣϯͷϩε͕গͳ͘ɺ
 ҆ఆͯ͠։ൃΛਐΊΒΕͨ • Ϧιʔεޮ཰ΛٻΊɺ
 backend / frontend ͦΕͧΕ

    ~9ϲ݄ؒ
 ಠཱͯ͠։ൃͨ͠ • ܨ͗͜Έ΋௒εϜʔζ • 1िؒͰશ෦ܨ͗͜Έ׬ྃͨ͠
  24. εΩʔϚۦಈ։ൃʹ GraphQL Λར༻͢ΔϝϦοτ • εΩʔϚͱ࣮૷͕ဃ཭͠΍͍͢ͱɺܨ͗͜Έ࣌ʹൃ֮͢Δ໰୊͕૿͑ɺ࣌ؒ ͕͔͔Δ (=ޮ཰͕Լ͕Δ) • GraphQL Λར༻͢ΔͱɺαʔόʔɾΫϥΠΞϯτ૒ํͰ


    εΩʔϚͱ࣮૷ͷဃ཭͕ى͖ʹ͍͘ • αʔόʔ: εΩʔϚΛຬͨ͞ͳ͍ϨεϙϯεΛฦͦ͏ͱ͢ΔͱΤϥʔʹͳΔ • ΫϥΠΞϯτ: ੩తܕΛࣗಈੜ੒͠ɺར༻Ͱ͖Δ
  25. ฐνʔϜʹ͓͚Δ GraphQL εΩʔϚۦಈ։ൃͷϑϩʔ • εΩʔϚ͸࠷ऴతʹ GraphQL Gateway ʹఆٛ͞ΕΔɻ
 ͜Ε͸֤ Backend

    Service ʹఆٛ͞Εͨ΋ͷ͕ू໿͞Ε͍ͯΔ • ϑϩϯτΤϯυओಋͰεΩʔϚΛॻ͘ͱ͖͸
 Ұ୴ GraphQL Gateway αʔϏεʹ௚઀ॻ͘ • ϞοΫαʔόʔͱͯ͠ఏڙͰ͖Δ • ࣮૷࣌ʹɺεΩʔϚఆٛΛ֤όοΫΤϯυαʔϏεʹҠಈ͢Δ • ※ ͜ͷ෦෼Ͱͪΐͬͱͨ͠೰Έ͋Γ (ӈͷπΠʔτ)
  26. Q. ୭͕εΩʔϚΛॻ͘΂͖͔? • A. ͦͷػೳͷಛੑʹΑΔ • ࠷ऴతʹ߹ҙͰ͖Ε͹Α͍ɻ୭͕ॻ͍ͯ΋Α͍ • ϑϩϯτΤϯυΤϯδχΞ΍ϓϩμΫτϚωʔδϟʔ͕εΩʔϚΛॻ͚Δͱɺ
 ϑϩʔޮ཰Խʹͭͳ͕Δ

    • ։ൃͷग़ൃ఺Ͱ͋Δʮཁٻʯʹ͍ۙ • όοΫΤϯυ࣮૷͕೉͍͠ػೳ͸ɺόοΫΤϯυΤϯδχΞ͕ఆٛͨ͠΄͏͕ྑ͍ • ࣮૷Ͱ͖ͳ͍εΩʔϚʹ͸ҙຯ͕ͳ͍ͨΊ
  27. Q. ୭͕εΩʔϚΛॻ͘΂͖͔? • εΩʔϚઃܭʹ͸ίπ͕͋Γɺ୭͕ॻ͘ʹͯ͠΋ମಘ͢Δඞཁ͕͋Δ • ը໘࢓༷ͱDBઃܭͷؒʹ͋ΔʮϦιʔεʯΛ͏·͘ଊ͑Δ • GraphQL ͷ৔߹͸ͦΕΛ GraphQL

    Type ͱͯ͠දݱ͢Δ • ͭ·ΓɺϑϩϯτΤϯυΤϯδχΞͰ͋Ε͹DBઃܭΛΠϝʔδ͠ɺ
 όοΫΤϯυΤϯδχΞͰ͋Ε͹ը໘࣮૷ΛΠϝʔδͰ͖Δͱ͏·͘ ͍͖΍͍͢
  28. ·ͱΊ • εΩʔϚۦಈ։ൃΛ࣮ફ͢Δ͜ͱͰɺ
 Ϧιʔεޮ཰·ͨ͸ϑϩʔޮ཰ΛߴΊΔ͜ͱ͕Ͱ͖Δ • GraphQL Λར༻͢Δͱɺͭͳ͗͜Έͷਫ਼౓΋ඇৗʹߴ͍ • εΩʔϚ͸୭͕ॻ͍ͯ΋Α͍ɻ
 ର৅ػೳͷಛੑ΍ɺνʔϜͷঢ়گͳͲʹΑͬͯม͑ΔͱΑ͍

  29. We're hiring! • GraphQL, Microservices ͸΋ͪΖΜ
 ϑϩϯτΤϯυ͔ΒόοΫΤϯυ·Ͱ
 ޿͍ٕज़ʹ৮ΕΒΕΔػձ͋Γ • ·ͣ͸ΧδϡΞϧ໘ஊ͔Βɺͥͻ͝Ԡื͍ͩ͘͞

    😁