Skip to content

Instantly share code, notes, and snippets.

@nabato
nabato / rtkQueryCacheUtils.ts
Created August 4, 2024 08:40 — forked from Shrugsy/rtkQueryCacheUtils.ts
RTK Query cache utils. Useful abstractions for creating `provides`/`invalidates` cache data tags against endpoints.
import { FetchBaseQueryError } from '@rtk-incubator/rtk-query/dist';
/**
* Default tags used by the cacher helpers
*/
const defaultTags = ["UNAUTHORIZED", "UNKNOWN_ERROR"] as const;
type DefaultTags = typeof defaultTags[number];
function concatErrorCache<T, ID>(
existingCache: CacheList<T, ID>,