( options: UseQueryOptionsWithMetadata< TMetadata, TQueryFnData, TError, TData, TQueryKey >, )
| 41 | * buildinfo, and a few others to reduce page load time. |
| 42 | */ |
| 43 | export function cachedQuery< |
| 44 | TMetadata extends MetadataValue = MetadataValue, |
| 45 | TQueryFnData = unknown, |
| 46 | TError = unknown, |
| 47 | TData = TQueryFnData, |
| 48 | TQueryKey extends QueryKey = QueryKey, |
| 49 | >( |
| 50 | options: UseQueryOptionsWithMetadata< |
| 51 | TMetadata, |
| 52 | TQueryFnData, |
| 53 | TError, |
| 54 | TData, |
| 55 | TQueryKey |
| 56 | >, |
| 57 | ): FormattedQueryOptionsResult<TQueryFnData, TError, TData, TQueryKey> { |
| 58 | const { metadata, ...delegatedOptions } = options; |
| 59 | const newOptions = { |
| 60 | ...delegatedOptions, |
| 61 | initialData: metadata.available ? metadata.value : undefined, |
| 62 | |
| 63 | // Make sure the disabled options are always serialized last, so that no |
| 64 | // one using this function can accidentally override the values |
| 65 | ...(metadata.available ? disabledRefetchOptions : {}), |
| 66 | }; |
| 67 | |
| 68 | return newOptions as FormattedQueryOptionsResult< |
| 69 | TQueryFnData, |
| 70 | TError, |
| 71 | TData, |
| 72 | TQueryKey |
| 73 | >; |
| 74 | } |
no outgoing calls
no test coverage detected