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

Add documentation for keyFields for singletons #6954

Merged
merged 3 commits into from
Sep 9, 2020

Conversation

adamnbowen
Copy link
Contributor

For singleton types that have no identifier, you can set keyFields: [] to ensure they're still persisted in the cache.

I just wasted an entire day trying to figure out how to configure the InMemoryCache so it would persist my singleton query types. I found this comment, which finally solved the issue for me, so I think it belongs in the documentation. I'm happy to write more or move this elsewhere in the documentation if you feel it's appropriate, but I want to help others in the future :)

Checklist:

  • If this PR is a new feature, please reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests

For singleton types that have no identifier, you can set `keyFields: []` to ensure they're still persisted in the cache.
Copy link
Member

@benjamn benjamn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition @adamnbowen—thanks!

docs/source/caching/cache-configuration.md Outdated Show resolved Hide resolved
@benjamn benjamn merged commit d91839c into apollographql:main Sep 9, 2020
@benjamn benjamn added this to the Docs updates milestone Sep 9, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants