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

Method refetchQueries

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

497 * ```
498 */
499 refetchQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
500 filters?: RefetchQueryFilters<TTaggedQueryKey>,
501 options: RefetchOptions = {},
502 ): Promise<void> {
503 const fetchOptions = {
504 ...options,
505 cancelRefetch: options.cancelRefetch ?? true,
506 }
507 const promises = notifyManager.batch(() =>
508 this.#queryCache
509 .findAll(filters)
510 .filter((query) => !query.isDisabled() && !query.isStatic())
511 .map((query) => {
512 let promise = query.fetch(undefined, fetchOptions)
513 if (!fetchOptions.throwOnError) {
514 promise = promise.catch(noop)
515 }
516 return query.state.fetchStatus === 'paused'
517 ? Promise.resolve()
518 : promise
519 }),
520 )
521
522 return Promise.all(promises).then(noop)
523 }
524
525 /**
526 * 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