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
20年続いているサービスの複雑な注文画面を GraphQL を使って改善した話
Search
株式会社出前館
October 27, 2022
Technology
1
400
20年続いているサービスの複雑な注文画面を GraphQL を使って改善した話
株式会社出前館
October 27, 2022
Tweet
Share
More Decks by 株式会社出前館
See All by 株式会社出前館
出前館アプリにおけるFlutterアプリ設計とそれを支えるCICD環境の進化
demaecan
0
550
出前館のマルチプロダクト戦略を支えるアーキテクチャ 〜技術的負債を解消しながら事業を多角化する〜
demaecan
1
120
新卒1年目の自分に伝えたかったエンジニアの成長に役に立つ話
demaecan
0
1.7k
新卒エンジニアが0からNon-BlockingなgPRCサーバーを作った話
demaecan
1
450
出前館におけるFlutter活用事例
demaecan
0
460
出前館アプリにおける Flutterアプリ設計
demaecan
2
860
プロダクト本部紹介資料
demaecan
0
9.4k
処理性能向上とコスト最適化を実現! ハイブリッド/マルチクラウド構成へ移行しサービス需要の急拡大に対応する強力なシステム基盤を実現
demaecan
0
110
出前館におけるFlutterの現在とこれから
demaecan
0
1.2k
Other Decks in Technology
See All in Technology
【詳説】コンテンツ配信 システムの複数機能 基盤への拡張
hatena
0
290
EDRの検知の仕組みと検知回避について
chayakonanaika
12
5.2k
フォーイット_エンジニア向け会社紹介資料_Forit_Company_Profile.pdf
forit_tech
1
1.7k
ディスプレイ広告(Yahoo!広告・LINE広告)におけるバックエンド開発
lycorptech_jp
PRO
0
540
マルチアカウント環境における組織ポリシーについて まとめてみる
nrinetcom
PRO
2
100
Autonomous Database Serverless 技術詳細 / adb-s_technical_detail_jp
oracle4engineer
PRO
17
46k
どちらかだけじゃもったいないかも? ECSとEKSを適材適所で併用するメリット、運用課題とそれらの対応について
tk3fftk
2
260
事業モメンタムを生み出すプロダクト開発
macchiitaka
0
100
Change Managerを活用して本番環境へのセキュアなGUIアクセスを統制する / Control Secure GUI Access to the Production Environment with Change Manager
yuj1osm
0
110
Introduction to OpenSearch Project - Search Engineering Tech Talk 2025 Winter
tkykenmt
2
180
ABWG2024採択者が語るエンジニアとしての自分自身の見つけ方〜発信して、つながって、世界を広げていく〜
maimyyym
1
200
E2Eテスト自動化入門
devops_vtj
1
110
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.4k
Automating Front-end Workflow
addyosmani
1369
200k
Rails Girls Zürich Keynote
gr2m
94
13k
Practical Orchestrator
shlominoach
186
10k
Into the Great Unknown - MozCon
thekraken
35
1.6k
Gamification - CAS2011
davidbonilla
80
5.2k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
193
16k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
10
530
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
100
18k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7.1k
Transcript
20年続いているサービスの 複雑な注文画面を GraphQLを使って改善した話 株式会社出前館・橋本茉利奈
橋本茉利奈 Hashimoto Marina 株式会社出前館 モバイルアプリエンジニア
None
出前館アプリ
注文画面
None
お届け時間
お届け時間 決済方法
お届け時間 決済方法 クーポン利用
お届け時間 決済方法 クーポン利用 LINEポイント
お届け時間 決済方法 クーポン利用 LINEポイント 特典の付与
お届け時間 決済方法 クーポン利用 LINEポイント 特典の付与 料金の再計算
お届け時間 決済方法 クーポン利用 LINEポイント 特典の付与 料金の再計算 めっちゃ切り替わる…😵
状態管理が大変…😵
状態管理が大変…😵 • 画面内に状態を管理しなければいけない要素が多い • 増え続ける決済パターン • ユーザ操作によって切り替わる注文情報 • ユーザへの許諾チェックボックスの表示制御 …etc
どうする…🤔
とにかくシンプルを目指す
RecoilをState管理に使ってみた • ねらい:State管理をできるだけシンプルにする • 要素をできるだけ細かく分解して管理する • Stateをどこからでも呼び出せる
screen RecoilをState管理に使ってみた Recoil Server user input item info amount coupon
delivery type LINE point order type terms agreement isEnabled receipt address phone number payment method
screen RecoilをState管理に使ってみた Recoil Server user input item info amount coupon
delivery type LINE point order type terms agreement isEnabled receipt address phone number payment method
screen RecoilをState管理に使ってみた Recoil Server user input item info amount coupon
delivery type LINE point order type terms agreement isEnabled receipt address phone number payment method 依存関係が多すぎる…😵
screen RecoilをState管理に使ってみた Recoil Server user input item info amount coupon
delivery type LINE point order type terms agreement isEnabled receipt address phone number payment method
screen RecoilをState管理に使ってみた Recoil Server user input item info amount coupon
delivery type LINE point order type terms agreement isEnabled receipt address phone number payment method
screen RecoilをState管理に使ってみた Recoil Server user input item info amount coupon
delivery type LINE point order type terms agreement isEnabled receipt address phone number payment method 頻繁に更新される…😵
screen RecoilをState管理に使ってみた Recoil Server user input item info amount coupon
delivery type LINE point order type terms agreement isEnabled receipt address phone number payment method かえって複雑に…😵
どうする…🤔
状態を2種類にわける
Server Cache / Local State
Server Cache • サーバの情報を保持するキャッシュ • サーバとクライアントの情報の一致が常に保証されている • キャッシュの値がコンポーネントへリアクティブに作用する
Local State • クライアントでのユーザ操作による情報を管理するState • クライアントのみで一時的に保持している値を管理
screen Server Cache / Local State Server user input Server
Cache Local State
注文画面で実装する💪
注文画面で実装する💪 • Server Cache → Apollo Client のキャッシュを使う • Local
State → React useState を使う
screen 注文画面で実装する💪 Apollo Server (BFF) user input Apollo Client Cache
useState
注文画面で実装する💪 • Server Cache → Apollo Client のキャッシュを使う • Local
State → React useState を使う
Server Cache→ apollo client のキャッシュを使う • BFFのレスポンス情報自体を、Server Cacheとして保持する • BFF
(GraphQL) によって、1画面描画のためのリクエストが1回で 済むのでServer Cacheの状態管理が容易 • BFFのスキーマで型定義できる
注文画面で実装する💪 • Server Cache → Apollo Clientのキャッシュを使う • Local State
→ React useState を使う
Local State → React useState を使う • Server Cacheのおかげで、Localで独自に定義するStateを減らすこと ができる
screen Before... Recoil Server user input item info amount coupon
delivery type LINE point order type terms agreement isEnabled receipt address phone number payment method
screen After... Apollo Server (BFF) user input Apollo Client Cache
useState isEnabled address payment method
まとめ
まとめ • 注文画面は、出前館アプリの中でも状態管理が大変な画面のひとつ • まずRecoilで管理する方法を試したものの、膨大な量のStateを管 理しなければならず、大変なことに...
まとめ • そこで、画面で管理するStateをSever CacheとLocal Stateの2種類に 分類して管理することにした
まとめ • Server Cacheとして, Apollo Client のキャッシュを活用することで 、型安全で、かつシンプルにサーバ情報を保持できるようになった
まとめ • Server Cacheがあるおかげで、ユーザ操作によって更新がかかる StateのみをLocal Stateで管理すれば良くなった
None