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
58
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
Transcript
12 slides
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!
Other Decks in Programming
See All in Programming
止まらない比較を止める — 余帰納法で無限ストリームを比べる
tarao
0
190
Spec-driven Development with AI
simas
PRO
0
2.3k
どうしても Eloquent でリポジトリパターンをやりたいんだ #phpcon_niigata / phpcon-niigata-2026
shogogg
0
580
SODA - FACT BOOK(JP)
sodainc
1
40k
動画プレイヤーはなぜカクつくのか 〜Flutterのレンダリングとネイティブの境界を解剖する〜
naruogram
0
340
조합이폭발하는디자인시스템이걸눈으로도테스트하라고요
giljongyu
0
770
あなたの await、OS まで届いてる? strace で覗く JavaScript の非同期
hasutosasaki
1
2.4k
Vue.jsで作る空間解析アプリとCapacitorプラグインのData Bridge
hal_spidernight
1
180
AI Augmentation Techniques with Liberty
ivargrimstad
1
510
将来の標準フォーマッター?ktfmtを深堀る
t45k
0
210
自作Discord音声botをLambda MicroVMsに移行した話 / Migrating My Discord Voice Bot to Lambda MicroVMs
akihisaikeda
1
360
あなたはMCPの機能を、まだ知らない。
4geru
1
560
Featured
See All Featured
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
690
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
450
Into the Great Unknown - MozCon
thekraken
41
2.8k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
560
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
480
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
43k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
610
Embracing the Ebb and Flow
colly
88
5.2k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Statistics for Hackers
jakevdp
799
230k
Designing for Timeless Needs
cassininazir
1
560
Documentation Writing (for coders)
carmenintech
77
5.6k