Use the existing query-key factory instead of hand-typed keys to avoid stale caches
The article argues that components fetching resources with hand-typed query keys like ['user', id] can break cache invalidation when a repo already provides a query-key factory. A mismatched key can leave list views stale after a successful mutation, or split one entity across separate cache slots. The author recommends that new queries and mutations use the shared factory, that invalidation rely on its prefix helpers, and that new resource keys be added to the factory rather than invented in feature files. The piece also offers review guidance, such as searching diffs for raw key arrays and rejecting handmade keys that bypass the factory.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in