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

Function shouldFetchOn

packages/query-core/src/queryObserver.ts:749–765  ·  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

747}
748
749function shouldFetchOn(
750 query: Query<any, any, any, any>,
751 options: QueryObserverOptions<any, any, any, any, any>,
752 field: (typeof options)['refetchOnMount'] &
753 (typeof options)['refetchOnWindowFocus'] &
754 (typeof options)['refetchOnReconnect'],
755) {
756 if (
757 resolveQueryValue(options.enabled, query) !== false &&
758 resolveQueryValue(options.staleTime, query) !== 'static'
759 ) {
760 const value = typeof field === 'function' ? field(query) : field
761
762 return value === 'always' || (value !== false && isStale(query, options))
763 }
764 return false
765}
766
767function shouldFetchOptionally(
768 query: Query<any, any, any, any>,

Callers 3

shouldFetchOnMountFunction · 0.85

Calls 2

resolveQueryValueFunction · 0.90
isStaleFunction · 0.85

Tested by

no test coverage detected