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

Method invalidateQueries

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

493 * ```
494 */
495 invalidateQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
496 filters?: InvalidateQueryFilters<TTaggedQueryKey>,
497 options: InvalidateOptions = {},
498 ): Promise<void> {
499 return notifyManager.batch(() => {
500 this.#queryCache.findAll(filters).forEach((query) => {
501 query.invalidate()
502 })
503
504 if (filters?.refetchType === 'none') {
505 return Promise.resolve()
506 }
507 return this.refetchQueries(
508 {
509 ...filters,
510 type: filters?.refetchType ?? filters?.type ?? 'active',
511 },
512 options,
513 )
514 })
515 }
516
517 /**
518 * 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