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

Implement cache normalization #7

Open
thomasdashney opened this issue Mar 1, 2020 · 0 comments
Open

Implement cache normalization #7

thomasdashney opened this issue Mar 1, 2020 · 0 comments

Comments

@thomasdashney
Copy link
Contributor

thomasdashney commented Mar 1, 2020

A major feature of data-fetching libraries is normalization. Existing data-fetching libraries have differing approaches to normalization:

  • Protocol-generic libraries such as react-query and swr use key-value caches, and by design, do not support normalization.
  • GraphQL libraries such as apollo-client and urql guarantee that the cached data is structured by nature of the type system, enabling them each to implement an easy-to-use normalized caching system.

rest-hooks is the most comparable data-fetching library, which implements a normalized cache for REST API data. As is evident in the API, this requires quite a bit of customization for the user to properly configure this, especially compared to the GraphQL libraries.

Goals

  • A normalized cache should be opt-in.
  • Non-normalized cached responses should behave exactly as they did before the cache was normalized.
  • A schema can optionally be provided when making any sort of request, indicating how it should be normalized and denormalized into the cache.

We could utilize normalizr under the hood, but need to provide customization for record merging.

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

No branches or pull requests

1 participant