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

Function shouldFetchOn

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

860}
861
862function shouldFetchOn(
863 query: Query<any, any, any, any>,
864 options: QueryObserverOptions<any, any, any, any, any>,
865 field: (typeof options)['refetchOnMount'] &
866 (typeof options)['refetchOnWindowFocus'] &
867 (typeof options)['refetchOnReconnect'],
868) {
869 if (
870 resolveQueryValue(options.enabled, query) !== false &&
871 resolveQueryValue(options.staleTime, query) !== 'static'
872 ) {
873 const value = resolveQueryValue(field, query)
874
875 return value === 'always' || (value !== false && isStale(query, options))
876 }
877 return false
878}
879
880function shouldFetchOptionally(
881 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