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

Method refetchQueries

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

* Refetches queries matching the given filters, regardless of whether they are stale. Without * filters, every query in the cache is refetched. Queries that are disabled, or static (only * have observers with a static `staleTime`), are never refetched. * * By default (`cancelRefetch: tru

(
    filters?: RefetchQueryFilters<TTaggedQueryKey>,
    options: RefetchOptions = {},
  )

Source from the content-addressed store, hash-verified

538 * ```
539 */
540 refetchQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
541 filters?: RefetchQueryFilters<TTaggedQueryKey>,
542 options: RefetchOptions = {},
543 ): Promise<void> {
544 const fetchOptions = {
545 ...options,
546 cancelRefetch: options.cancelRefetch ?? true,
547 }
548 const promises = notifyManager.batch(() =>
549 this.#queryCache
550 .findAll(filters)
551 .filter((query) => !query.isDisabled() && !query.isStatic())
552 .map((query) => {
553 let promise = query.fetch(undefined, fetchOptions)
554 const isPaused = query.state.fetchStatus === 'paused'
555 if (!fetchOptions.throwOnError || isPaused) {
556 promise = promise.catch(noop)
557 }
558 return isPaused ? Promise.resolve() : promise
559 }),
560 )
561
562 return Promise.all(promises).then(noop)
563 }
564
565 /**
566 * Asynchronous method to fetch and cache a query, resolving with the data or throwing with

Callers 15

resetQueriesMethod · 0.95
invalidateQueriesMethod · 0.95
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

Calls 4

isDisabledMethod · 0.80
isStaticMethod · 0.80
findAllMethod · 0.45
fetchMethod · 0.45

Tested by

no test coverage detected