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

Method resetQueries

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

397 * ```
398 */
399 resetQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
400 filters?: QueryFilters<TTaggedQueryKey>,
401 options?: ResetOptions,
402 ): Promise<void> {
403 const queryCache = this.#queryCache
404
405 return notifyManager.batch(() => {
406 const matched = queryCache.findAll(filters)
407 const queriesToRefetch = new Set(matched)
408 matched.forEach((query) => {
409 query.reset()
410 })
411 return this.refetchQueries(
412 {
413 type: 'active',
414 predicate: (query) => queriesToRefetch.has(query),
415 },
416 options,
417 )
418 })
419 }
420
421 /**
422 * 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