* Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the * caller into their final, defaulted form: merging `queryClient.setQueryDefaults` for the * given `queryKey`, then the client's own `defaultOptions.queries`, then the caller's options * on top. A no
(
options:
| QueryObserverOptions<
TQueryFnData,
TError,
TData,
TQueryData,
TQueryKey,
TPageParam
>
| DefaultedQueryObserverOptions<
TQueryFnData,
TError,
TData,
TQueryData,
TQueryKey
>,
)
| 974 | * on top. A no-op if the options are already defaulted (`_defaulted: true`). |
| 975 | */ |
| 976 | defaultQueryOptions< |
| 977 | TQueryFnData = unknown, |
| 978 | TError = DefaultError, |
| 979 | TData = TQueryFnData, |
| 980 | TQueryData = TQueryFnData, |
| 981 | TQueryKey extends QueryKey = QueryKey, |
| 982 | TPageParam = never, |
| 983 | >( |
| 984 | options: |
| 985 | | QueryObserverOptions< |
| 986 | TQueryFnData, |
| 987 | TError, |
| 988 | TData, |
| 989 | TQueryData, |
| 990 | TQueryKey, |
| 991 | TPageParam |
| 992 | > |
| 993 | | DefaultedQueryObserverOptions< |
| 994 | TQueryFnData, |
| 995 | TError, |
| 996 | TData, |
| 997 | TQueryData, |
| 998 | TQueryKey |
| 999 | >, |
| 1000 | ): DefaultedQueryObserverOptions< |
| 1001 | TQueryFnData, |
| 1002 | TError, |
| 1003 | TData, |
| 1004 | TQueryData, |
| 1005 | TQueryKey |
| 1006 | > { |
| 1007 | if (options._defaulted) { |
| 1008 | return options as DefaultedQueryObserverOptions< |
| 1009 | TQueryFnData, |
| 1010 | TError, |
| 1011 | TData, |
| 1012 | TQueryData, |
| 1013 | TQueryKey |
| 1014 | > |
| 1015 | } |
| 1016 | |
| 1017 | const defaultedOptions = { |
| 1018 | ...this.#defaultOptions.queries, |
| 1019 | ...this.getQueryDefaults(options.queryKey), |
| 1020 | ...options, |
| 1021 | _defaulted: true, |
| 1022 | } |
| 1023 | |
| 1024 | if (!defaultedOptions.queryHash) { |
| 1025 | defaultedOptions.queryHash = hashQueryKeyByOptions( |
| 1026 | defaultedOptions.queryKey, |
| 1027 | defaultedOptions, |
| 1028 | ) |
| 1029 | } |
| 1030 | |
| 1031 | // dependent default values |
| 1032 | if (defaultedOptions.refetchOnReconnect === undefined) { |
| 1033 | defaultedOptions.refetchOnReconnect = |
no test coverage detected