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
まずはマネコンでちゃちゃっと作ってから、それをCDKにしてみよか。
yamada_r
2
120
Unlocking the Power of AI Agents with LINE Bot MCP Server
linedevth
0
120
株式会社ログラス - 会社説明資料【エンジニア】/ Loglass Engineer
loglass2019
4
65k
OCI Oracle Database Services新機能アップデート(2025/06-2025/08)
oracle4engineer
PRO
0
180
テストを軸にした生き残り術
kworkdev
PRO
0
220
Django's GeneratedField by example - DjangoCon US 2025
pauloxnet
0
160
AI時代を生き抜くエンジニアキャリアの築き方 (AI-Native 時代、エンジニアという道は 「最大の挑戦の場」となる) / Building an Engineering Career to Thrive in the Age of AI (In the AI-Native Era, the Path of Engineering Becomes the Ultimate Arena of Challenge)
jeongjaesoon
0
260
Autonomous Database - Dedicated 技術詳細 / adb-d_technical_detail_jp
oracle4engineer
PRO
4
10k
なぜテストマネージャの視点が 必要なのか? 〜 一歩先へ進むために 〜
moritamasami
0
240
Terraformで構築する セルフサービス型データプラットフォーム / terraform-self-service-data-platform
pei0804
1
200
Bedrock で検索エージェントを再現しようとした話
ny7760
1
110
下手な強制、ダメ!絶対! 「ガードレール」を「檻」にさせない"ガバナンス"の取り方とは?
tsukaman
2
460
Featured
See All Featured
It's Worth the Effort
3n
187
28k
A designer walks into a library…
pauljervisheath
207
24k
The Straight Up "How To Draw Better" Workshop
denniskardys
236
140k
Building Better People: How to give real-time feedback that sticks.
wjessup
368
19k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
139
34k
Designing for Performance
lara
610
69k
The Cost Of JavaScript in 2023
addyosmani
53
8.9k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.5k
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