(
Observer: typeof QueryObserver,
options: MaybeRefOrGetter<
UseQueryOptionsGeneric<
TQueryFnData,
TError,
TData,
TQueryData,
TQueryKey,
TPageParam
>
>,
queryClient?: QueryClient,
)
| 51 | | UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> |
| 52 | |
| 53 | export function useBaseQuery< |
| 54 | TQueryFnData, |
| 55 | TError, |
| 56 | TData, |
| 57 | TQueryData, |
| 58 | TQueryKey extends QueryKey, |
| 59 | TPageParam, |
| 60 | >( |
| 61 | Observer: typeof QueryObserver, |
| 62 | options: MaybeRefOrGetter< |
| 63 | UseQueryOptionsGeneric< |
| 64 | TQueryFnData, |
| 65 | TError, |
| 66 | TData, |
| 67 | TQueryData, |
| 68 | TQueryKey, |
| 69 | TPageParam |
| 70 | > |
| 71 | >, |
| 72 | queryClient?: QueryClient, |
| 73 | ): UseBaseQueryReturnType<TData, TError> { |
| 74 | if (process.env.NODE_ENV === 'development') { |
| 75 | if (!getCurrentScope()) { |
| 76 | console.warn( |
| 77 | '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.', |
| 78 | ) |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | const client = queryClient || useQueryClient() |
| 83 | |
| 84 | const defaultedOptions = computed(() => { |
| 85 | const clonedOptions = cloneDeepUnref(options as any) |
| 86 | |
| 87 | if (typeof clonedOptions.enabled === 'function') { |
| 88 | clonedOptions.enabled = clonedOptions.enabled() |
| 89 | } |
| 90 | |
| 91 | const defaulted: DefaultedQueryObserverOptions< |
| 92 | TQueryFnData, |
| 93 | TError, |
| 94 | TData, |
| 95 | TQueryData, |
| 96 | TQueryKey |
| 97 | > = client.defaultQueryOptions(clonedOptions) |
| 98 | |
| 99 | defaulted._optimisticResults = client.isRestoring?.value |
| 100 | ? 'isRestoring' |
| 101 | : 'optimistic' |
| 102 | |
| 103 | return defaulted |
| 104 | }) |
| 105 | |
| 106 | const observer = new Observer(client, defaultedOptions.value) |
| 107 | // @ts-expect-error |
| 108 | const state = defaultedOptions.value.shallow |
| 109 | ? shallowReactive(observer.getCurrentResult()) |
| 110 | : reactive(observer.getCurrentResult()) |
no test coverage detected
searching dependent graphs…