MCPcopy Create free account
hub / github.com/effect-app/libs / getClientInvalidationKeys

Function getClientInvalidationKeys

packages/vue/src/mutate.ts:273–304  ·  view source on GitHub ↗
(
    input: unknown,
    output: Exit.Exit<unknown, unknown>
  )

Source from the content-addressed store, hash-verified

271 return tuple(computed(() => state.value), act)
272}
273
274const buildInvalidateCache = <RInvalidator>(
275 self: { id: string; options?: ClientForOptions; disableQueryInvalidation?: boolean },
276 queryInvalidation: MutationOptionsBase["queryInvalidation"] | undefined,
277 queryInvalidator: QueryInvalidator<RInvalidator>
278) => {
279 // Concrete reactivity keys to invalidate: a raw query key, one derived from an `{ id }`
280 // entry, or a compatibility `{ filters: { queryKey } }` entry.
281 // Predicate-only `{ filters }` entries have no exact-key reactivity equivalent and throw.
282 const getClientInvalidationKeys = (
283 input: unknown,
284 output: Exit.Exit<unknown, unknown>
285 ): ReadonlyArray<ReadonlyArray<unknown>> => {
286 const queryKey = getQueryKey(self)
287
288 if (queryInvalidation) {
289 const keys: Array<ReadonlyArray<unknown>> = []
290 for (const entry of queryInvalidation(queryKey, self.id, input, output)) {
291 if (isQueryKey(entry)) {
292 keys.push(entry)
293 continue
294 }
295 if ("id" in entry) {
296 keys.push(makeQueryKey(entry.options ? { id: entry.id, options: entry.options } : { id: entry.id }))
297 continue
298 }
299 const filterQueryKey = queryKeyFromFilters(entry)
300 if (filterQueryKey !== undefined) {
301 keys.push(filterQueryKey)
302 continue
303 }
304 throw new Error("Unsupported query invalidation filter: only filters.queryKey is supported")
305 }
306 return keys
307 }

Callers 1

invalidateCacheFunction · 0.85

Calls 5

makeQueryKeyFunction · 0.90
getQueryKeyFunction · 0.85
isQueryKeyFunction · 0.85
queryKeyFromFiltersFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…