(
Observer: typeof QueryObserver,
options: MaybeRefOrGetter<
UseQueryOptionsGeneric<
TQueryFnData,
TError,
TData,
TQueryData,
TQueryKey,
TPageParam
>
>,
queryClient?: QueryClient,
)
| 59 | * will be used. |
| 60 | */ |
| 61 | export function useBaseQuery< |
| 62 | TQueryFnData, |
| 63 | TError, |
| 64 | TData, |
| 65 | TQueryData, |
| 66 | TQueryKey extends QueryKey, |
| 67 | TPageParam, |
| 68 | >( |
| 69 | Observer: typeof QueryObserver, |
| 70 | options: MaybeRefOrGetter< |
| 71 | UseQueryOptionsGeneric< |
| 72 | TQueryFnData, |
| 73 | TError, |
| 74 | TData, |
| 75 | TQueryData, |
| 76 | TQueryKey, |
| 77 | TPageParam |
| 78 | > |
| 79 | >, |
| 80 | queryClient?: QueryClient, |
| 81 | ): UseBaseQueryReturnType<TData, TError> { |
| 82 | if (process.env.NODE_ENV === 'development') { |
| 83 | if (!getCurrentScope()) { |
| 84 | console.warn( |
| 85 | 'vue-query composable like "useQuery()" should only be used inside a "setup()" function or a running effect scope. They might otherwise lead to memory leaks.', |
| 86 | ) |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | const client = queryClient || useQueryClient() |
| 91 | |
| 92 | const defaultedOptions = computed(() => { |
| 93 | let resolvedOptions = options |
| 94 | if (typeof resolvedOptions === 'function') { |
| 95 | resolvedOptions = resolvedOptions() |
| 96 | } |
| 97 | const clonedOptions = cloneDeepUnref(resolvedOptions as any) |
| 98 | |
| 99 | if (typeof clonedOptions.enabled === 'function') { |
| 100 | clonedOptions.enabled = clonedOptions.enabled() |
| 101 | } |
| 102 | |
| 103 | const defaulted: DefaultedQueryObserverOptions< |
| 104 | TQueryFnData, |
| 105 | TError, |
| 106 | TData, |
| 107 | TQueryData, |
| 108 | TQueryKey |
| 109 | > = client.defaultQueryOptions(clonedOptions) |
| 110 | |
| 111 | defaulted._optimisticResults = client.isRestoring?.value |
| 112 | ? 'isRestoring' |
| 113 | : 'optimistic' |
| 114 | |
| 115 | return defaulted |
| 116 | }) |
| 117 | |
| 118 | const observer = new Observer(client, defaultedOptions.value) |
no test coverage detected