// the find
klis87/normy
Automatic normalization and data updates for data fetching libraries (react-query, vue-query, trpc, swr, rtk-query and more)
Normy adds automatic cache normalization to data-fetching libraries like react-query, SWR, and RTK Query. When a mutation returns an object with an id, Normy propagates that update to every query in the cache that holds the same id — no manual setQueryData calls needed. It's for teams tired of writing boilerplate cache-update logic that breaks whenever a new query touches the same data.
The core mechanism is genuinely useful: deep-merge by id across all cached queries works for the common case where your server returns consistent shapes and your ids are globally unique. The array operations system (insert, remove, move, swap, replaceAll, plus custom ops) is more complete than anything similar — most alternatives just punt on arrays. The adapter pattern in @normy/core is clean; writing a plugin for a new fetching library is a few dozen lines. Performance is handled thoughtfully: structural sharing means a cache update that produces identical data doesn't trigger re-normalization, and you can opt individual queries out if they're too large.
The three preconditions — globally unique ids, consistent object shapes across queries, and a standardized id key — will break down on most real-world APIs. REST endpoints routinely return the same entity with different field sets (list view vs detail view), and 'globally unique ids' is aspirational when you're mixing users, posts, and comments that all use sequential integers. The __append/__insert/__remove magic properties on mutation response objects are a significant smell: you're coupling server response transformation to UI array semantics, and if you don't control the mutation function (e.g., tRPC procedures, generated clients) you need a wrapper anyway. 608 stars and 13 forks after what looks like several years of development is a signal — this is a real idea but it hasn't found an audience, which means bug reports may sit unanswered and the ecosystem integrations may lag behind breaking changes in react-query or RTK Query.