-
Notifications
You must be signed in to change notification settings - Fork 661
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 cache documentation #2433
📖 Improve cache documentation #2433
Conversation
Looks awesome. I've read it all and do not have any comment. |
|
||
</MultiCodeBlock> | ||
|
||
Once the dependency added, you can create the `SqlNormalizedCacheFactory`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
english nit: Once the dependency is added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I also took this opportunity to switch to imperative voice, that felt more positive:
Once the dependency is added, create the `SqlNormalizedCacheFactory`:
} | ||
``` | ||
|
||
In the above example, requesting the author of your favorite book with the `AuthorById` query will return a result from the cache if you requested your favorite book before. This is because the author is stored only once in the cache. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think to mention that the selection set of fields should be the same or less than in cache? Otherwise we won;t be able to resolve it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a small explanation and a link to https://www.apollographql.com/blog/the-concepts-of-graphql-bc68bd819be3. Since the process of normalization is the same for all platforms, I'd like to focus on the Android specific parts in this page.
) | ||
// Write to the store. All watchers will be notified | ||
apolloClient.apolloStore.writeAndPublish(BookWithAuthorName(), data).execute() | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we should add section like trouble shooting, what user should check first / pay attention to in case of cache miss or other issues?
Also we can mentioned here how to dump the cache content:
Map<KClass<?>, Map<String, Record>> dump = apolloClient.getApolloStore().normalizedCache().dump();
NormalizedCache.prettifyDump(dump)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we should add section like trouble shooting
That's definitely something that could be useful (See #2397). Not sure what to recommend though, did you have something specific in mind?
Also we can mentioned here how to dump the cache content
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should start with dump cache. Second we should mention to double check how cache key generated (make sure that there is stable ids). Third mention again about selection set should be the same or less. At least to start with these 3 points.
Maybe later we can expand more.
Separate HTTP and normalized cache and give more details for the normalized cache.
Closes #2429