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