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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
LLM 101
dalinaum
0
480
Spec-Driven Development - Why Vaadin Is the Perfect Fit
simas
PRO
0
250
Optunaを作ったときにやりたかったこと、その後 (2026/10/16, Optuna Meetup #3)
iwiwi
4
1.5k
動画プレイヤーはなぜカクつくのか 〜Flutterのレンダリングとネイティブの境界を解剖する〜
naruogram
0
330
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
340
AWS CDKを理解するために公式の定義を深掘って解説してみる / Understanding AWS CDK by Digging into Its Official Definition
akihisaikeda
3
300
TanStack Vue Query と Pinia Colada から学ぶ非同期状態の型設計
aoshi
0
660
私なりのハーネスエンジニアリング ~独自の言語処理系の開発を通して~
seosoft
0
200
Goコンパイラを作ってGoをもっと理解する / Build a Go compiler to better understand Go
ikura_hamu
0
130
Event is what happens
moro
2
4.6k
Vue.jsで作る空間解析アプリとCapacitorプラグインのData Bridge
hal_spidernight
1
170
graphql-ruby を Spinel で速くしようとした話
mtsmfm
0
140
Featured
See All Featured
Designing for Performance
lara
612
70k
Marketing to machines
jonoalderson
1
6k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.8k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
WCS-LA-2024
lcolladotor
0
990
What the history of the web can teach us about the future of AI
inesmontani
PRO
3
810
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
60k
Fireside Chat
paigeccino
43
4.1k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
350
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
340
WENDY [Excerpt]
tessaabrams
15
40k
Everyday Curiosity
cassininazir
0
400