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

Method invalidateQueries

packages/query-core/src/queryClient.ts:469–489  ·  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

467 * ```
468 */
469 invalidateQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
470 filters?: InvalidateQueryFilters<TTaggedQueryKey>,
471 options: InvalidateOptions = {},
472 ): Promise<void> {
473 return notifyManager.batch(() => {
474 this.#queryCache.findAll(filters).forEach((query) => {
475 query.invalidate()
476 })
477
478 if (filters?.refetchType === 'none') {
479 return Promise.resolve()
480 }
481 return this.refetchQueries(
482 {
483 ...filters,
484 type: filters?.refetchType ?? filters?.type ?? 'active',
485 },
486 options,
487 )
488 })
489 }
490
491 /**
492 * 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