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.6k
GraphQL GatewayをNode.jsで作ってる話
Haruhiko Kobayashi
December 07, 2018
Tweet
Share
More Decks by Haruhiko Kobayashi
See All by Haruhiko Kobayashi
スペースマーケットのアーキテクチャ変遷
hmatsuda
0
2.2k
Other Decks in Technology
See All in Technology
Amazon Personalizeのレコメンドシステム構築、実際何するの?〜大体10分で具体的なイメージをつかむ〜
kniino
1
100
RubyのWebアプリケーションを50倍速くする方法 / How to Make a Ruby Web Application 50 Times Faster
hogelog
3
940
CysharpのOSS群から見るModern C#の現在地
neuecc
1
3.1k
いざ、BSC討伐の旅
nikinusu
2
780
第1回 国土交通省 データコンペ参加者向け勉強会③- Snowflake x estie編 -
estie
0
120
Lambdaと地方とコミュニティ
miu_crescent
2
370
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
370
適材適所の技術選定 〜GraphQL・REST API・tRPC〜 / Optimal Technology Selection
kakehashi
1
160
The Role of Developer Relations in AI Product Success.
giftojabu1
0
120
フルカイテン株式会社 採用資料
fullkaiten
0
40k
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
430
Lambda10周年!Lambdaは何をもたらしたか
smt7174
2
110
Featured
See All Featured
Six Lessons from altMBA
skipperchong
27
3.5k
For a Future-Friendly Web
brad_frost
175
9.4k
Building Adaptive Systems
keathley
38
2.3k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
Why Our Code Smells
bkeepers
PRO
334
57k
Designing for humans not robots
tammielis
250
25k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
The Pragmatic Product Professional
lauravandoore
31
6.3k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
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