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

Method resetQueries

packages/query-core/src/queryClient.ts:427–447  ·  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. * @param filters - The

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

Source from the content-addressed store, hash-verified

425 * ```
426 */
427 resetQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
428 filters?: QueryFilters<TTaggedQueryKey>,
429 options?: ResetOptions,
430 ): Promise<void> {
431 const queryCache = this.#queryCache
432
433 return notifyManager.batch(() => {
434 const matched = queryCache.findAll(filters)
435 const queriesToRefetch = new Set(matched)
436 matched.forEach((query) => {
437 query.reset()
438 })
439 return this.refetchQueries(
440 {
441 type: 'active',
442 predicate: (query) => queriesToRefetch.has(query),
443 },
444 options,
445 )
446 })
447 }
448
449 /**
450 * 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 4

refetchQueriesMethod · 0.95
hasMethod · 0.80
findAllMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected