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
Amazon Bedrock AgentCore でプロモーション用動画生成エージェントを開発する
nasuvitz
6
430
Backboneとしてのtimm2025
yu4u
4
1.5k
ABEMAにおける 生成AI活用の現在地 / The Current Status of Generative AI at ABEMA
dekatotoro
0
660
Goss: Faiss向けの新しい本番環境対応 Goバインディング #coefl_go_jp
bengo4com
0
1.4k
広島発!スタートアップ開発の裏側
tsankyo
0
240
VPC Latticeのサービスエンドポイント機能を使用した複数VPCアクセス
duelist2020jp
0
240
7月のガバクラ利用料が高かったので調べてみた
techniczna
3
440
[CV勉強会@関東 CVPR2025 読み会] MegaSaM: Accurate, Fast, and Robust Structure and Motion from Casual Dynamic Videos (Li+, CVPR2025)
abemii
0
190
現場が抱える様々な問題は “組織設計上” の問題によって生じていることがある / Team-oriented Organization Design 20250827
mtx2s
5
1.1k
認知戦の理解と、市民としての対抗策
hogehuga
0
360
モダンフロントエンド 開発研修
recruitengineers
PRO
3
350
AIエージェントの開発に必須な「コンテキスト・エンジニアリング」とは何か──プロンプト・エンジニアリングとの違いを手がかりに考える
masayamoriofficial
0
390
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Git: the NoSQL Database
bkeepers
PRO
431
65k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3k
Scaling GitHub
holman
462
140k
Designing Experiences People Love
moore
142
24k
A Modern Web Designer's Workflow
chriscoyier
695
190k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
jQuery: Nuts, Bolts and Bling
dougneiner
64
7.9k
Mobile First: as difficult as doing things right
swwweet
223
9.9k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.6k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
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