Skip to content

Implement cache normalization #7

Description

@thomasdashney

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions