MCPcopy
hub / github.com/TanStack/query / shouldFetchOn

Function shouldFetchOn

packages/query-core/src/queryObserver.ts:769–785  ·  view source on GitHub ↗
(
  query: Query<any, any, any, any>,
  options: QueryObserverOptions<any, any, any, any, any>,
  field: (typeof options)['refetchOnMount'] &
    (typeof options)['refetchOnWindowFocus'] &
    (typeof options)['refetchOnReconnect'],
)

Source from the content-addressed store, hash-verified

767}
768
769function shouldFetchOn(
770 query: Query<any, any, any, any>,
771 options: QueryObserverOptions<any, any, any, any, any>,
772 field: (typeof options)['refetchOnMount'] &
773 (typeof options)['refetchOnWindowFocus'] &
774 (typeof options)['refetchOnReconnect'],
775) {
776 if (
777 resolveEnabled(options.enabled, query) !== false &&
778 resolveStaleTime(options.staleTime, query) !== 'static'
779 ) {
780 const value = typeof field === 'function' ? field(query) : field
781
782 return value === 'always' || (value !== false && isStale(query, options))
783 }
784 return false
785}
786
787function shouldFetchOptionally(
788 query: Query<any, any, any, any>,

Callers 3

shouldFetchOnMountFunction · 0.85

Calls 3

resolveEnabledFunction · 0.90
resolveStaleTimeFunction · 0.90
isStaleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…