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

Method resetQueries

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

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