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

Method resetQueries

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

* Resets queries matching the given filters back to their initial state (e.g. any * `initialData`), notifying subscribers rather than removing them. Active queries among the * matched set are then refetched, and the returned promise resolves once that refetch settles. * * @example * `

(
    filters?: QueryFilters<TTaggedQueryKey>,
    options?: ResetOptions,
  )

Source from the content-addressed store, hash-verified

404 * ```
405 */
406 resetQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
407 filters?: QueryFilters<TTaggedQueryKey>,
408 options?: ResetOptions,
409 ): Promise<void> {
410 const queryCache = this.#queryCache
411
412 return notifyManager.batch(() => {
413 const matched = queryCache.findAll(filters)
414 const queriesToRefetch = new Set(matched)
415 matched.forEach((query) => {
416 query.reset()
417 })
418 return this.refetchQueries(
419 {
420 type: 'active',
421 predicate: (query) => queriesToRefetch.has(query),
422 },
423 options,
424 )
425 })
426 }
427
428 /**
429 * Cancels outgoing fetches for queries matching the given filters. Most useful when performing

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
findAllMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected