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

Method invalidateQueries

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

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