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

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

qsona
September 08, 2021

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

MIDAS TECH STUDY #2

qsona

September 08, 2021
Tweet

More Decks by qsona

Other Decks in Technology

Transcript

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

    Microservices / Rails / Node.js / GraphQL
  2. ґଘؔ܎͕͋Δ • ґଘؔ܎͸ ϑϩϯτΤϯυ => όοΫΤϯυ • όοΫΤϯυ͕ఏڙ͢Δ API Λ


    ϑϩϯτΤϯυ͕ར༻͢Δ • ૉ௚ʹߟ͑ΔͱɺόοΫΤϯυ => ϑϩϯτΤϯυͷॱͰ։ൃ ͢Δ͜ͱʹͳΔ => ޮ཰͕ѱ͍ (࣍ϖʔδ͔Βઆ໌)
  3. εΩʔϚۦಈ։ൃ • ͸͡Ίʹ API ͷεΩʔϚΛఆΊɺ
 ϑϩϯτΤϯυ - όοΫΤϯυ ؒͰ߹ҙ͢Δ •

    ϑϩϯτΤϯυ͸ɺόοΫΤϯυͷ API ͷ࣮૷Λ଴ͨͣʹ
 API εΩʔϚΛར༻࣮ͯ͠૷։࢝͢Δ • ΫϥΠΞϯτ্Ͱͷ੩తܕɺϞοΫαʔόʔͳͲ͕ಘΒΕɺ
 ͋Δఔ౓͸ෆ౎߹ͳ͘։ൃͰ͖Δ
  4. ৽ن։ൃϓϩδΣΫτʹ͍ͭͯ • ։ൃ͢Δ΋ͷ • iOS / Android / PC Web

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

    GraphQL Λ࠾༻ • gateway ͸ schema stitching Λར༻͍ͯ͠Δ • ͦͷଞར༻ٕज़ • Ruby on Rails • Node.js + TypeScript + Apollo Server + Prisma 2 • React, Apollo Client
  6. εΩʔϚۦಈ։ൃʹ GraphQL Λར༻͢ΔϝϦοτ • εΩʔϚͱ࣮૷͕ဃ཭͠΍͍͢ͱɺܨ͗͜Έ࣌ʹൃ֮͢Δ໰୊͕૿͑ɺ࣌ؒ ͕͔͔Δ (=ޮ཰͕Լ͕Δ) • GraphQL Λར༻͢ΔͱɺαʔόʔɾΫϥΠΞϯτ૒ํͰ


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

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

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

    Type ͱͯ͠දݱ͢Δ • ͭ·ΓɺϑϩϯτΤϯυΤϯδχΞͰ͋Ε͹DBઃܭΛΠϝʔδ͠ɺ
 όοΫΤϯυΤϯδχΞͰ͋Ε͹ը໘࣮૷ΛΠϝʔδͰ͖Δͱ͏·͘ ͍͖΍͍͢