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

Added documentation for read and update operations #452

Merged
merged 1 commit into from
Feb 3, 2019
Merged

Added documentation for read and update operations #452

merged 1 commit into from
Feb 3, 2019

Conversation

Nickersoft
Copy link
Contributor

Gave a very brief overview of the cache read/update functionality that was just added just to prove its existence. Does not really contain a deep-dive into how the cache is internally managed and propagated like the React docs do, so this section I feel can definitely be expanded. This is really just to get something on the site.

@martijnwalraven
Copy link
Contributor

Thanks!

@Nickersoft Nickersoft deleted the nickersoft/cachingdocs branch February 3, 2019 23:57
@morgan-edwards
Copy link

I've been following this PR for a while, and I'm really glad this is getting some attention. Cache manipulation is a feature of the react client that my application relies heavily on.

Trying to get this functionality in the iOS adaptation has proven to be no simple task. After following the new docs and proposed functionality, there seems be a disconnect between the documentation and what is available in the most recent package. Specifically, the client has no store exposed, and when I separate the store into a variable and attempt to call load on it, I am met with "'load' is inaccessible due to 'internal' protection level."

Is there something I am missing, or is it necessary to fork and expose these elements in order to do direct cache manipulation?

@AnthonyMDev
Copy link
Contributor

@Nickersoft Just read through #413 and the context around that. Thanks so much for making this fix.
I'm looking for a little clarification, and the docs don't seem to answer my question here.

I'm not sure when to use the manual writing to the cache. If I want to do optimistic updates, then I would use this, but if I am implementing caching properly, it seems to me that writing directly to the cache to update after mutations isn't necessary.

From the docs:

This functionality is useful when performing mutations or receiving subscription data, as you should always update the local cache to ensure consistency with the operation that was just performed.

If I'm properly implementing cacheKeyForObject on my ApolloClient, and my mutation includes fields to return all of the fields that would be mutated by the mutation, wouldn't my cache already be automatically updated when the mutation finishes?

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

Successfully merging this pull request may close these issues.

4 participants