This repository was archived by the owner on Apr 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 774
This repository was archived by the owner on Apr 13, 2023. It is now read-only.
[v3] Local state management #4035
Copy link
Copy link
Open
Description
Intended outcome:
I'm trying to implement storing a collection of notifications fully on the client side. However, the documentation contains plenty of references to cache.writeData
that doesn't exist:
TS2339: Property 'writeData' does not exist on type 'InMemoryCache'.
I've implemented local type defs and resolvers using writeFragment
and writeQuery
for initial data, but the cache is not updated. The documentation on local state management is rather chaotic, as it discusses 10 things at a time, and requires jumping back and forth to "Caching" section. I wasn't able to find a good example of how to store a collection of simple objects in the cache, so that it feels like it was coming from the API actually.
Actual outcome:
- I'd expect methods used in the documentation to exist
- I'd expect more thorough and step-by-step explanation how to manage local state (beyond single primitive values) via react-apollo
How to reproduce the issue:
import { ApolloClient, InMemoryCache } from '@apollo/client';
const cache = new InMemoryCache();
const client = new ApolloClient({
cache,
resolvers: { /* ... */ },
});
// writeData doesn't exist
cache.writeData({
data: {
todos: [],
visibilityFilter: 'SHOW_ALL',
networkStatus: {
__typename: 'NetworkStatus',
isConnected: false,
},
},
});
Version
System:
OS: Linux 4.4 Ubuntu 18.04.4 LTS (Bionic Beaver)
Binaries:
Node: 13.3.0 - ~/.nvm/versions/node/v13.3.0/bin/node
Yarn: 1.21.1 - ~/.nvm/versions/node/v13.3.0/bin/yarn
npm: 6.13.1 - ~/.nvm/versions/node/v13.3.0/bin/npm
npmPackages:
@apollo/client: 3.0.0-rc.10 => 3.0.0-rc.10
@apollo/link-ws: 2.0.0-beta.3 => 2.0.0-beta.3
Metadata
Metadata
Assignees
Labels
No labels