Skip to content

Commit a028f88

Browse files
committed
fix(vue-query): wrap useInfiniteQuery options in MaybeRefOrGetter
1 parent 44563c3 commit a028f88

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

packages/vue-query/src/__tests__/useInfiniteQuery.test-d.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { describe, expectTypeOf, it } from 'vitest'
22
import { computed, reactive } from 'vue-demi'
33
import { sleep } from '@tanstack/query-test-utils'
44
import { useInfiniteQuery } from '../useInfiniteQuery'
5-
import type { InfiniteData } from '@tanstack/query-core'
65
import { infiniteQueryOptions } from '../infiniteQueryOptions'
6+
import type { InfiniteData } from '@tanstack/query-core'
77

88
describe('Discriminated union return type', () => {
99
it('data should be possibly undefined by default', () => {
@@ -97,7 +97,7 @@ describe('Discriminated union return type', () => {
9797
}
9898
})
9999

100-
it('should accept computed options with infiniteQueryOptions', () => {
100+
it('should accept computed options using infiniteQueryOptions', () => {
101101
const options = computed(() => infiniteQueryOptions({
102102
queryKey: ['infiniteQuery'],
103103
queryFn: () => sleep(0).then(() => 'Some data'),

packages/vue-query/src/useBaseQuery.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import type {
2222
import type { QueryClient } from './queryClient'
2323
import type { UseQueryOptions } from './useQuery'
2424
import type { UseInfiniteQueryOptions } from './useInfiniteQuery'
25+
import type { MaybeRefOrGetter } from './types'
2526

2627
export type UseBaseQueryReturnType<
2728
TData,
@@ -58,14 +59,14 @@ export function useBaseQuery<
5859
TPageParam,
5960
>(
6061
Observer: typeof QueryObserver,
61-
options: UseQueryOptionsGeneric<
62+
options: MaybeRefOrGetter<UseQueryOptionsGeneric<
6263
TQueryFnData,
6364
TError,
6465
TData,
6566
TQueryData,
6667
TQueryKey,
6768
TPageParam
68-
>,
69+
>>,
6970
queryClient?: QueryClient,
7071
): UseBaseQueryReturnType<TData, TError> {
7172
if (process.env.NODE_ENV === 'development') {

packages/vue-query/src/useInfiniteQuery.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ export function useInfiniteQuery<
7272
TQueryKey extends QueryKey = QueryKey,
7373
TPageParam = unknown,
7474
>(
75-
options: DefinedInitialDataInfiniteOptions<
75+
options: MaybeRefOrGetter<DefinedInitialDataInfiniteOptions<
7676
TQueryFnData,
7777
TError,
7878
TData,
7979
TQueryKey,
8080
TPageParam
81-
>,
81+
>>,
8282
queryClient?: QueryClient,
8383
): UseInfiniteQueryReturnType<TData, TError>
8484

@@ -89,13 +89,13 @@ export function useInfiniteQuery<
8989
TQueryKey extends QueryKey = QueryKey,
9090
TPageParam = unknown,
9191
>(
92-
options: UndefinedInitialDataInfiniteOptions<
92+
options: MaybeRefOrGetter<UndefinedInitialDataInfiniteOptions<
9393
TQueryFnData,
9494
TError,
9595
TData,
9696
TQueryKey,
9797
TPageParam
98-
>,
98+
>>,
9999
queryClient?: QueryClient,
100100
): UseInfiniteQueryReturnType<TData, TError>
101101

@@ -106,18 +106,18 @@ export function useInfiniteQuery<
106106
TQueryKey extends QueryKey = QueryKey,
107107
TPageParam = unknown,
108108
>(
109-
options: UseInfiniteQueryOptions<
109+
options: MaybeRefOrGetter<UseInfiniteQueryOptions<
110110
TQueryFnData,
111111
TError,
112112
TData,
113113
TQueryKey,
114114
TPageParam
115-
>,
115+
>>,
116116
queryClient?: QueryClient,
117117
): UseInfiniteQueryReturnType<TData, TError>
118118

119119
export function useInfiniteQuery(
120-
options: UseInfiniteQueryOptions,
120+
options: MaybeRefOrGetter<UseInfiniteQueryOptions> ,
121121
queryClient?: QueryClient,
122122
) {
123123
return useBaseQuery(

0 commit comments

Comments
 (0)