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.7k
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
サービスでLLMを採用したばっかりに振り回され続けたこの一年のあれやこれや
segavvy
2
390
20241220_S3 tablesの使い方を検証してみた
handy
3
360
2024年にチャレンジしたことを振り返るぞ
mitchan
0
130
バクラクのドキュメント解析技術と実データにおける課題 / layerx-ccc-winter-2024
shimacos
2
1.1k
サーバレスアプリ開発者向けアップデートをキャッチアップしてきた #AWSreInvent #regrowth_fuk
drumnistnakano
0
190
開発生産性向上! 育成を「改善」と捉えるエンジニア育成戦略
shoota
1
290
.NET 9 のパフォーマンス改善
nenonaninu
0
780
alecthomas/kong はいいぞ / kamakura.go#7
fujiwara3
1
300
kargoの魅力について伝える
magisystem0408
0
200
生成AIのガバナンスの全体像と現実解
fnifni
1
180
サイバー攻撃を想定したセキュリティガイドライン 策定とASM及びCNAPPの活用方法
syoshie
3
1.2k
Amazon SageMaker Unified Studio(Preview)、Lakehouse と Amazon S3 Tables
ishikawa_satoru
0
150
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
BBQ
matthewcrist
85
9.4k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
510
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Into the Great Unknown - MozCon
thekraken
33
1.5k
It's Worth the Effort
3n
183
28k
Site-Speed That Sticks
csswizardry
2
190
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.1k
Visualization
eitanlees
146
15k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
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