Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

[v3] Local state management #4035

Open
TeoTN opened this issue Jul 8, 2020 · 0 comments
Open

[v3] Local state management #4035

TeoTN opened this issue Jul 8, 2020 · 0 comments

Comments

@TeoTN
Copy link

TeoTN commented Jul 8, 2020

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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant