A lightweight library that normalizes nested GraphQL responses into flat, key-value objects for efficient client-side caching.
GraphQL Normalizr is a JavaScript library that normalizes nested GraphQL API responses into flat, key-value objects for efficient client-side caching. It solves the problem of persisting GraphQL data in state management libraries like Redux or Apollo Client by converting deeply nested structures into normalized collections, enabling faster data access and updates.
Frontend developers working with GraphQL APIs who need to cache responses in client-side state management systems like Redux, Apollo Client, or custom Flux stores.
Developers choose GraphQL Normalizr for its lightweight, configurable approach to normalization without heavy dependencies, offering fine-grained control over entity mapping, ID fields, and connection handling while maintaining performance.
Normalize GraphQL responses for persisting in the client cache/state
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Efficiently flattens nested GraphQL responses into key-value stores using `__typename` and `id` fields, as shown in the TL;DR transformation example, enabling faster cache lookups.
Supports custom ID keys, entity naming, field ignoring, and GraphQL connections through a comprehensive config object, such as `idKey: 'uid'` or `useConnections: true`, allowing tailored integration.
Automatically adds required `__typename` and `id` fields to GraphQL queries if missing, via the `parse` or `addRequiredFields` methods, simplifying client-side setup without modifying server queries.
Includes optional caching to prevent re-normalization of unchanged data, improving efficiency for scenarios like polling or repeated queries, as noted in the caching configuration.
Version 2.x introduced changes to entity name casing that require manual configuration adjustments, as highlighted in the migration guide, which can be a hurdle for upgrades.
With numerous options like typeMap, ignore, lists, and casing, the setup can be overwhelming and error-prone for developers not needing fine-grained control, increasing initial time investment.
Relies on `__typename` and `id` fields being present or augmentable, which may not be feasible if the GraphQL server doesn't support these or if queries are static and unmodifiable.