MCPcopy Create free account
hub / github.com/TanStack/query / invalidateQueries

Method invalidateQueries

packages/query-core/src/queryClient.ts:462–482  ·  view source on GitHub ↗

* Marks queries matching the given filters as invalidated. Unlike * QueryClient#removeQueries, invalidated queries stay in the cache. * * Unless `filters.refetchType` is `'none'`, matching queries are then refetched via * QueryClient#refetchQueries, using `filters.refetch

(
    filters?: InvalidateQueryFilters<TTaggedQueryKey>,
    options: InvalidateOptions = {},
  )

Source from the content-addressed store, hash-verified

460 * ```
461 */
462 invalidateQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
463 filters?: InvalidateQueryFilters<TTaggedQueryKey>,
464 options: InvalidateOptions = {},
465 ): Promise<void> {
466 return notifyManager.batch(() => {
467 this.#queryCache.findAll(filters).forEach((query) => {
468 query.invalidate()
469 })
470
471 if (filters?.refetchType === 'none') {
472 return Promise.resolve()
473 }
474 return this.refetchQueries(
475 {
476 ...filters,
477 type: filters?.refetchType ?? filters?.type ?? 'active',
478 },
479 options,
480 )
481 })
482 }
483
484 /**
485 * Refetches queries matching the given filters, regardless of whether they are stale. Without

Callers 15

WithKnownParametersFunction · 0.45
WithIdentifiersFunction · 0.45
WithKnownParametersFunction · 0.45
WithIdentifiersFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
QueryDetailsFunction · 0.45

Calls 3

refetchQueriesMethod · 0.95
invalidateMethod · 0.80
findAllMethod · 0.45

Tested by

no test coverage detected