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
State Management with Apollo GraphQL
Search
adamTrz
August 27, 2018
Programming
52
0
Share
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
運用エージェントは "作る" から "育てる" へ - 記憶と自己進化の3層設計パターン / self-evolving-agents-three-layer-agent-design
gawa
12
3.5k
Oxcを導入して開発体験が向上した話
yug1224
4
290
CSC307 Lecture 17
javiergs
PRO
0
310
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
950
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
0
140
net-httpのHTTP/2対応について
naruse
0
440
AIエージェントの隔離技術の徹底比較
kawayu
0
460
今さら聞けないCancellationToken
htkym
0
220
AI時代のUIはどこへ行く?その2!
yusukebe
19
6.6k
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
300
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
220
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
140
Featured
See All Featured
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.3k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
430
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
290
エンジニアに許された特別な時間の終わり
watany
107
250k
Designing Powerful Visuals for Engaging Learning
tmiket
1
400
Utilizing Notion as your number one productivity tool
mfonobong
4
310
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
190
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
WCS-LA-2024
lcolladotor
0
620
Building the Perfect Custom Keyboard
takai
2
780
Thoughts on Productivity
jonyablonski
76
5.2k
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
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!