Apollo-client: [apollo-cache-inmemory] Documentation improvements : Change cacheResolvers to cacheRedirects

Created on 15 Feb 2018  ·  4Comments  ·  Source: apollographql/apollo-client

Most helpful comment

As I can see in the newest apollo-boost package, there is also an interesting third parameter called getCacheKey.
Now the import { toIdValue } from 'apollo-utilities'; is no more required.
The example code is

cacheRedirects: {
    Query: {
      movie: (_, { id }, { getCacheKey }) =>
        getCacheKey({ __typename: 'Movie', id });
    }
  }

Be careful with the id field if you had previously declared a specific dataIdFromObject configuration.

All 4 comments

As I can see in the newest apollo-boost package, there is also an interesting third parameter called getCacheKey.
Now the import { toIdValue } from 'apollo-utilities'; is no more required.
The example code is

cacheRedirects: {
    Query: {
      movie: (_, { id }, { getCacheKey }) =>
        getCacheKey({ __typename: 'Movie', id });
    }
  }

Be careful with the id field if you had previously declared a specific dataIdFromObject configuration.

Maybe you could add a version select in the documentation as can be seen in the lodash documentation

/label docs

Thanks for reporting this. There hasn't been any activity here in quite some time, so we'll close this issue for now. If this is still a problem (using a modern version of Apollo Client), please let us know. Thanks!

Was this page helpful?
0 / 5 - 0 ratings