Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
State Management with Apollo GraphQL
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
adamTrz
August 27, 2018
Programming
53
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
State Management with Apollo GraphQL
Manage your Application State with Apollo GraphQL without a hassle.
adamTrz
August 27, 2018
Other Decks in Programming
See All in Programming
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.9k
半永久的に提供し続けられるプライベートクラウドを目指して ― 利用者の認知負荷を抑えるAPI抽象化とハードウェア世代交代の基盤設計
tomokon
0
500
SREの越境 / SRE Collaboration
y0hgi
2
310
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
380
Simple Storage Service(S3) is not simple
iwatsukayura
0
290
Optunaを作ったときにやりたかったこと、その後 (2026/10/16, Optuna Meetup #3)
iwiwi
1
430
R8 の設定見直しでアプリサイズ削減
andpad
0
220
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
0
460
コーディング自動化の次へ。人の介入をゼロにするファクトリーとサポートAIによる実践
timakin
4
3.5k
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
610
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
370
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
220
Being A Developer After 40
akosma
92
590k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
520
Speed Design
sergeychernyshev
33
2.2k
Git: the NoSQL Database
bkeepers
PRO
433
67k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
Odyssey Design
rkendrick25
PRO
2
870
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
730
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
How to make the Groovebox
asonas
2
2.5k
Automating Front-end Workflow
addyosmani
1369
210k
Transcript
State Management with Apollo GraphQL Adam Trzciński github.com/adamTrz medium.com/@adamtrzciski
What is State? •Data that comes from external APIs •Temporary
data •User selections !2
Redux or Mobx?
• Declarative data fetching • Apollo’s Higher Order Components
apollo-link-state • what are links? • what is apollo-link-state?
... import ApolloClient from 'apollo-boost'; ... const client = new
ApolloClient({ uri, clientState, }); Set up
const clientState = { defaults: { cart: [], }, resolvers:
{ Mutation: { addItemToCart: (_, { id, value }, { cache }) => { const previous = cache.readQuery({ query: CART_QUERY }); const data = {...}; cache.writeData({ data }); return null; }, ... Set up
export const CART_QUERY = gql` query GetCart { cart @client
{ id value } } `; export const ADD_ITEM_TO_CART = gql` mutation addItemToCart($id: ID!, $value: number!) { addItemToCart(id: $id, value: $value) @client } `; Usage
Demo Time!
Take away • One source of truth • Reduced code
boilerplate
Useful links • The Future of State Management by Peggy
Razis http://bit.ly/apollo_medium • Apollo-link-state - Let’s manage state with queries http://bit.ly/apollo_yt • Docs! http://bit.ly/apollo_docs
Thank you!