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

Function fetchState

packages/query-core/src/query.ts:692–711  ·  view source on GitHub ↗
(
  data: TData | undefined,
  options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,
)

Source from the content-addressed store, hash-verified

690}
691
692export function fetchState<
693 TQueryFnData,
694 TError,
695 TData,
696 TQueryKey extends QueryKey,
697>(
698 data: TData | undefined,
699 options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,
700) {
701 return {
702 fetchFailureCount: 0,
703 fetchFailureReason: null,
704 fetchStatus: canFetch(options.networkMode) ? 'fetching' : 'paused',
705 ...(data === undefined &&
706 ({
707 error: null,
708 status: 'pending',
709 } as const)),
710 } as const
711}
712
713function getDefaultState<
714 TQueryFnData,

Callers 2

createResultMethod · 0.90
reducerMethod · 0.85

Calls 1

canFetchFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…