( data: TData | undefined, options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>, )
| 1045 | * @returns The partial query state for a starting fetch. |
| 1046 | */ |
| 1047 | export function fetchState< |
| 1048 | TQueryFnData, |
| 1049 | TError, |
| 1050 | TData, |
| 1051 | TQueryKey extends QueryKey, |
| 1052 | >( |
| 1053 | data: TData | undefined, |
| 1054 | options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>, |
| 1055 | ) { |
| 1056 | return { |
| 1057 | fetchFailureCount: 0, |
| 1058 | fetchFailureReason: null, |
| 1059 | fetchStatus: canFetch(options.networkMode) ? 'fetching' : 'paused', |
| 1060 | ...(data === undefined && |
| 1061 | ({ |
| 1062 | error: null, |
| 1063 | status: 'pending', |
| 1064 | } as const)), |
| 1065 | } as const |
| 1066 | } |
| 1067 | |
| 1068 | /** |
| 1069 | * Returns the state changes applied when a query receives data. |
no test coverage detected