Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation on normalized cache #2429

Closed
lbg-reggar opened this issue Jul 7, 2020 · 5 comments · Fixed by #2433
Closed

Improve documentation on normalized cache #2429

lbg-reggar opened this issue Jul 7, 2020 · 5 comments · Fixed by #2433

Comments

@lbg-reggar
Copy link

Is your feature request related to a problem? Please describe.
Currently, iOS and React have a lot more detailed information about how the normalized cache works and how one can interact with it. The Android documentation should be updated to include this.

Describe the solution you'd like
Android documentation includes:

  • How the default cache key is defined
  • How to configure the cache keys
  • How to interact with cached data
@martinbonnin
Copy link
Contributor

The preview of the docmentation is available there: https://deploy-preview-2433--apollo-android-docs.netlify.app/docs/android/essentials/normalized-cache/
Pull request: #2433

Let me know if that helps

@lbg-reggar
Copy link
Author

Thanks for the quick turnaround @martinbonnin . Looks good so far might be helpful to add any recommendations around the ApolloStore like updating or removing (as opposed to the catch-all clearNormalizedCache())?

@martinbonnin
Copy link
Contributor

@lbg-reggar I added a small section about ApolloStore. I don't want to commit too much there since this is typically something that can be improved and might change in the near future. See #2331.

Out of curiosity, is this an API that you are using already? Would you share some details about your use case to make sure it's addressed by any new API?

@lbg-reggar
Copy link
Author

@martinbonnin Thanks for doing that, really appreciated.

We are early on our GraphQL journey so just learning the realm of possibility. Essentially, an illustratrative use-case would be:

  • We have a library that contain shelves that contain a selection of books (with chapters and pages)
  • We have the ability to add/remove books and move them between shelves
  • After updating we want a way to invalidate the cache for those books rather then invalidating the app-wide normalized cache

We are essentially thinking about storing everything with their ID's as the CacheKey. We can then use apolloClient.apolloStore.remove([SHELF_ID]) when we know a shelf has been updated, rather than apolloClient.clearNormalizedCache(). Another option, would be to retrieve the shelf as part of the
mutation call, but then it requires the shelf modification screen to know which fields other parts of
the application are using.

Hope that all makes sense.

@martinbonnin
Copy link
Contributor

That makes perfect sense. Thanks for the explanations 👌 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants