SlideShare a Scribd company logo
1 of 46
Download to read offline
20年続いているサービスの
複雑な注文画面を
GraphQLを使って改善した話
株式会社出前館・橋本茉利奈
橋本茉利奈
Hashimoto Marina
株式会社出前館
モバイルアプリエンジニア
出前館アプリ
注文画面
お届け時間
お届け時間
決済方法
お届け時間
決済方法
クーポン利用
お届け時間
決済方法
クーポン利用
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で管理すれば良くなった
20年続いているサービスの複雑な注文画面を GraphQL を使って改善した話

More Related Content

What's hot

ドメイン駆動設計 ( DDD ) をやってみよう
ドメイン駆動設計 ( DDD ) をやってみようドメイン駆動設計 ( DDD ) をやってみよう
ドメイン駆動設計 ( DDD ) をやってみよう増田 亨
 
C#×LLVM=アセンブラ!? 〜詳説・Burstコンパイラー〜
C#×LLVM=アセンブラ!? 〜詳説・Burstコンパイラー〜C#×LLVM=アセンブラ!? 〜詳説・Burstコンパイラー〜
C#×LLVM=アセンブラ!? 〜詳説・Burstコンパイラー〜UnityTechnologiesJapan002
 
【DL輪読会】The Forward-Forward Algorithm: Some Preliminary
【DL輪読会】The Forward-Forward Algorithm: Some Preliminary【DL輪読会】The Forward-Forward Algorithm: Some Preliminary
【DL輪読会】The Forward-Forward Algorithm: Some PreliminaryDeep Learning JP
 
2015年度先端GPGPUシミュレーション工学特論 第11回 数値流体力学への応用 (支配方程式,CPUプログラム)
2015年度先端GPGPUシミュレーション工学特論 第11回 数値流体力学への応用(支配方程式,CPUプログラム)2015年度先端GPGPUシミュレーション工学特論 第11回 数値流体力学への応用(支配方程式,CPUプログラム)
2015年度先端GPGPUシミュレーション工学特論 第11回 数値流体力学への応用 (支配方程式,CPUプログラム)智啓 出川
 
VoxFormer: Sparse Voxel Transformer for Camera-based 3D Semantic Scene Comple...
VoxFormer: Sparse Voxel Transformer for Camera-based 3D Semantic Scene Comple...VoxFormer: Sparse Voxel Transformer for Camera-based 3D Semantic Scene Comple...
VoxFormer: Sparse Voxel Transformer for Camera-based 3D Semantic Scene Comple...Kazuyuki Miyazawa
 
分散型IDと検証可能なアイデンティティ技術概要
分散型IDと検証可能なアイデンティティ技術概要分散型IDと検証可能なアイデンティティ技術概要
分散型IDと検証可能なアイデンティティ技術概要Naohiro Fujie
 
TorchDataチュートリアル解説
TorchDataチュートリアル解説TorchDataチュートリアル解説
TorchDataチュートリアル解説西岡 賢一郎
 
Modern Authentication -- FIDO2 Web Authentication (WebAuthn) を学ぶ --
Modern Authentication -- FIDO2 Web Authentication (WebAuthn) を学ぶ --Modern Authentication -- FIDO2 Web Authentication (WebAuthn) を学ぶ --
Modern Authentication -- FIDO2 Web Authentication (WebAuthn) を学ぶ --Jun Kurihara
 
[DL Hacks]Simple Online Realtime Tracking with a Deep Association Metric
[DL Hacks]Simple Online Realtime Tracking with a Deep Association Metric[DL Hacks]Simple Online Realtime Tracking with a Deep Association Metric
[DL Hacks]Simple Online Realtime Tracking with a Deep Association MetricDeep Learning JP
 
画像認識の初歩、SIFT,SURF特徴量
画像認識の初歩、SIFT,SURF特徴量画像認識の初歩、SIFT,SURF特徴量
画像認識の初歩、SIFT,SURF特徴量takaya imai
 
【DL輪読会】Is Conditional Generative Modeling All You Need For Decision-Making?
【DL輪読会】Is Conditional Generative Modeling All You Need For Decision-Making?【DL輪読会】Is Conditional Generative Modeling All You Need For Decision-Making?
【DL輪読会】Is Conditional Generative Modeling All You Need For Decision-Making?Deep Learning JP
 
【DL輪読会】Implicit Behavioral Cloning
【DL輪読会】Implicit Behavioral Cloning【DL輪読会】Implicit Behavioral Cloning
【DL輪読会】Implicit Behavioral CloningDeep Learning JP
 
プログラミング勉強会「オトナのGit入門」
プログラミング勉強会「オトナのGit入門」プログラミング勉強会「オトナのGit入門」
プログラミング勉強会「オトナのGit入門」Yoshinori Yamanouchi
 
[DL輪読会]Batch Renormalization: Towards Reducing Minibatch Dependence in Batch-...
[DL輪読会]Batch Renormalization: Towards Reducing Minibatch Dependence in Batch-...[DL輪読会]Batch Renormalization: Towards Reducing Minibatch Dependence in Batch-...
[DL輪読会]Batch Renormalization: Towards Reducing Minibatch Dependence in Batch-...Deep Learning JP
 
BRDF レンダリングの方程式
BRDF レンダリングの方程式BRDF レンダリングの方程式
BRDF レンダリングの方程式康弘 等々力
 
CycleGANで顔写真をアニメ調に変換する
CycleGANで顔写真をアニメ調に変換するCycleGANで顔写真をアニメ調に変換する
CycleGANで顔写真をアニメ調に変換するmeownoisy
 
Linked Open Data(LOD)の基本理念と基盤となる技術
Linked Open Data(LOD)の基本理念と基盤となる技術Linked Open Data(LOD)の基本理念と基盤となる技術
Linked Open Data(LOD)の基本理念と基盤となる技術Kouji Kozaki
 
PDSを実現するにあたっての技術動向の紹介 (OAuth, OpenID Connect, UMAなど)
PDSを実現するにあたっての技術動向の紹介 (OAuth, OpenID Connect, UMAなど)PDSを実現するにあたっての技術動向の紹介 (OAuth, OpenID Connect, UMAなど)
PDSを実現するにあたっての技術動向の紹介 (OAuth, OpenID Connect, UMAなど)Tatsuo Kudo
 
Raspberry PiとGoogle Meetでお手軽ペットカメラ
Raspberry PiとGoogle Meetでお手軽ペットカメラRaspberry PiとGoogle Meetでお手軽ペットカメラ
Raspberry PiとGoogle Meetでお手軽ペットカメラKLab Inc. / Tech
 
ChatGPTの驚くべき対話能力 20230414APR.pdf
ChatGPTの驚くべき対話能力 20230414APR.pdfChatGPTの驚くべき対話能力 20230414APR.pdf
ChatGPTの驚くべき対話能力 20230414APR.pdfYamashitaKatsushi
 

What's hot (20)

ドメイン駆動設計 ( DDD ) をやってみよう
ドメイン駆動設計 ( DDD ) をやってみようドメイン駆動設計 ( DDD ) をやってみよう
ドメイン駆動設計 ( DDD ) をやってみよう
 
C#×LLVM=アセンブラ!? 〜詳説・Burstコンパイラー〜
C#×LLVM=アセンブラ!? 〜詳説・Burstコンパイラー〜C#×LLVM=アセンブラ!? 〜詳説・Burstコンパイラー〜
C#×LLVM=アセンブラ!? 〜詳説・Burstコンパイラー〜
 
【DL輪読会】The Forward-Forward Algorithm: Some Preliminary
【DL輪読会】The Forward-Forward Algorithm: Some Preliminary【DL輪読会】The Forward-Forward Algorithm: Some Preliminary
【DL輪読会】The Forward-Forward Algorithm: Some Preliminary
 
2015年度先端GPGPUシミュレーション工学特論 第11回 数値流体力学への応用 (支配方程式,CPUプログラム)
2015年度先端GPGPUシミュレーション工学特論 第11回 数値流体力学への応用(支配方程式,CPUプログラム)2015年度先端GPGPUシミュレーション工学特論 第11回 数値流体力学への応用(支配方程式,CPUプログラム)
2015年度先端GPGPUシミュレーション工学特論 第11回 数値流体力学への応用 (支配方程式,CPUプログラム)
 
VoxFormer: Sparse Voxel Transformer for Camera-based 3D Semantic Scene Comple...
VoxFormer: Sparse Voxel Transformer for Camera-based 3D Semantic Scene Comple...VoxFormer: Sparse Voxel Transformer for Camera-based 3D Semantic Scene Comple...
VoxFormer: Sparse Voxel Transformer for Camera-based 3D Semantic Scene Comple...
 
分散型IDと検証可能なアイデンティティ技術概要
分散型IDと検証可能なアイデンティティ技術概要分散型IDと検証可能なアイデンティティ技術概要
分散型IDと検証可能なアイデンティティ技術概要
 
TorchDataチュートリアル解説
TorchDataチュートリアル解説TorchDataチュートリアル解説
TorchDataチュートリアル解説
 
Modern Authentication -- FIDO2 Web Authentication (WebAuthn) を学ぶ --
Modern Authentication -- FIDO2 Web Authentication (WebAuthn) を学ぶ --Modern Authentication -- FIDO2 Web Authentication (WebAuthn) を学ぶ --
Modern Authentication -- FIDO2 Web Authentication (WebAuthn) を学ぶ --
 
[DL Hacks]Simple Online Realtime Tracking with a Deep Association Metric
[DL Hacks]Simple Online Realtime Tracking with a Deep Association Metric[DL Hacks]Simple Online Realtime Tracking with a Deep Association Metric
[DL Hacks]Simple Online Realtime Tracking with a Deep Association Metric
 
画像認識の初歩、SIFT,SURF特徴量
画像認識の初歩、SIFT,SURF特徴量画像認識の初歩、SIFT,SURF特徴量
画像認識の初歩、SIFT,SURF特徴量
 
【DL輪読会】Is Conditional Generative Modeling All You Need For Decision-Making?
【DL輪読会】Is Conditional Generative Modeling All You Need For Decision-Making?【DL輪読会】Is Conditional Generative Modeling All You Need For Decision-Making?
【DL輪読会】Is Conditional Generative Modeling All You Need For Decision-Making?
 
【DL輪読会】Implicit Behavioral Cloning
【DL輪読会】Implicit Behavioral Cloning【DL輪読会】Implicit Behavioral Cloning
【DL輪読会】Implicit Behavioral Cloning
 
プログラミング勉強会「オトナのGit入門」
プログラミング勉強会「オトナのGit入門」プログラミング勉強会「オトナのGit入門」
プログラミング勉強会「オトナのGit入門」
 
[DL輪読会]Batch Renormalization: Towards Reducing Minibatch Dependence in Batch-...
[DL輪読会]Batch Renormalization: Towards Reducing Minibatch Dependence in Batch-...[DL輪読会]Batch Renormalization: Towards Reducing Minibatch Dependence in Batch-...
[DL輪読会]Batch Renormalization: Towards Reducing Minibatch Dependence in Batch-...
 
BRDF レンダリングの方程式
BRDF レンダリングの方程式BRDF レンダリングの方程式
BRDF レンダリングの方程式
 
CycleGANで顔写真をアニメ調に変換する
CycleGANで顔写真をアニメ調に変換するCycleGANで顔写真をアニメ調に変換する
CycleGANで顔写真をアニメ調に変換する
 
Linked Open Data(LOD)の基本理念と基盤となる技術
Linked Open Data(LOD)の基本理念と基盤となる技術Linked Open Data(LOD)の基本理念と基盤となる技術
Linked Open Data(LOD)の基本理念と基盤となる技術
 
PDSを実現するにあたっての技術動向の紹介 (OAuth, OpenID Connect, UMAなど)
PDSを実現するにあたっての技術動向の紹介 (OAuth, OpenID Connect, UMAなど)PDSを実現するにあたっての技術動向の紹介 (OAuth, OpenID Connect, UMAなど)
PDSを実現するにあたっての技術動向の紹介 (OAuth, OpenID Connect, UMAなど)
 
Raspberry PiとGoogle Meetでお手軽ペットカメラ
Raspberry PiとGoogle Meetでお手軽ペットカメラRaspberry PiとGoogle Meetでお手軽ペットカメラ
Raspberry PiとGoogle Meetでお手軽ペットカメラ
 
ChatGPTの驚くべき対話能力 20230414APR.pdf
ChatGPTの驚くべき対話能力 20230414APR.pdfChatGPTの驚くべき対話能力 20230414APR.pdf
ChatGPTの驚くべき対話能力 20230414APR.pdf
 

20年続いているサービスの複雑な注文画面を GraphQL を使って改善した話