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

Method refetchQueries

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

542 * ```
543 */
544 refetchQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
545 filters?: RefetchQueryFilters<TTaggedQueryKey>,
546 options: RefetchOptions = {},
547 ): Promise<void> {
548 const fetchOptions = {
549 ...options,
550 cancelRefetch: options.cancelRefetch ?? true,
551 }
552 const promises = notifyManager.batch(() =>
553 this.#queryCache
554 .findAll(filters)
555 .filter((query) => !query.isDisabled() && !query.isStatic())
556 .map((query) => {
557 let promise = query.fetch(undefined, fetchOptions)
558 const isPaused = query.state.fetchStatus === 'paused'
559 if (!fetchOptions.throwOnError || isPaused) {
560 promise = promise.catch(noop)
561 }
562 return isPaused ? Promise.resolve() : promise
563 }),
564 )
565
566 return Promise.all(promises).then(noop)
567 }
568
569 /**
570 * 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