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
GraphQL GatewayをNode.jsで作ってる話
Search
Haruhiko Kobayashi
December 07, 2018
Technology
2
1.8k
GraphQL GatewayをNode.jsで作ってる話
Haruhiko Kobayashi
December 07, 2018
Tweet
Share
More Decks by Haruhiko Kobayashi
See All by Haruhiko Kobayashi
スペースマーケットのアーキテクチャ変遷
hmatsuda
0
2.3k
Other Decks in Technology
See All in Technology
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
12
81k
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
3
20k
Data Hubグループ 紹介資料
sansan33
PRO
0
2.2k
能登半島地震において デジタルができたこと・できなかったこと
ditccsugii
0
250
やる気のない自分との向き合い方/How to Deal with Your Unmotivated Self
sanogemaru
1
520
Wasmの気になる最新情報
askua
0
130
速習AGENTS.md:5分で精度を上げる "3ブロック" テンプレ
ismk
6
1.8k
Introdução a Service Mesh usando o Istio
aeciopires
0
210
「改善」ってこれでいいんだっけ?
ukigmo_hiro
0
340
CoRL 2025 Survey
harukiabe
1
220
Node.js 2025: What's new and what's next
ruyadorno
0
420
LLMアプリの地上戦開発計画と運用実践 / 2025.10.15 GPU UNITE 2025
smiyawaki0820
1
640
Featured
See All Featured
Building Adaptive Systems
keathley
44
2.8k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.9k
Thoughts on Productivity
jonyablonski
70
4.9k
Speed Design
sergeychernyshev
32
1.2k
The Pragmatic Product Professional
lauravandoore
36
6.9k
How to Ace a Technical Interview
jacobian
280
24k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Typedesign – Prime Four
hannesfritz
42
2.8k
Context Engineering - Making Every Token Count
addyosmani
7
260
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.2k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
Transcript
GraphQL GatewayΛ Node.jsͰ࡞ͬͯΔ haruhiko kobayashi 2018/12/6
!2 ࣗݾհ Haruhiko Kobayashi Chief Tech Lead εϖʔεϚʔέοτ yahooͷόοΫΤϯυΤϯδχΞ ग़Ͱ͢ɻϑϩϯτΤϯυͱΠϯ
ϑϥҰ௨Γ͔ͬͨ͡ͷͪʹεϖʔ εϚʔέοτʹJoin
!3 Agenda
!4 Agenda • GraphQLͷ͝հ • MicroservicesͱͷΈ߹Θͤ • GraphQL Gateway on
Node.js
GraphQLͷ͝հ
!6 GraphQLͷ͝հ • Facebook͕ఏএͨ͠API༷ • ڧ͍ܕγεςϜ • ࢀরܥquery • ߋ৽ܥmutation
• RESTͱରൺͯ͠ޠΒΕΔࣄ͕ଟ͍ جຊతͳ
!7 GraphQLͷ͝հ • Partial Response • Batch Request • graphdoc
• Graphiql σϑΥϧτػೳ
!8 Partial Response ࢦఆͨ͠σʔλͷΈऔಘ
!9 Batch Request 1ͷAPIίʔϧͰෳͷϦιʔεΛऔಘՄೳ
!10 graphdoc GraphQL API͔ΒυΩϡϝϯτࣗಈੜ
!11 graphdoc GraphQL API͔ΒυΩϡϝϯτࣗಈੜ confidential
!12 GraphiQL GraphQLͷΫΤϦ࣮ߦڥ
!13 ಋೖ࣌ظ 2017ࠒ͔Β෦తʹಋೖ • Client: Apollo Client • Server: Rails
RESTͱൺͨ։ൃମݧ • FEɾΞϓϦ։ൃऀ͔Β૬ָʹͳͬͨͱ͍͏ • BEͱͯ͠ແବͳϖΠϩʔυݮͳͲϝϦοτଟ͍
MicroservicesͱͷΈ߹Θͤ
!15 MicroservicesͱͷΈ߹Θͤ • ݕࡧαʔϏε • ΞΧϯταʔϏε • ϦίϝϯυαʔϏε • etc..
ڊେͳREST API͔ΒGraphQLαʔϏεΛΓग़͠த
!16 MicroservicesͱͷΈ߹Θͤ API͕ଟ͗ͯ͢frontendͷਏΈ͕༧͞ΕΔ ݕࡧ (GraphQL) Ϩίϝϯυ (REST) ΞΧϯτ (GraphQL) ༧
(REST) FE
!17 MicroservicesͱͷΈ߹Θͤ GraphQL GatewayΛrubyͰ࡞ͬͨ ݕࡧ (GraphQL) Ϩίϝϯυ (REST) ΞΧϯτ (GraphQL)
༧ (REST) FE gateway
!18 MicroservicesͱͷΈ߹Θͤ GatewayremoteͷAPIʹϦΫΤετͯ݁͠ՌΛฦ͢
!19 MicroservicesͱͷΈ߹Θͤ resolverͰผAPIΛୟ͘ confidential
!20 MicroservicesͱͷΈ߹Θͤ resolverͰผAPIΛୟ͘
!21 MicroservicesͱͷΈ߹Θͤ ՝1: GraphQLͷܕΤϥʔʹͳΔ confidential • GraphQLఆٛ͞Ε͍ͯͳ͍ܕ͕ΫΤϦʹؚ·ΕΔͱΤϥʔ ʹͳΔ
!22 MicroservicesͱͷΈ߹Θͤ ՝1: GraphQLͷܕΤϥʔʹͳΔ • GraphQLͷΫΤϦΛղੳͯ͠༨ܭͳͷΛফ͢ॲཧΛॻ͍ͯ ରԠ
!23 MicroservicesͱͷΈ߹Θͤ ՝2: Blocking IO confidential • rubyBlocking IO͕ඪ४ͷͨΊΫΤϦ͕૿͑ΔͱͲΜͲΜ ͘ͳΔ
!24 MicroservicesͱͷΈ߹Θͤ ՝2: Blocking IO • ΫΤϦͷ࣮ߦΛԆධՁͯ͠1ͭͷΫΤϦʹ·ͱΊ࣮ͯߦ • graphql-batchͱ͍͏ϥΠϒϥϦͰରԠՄೳ
!25 MicroservicesͱͷΈ߹Θͤ ՝2: Blocking IO • ̎ͭͷϦΫΤετΛԆධՁͤͯ͞1ͭͷϦΫΤετʹ߹
!26 MicroservicesͱͷΈ߹Θͤ ՝2: Blocking IO confidential • ̎ͭͷϦΫΤετΛԆධՁͤͯ͞1ͭͷϦΫΤετʹ߹
!27 MicroservicesͱͷΈ߹Θͤ ͜͜·Ͱͷ·ͱΊ • ৭ʑ͕Μ͕ͬͨෳAPIΤϯυϙΠϯτͱͳΔͱॲཧ͕ṫ ࡶʹͳΔ • rubyͷಛੑGraphQL Gatewayʹ͍ͯͳͦ͞͏ •
Node.jsͷҠ২Λݕ౼͠͡ΊΔ
GraphQL Gateway on Node.js
!29 Apollo Server Node.jsͷGraphQL Server࣮ • jsͰGraphQL API࡞ΔʹσϑΝΫτελϯμʔυ • Gatewayͱͯ͠ಈ͘ػೳఏڙ͍ͯ͠Δ
• (ਖ਼֬ʹgraphql-toolsύοέʔδʹ)
!30 ՝1: GraphQLͷܕΤϥʔʹͳΔ ղܾࡦ: Schema Stitching • remoteͷGraphQL APIΛ͔͋ͨlocalͷGraphQL APIͱͯ͠
ѻ͏ػೳͷ͜ͱ
!31 Schema Stitching ͭ·Γ͜Εͷ͜ͱͰ͢ ݕࡧ (GraphQL) Ϩίϝϯυ (REST) ΞΧϯτ (GraphQL)
༧ (REST) FE gateway
!32 ՝1: GraphQLͷܕΤϥʔʹͳΔ ղܾ: Schema Stitching confidential • remoteͷGraphQL APIΛlocalͷGraphQL
APIͱͯ͠ѻ͏
!33 ՝1: GraphQLͷܕΤϥʔʹͳΔ ղܾ: Schema Stitching • 1ͭͷqueryΛผͷAPI͔ΒऔಘͰ͖ΔΑ͏ʹͳΔ
!34 ՝1: GraphQLͷܕΤϥʔʹͳΔ ղܾ: Schema Stitching • rubyͰؤுͬͯ࡞࣮͕ͬͨ20ߦ΄Ͳͷ࣮ͰղܾͰ͖ͨ • શʹٕज़࠾ͷࣦഊ..
!35 ՝2: Blocking IO ղܾ:NodeͷಛੑΛੜ͔ͯ͠Non-Blocking IOͰ௨৴ͯ͘͠ΕΔ confidential
!36 ՝2: Blocking IO ղܾ:NodeͷಛੑΛੜ͔ͯ͠Non-Blocking IOͰ௨৴ͯ͘͠ΕΔ
·ͱΊ
!38 • ݴޠͷಛੑΛݟۃΊͯϛυϧΣΞઃܭ͖͢ • GraphQL GatewayελοΫjavascriptͰ࣮
None