mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-26 01:40:31 +01:00
fix: add missing useLazyQuery type
This commit is contained in:
@@ -54,17 +54,17 @@ export function createNuxtProxyDecoration<TRouter extends AnyRouter> (name: stri
|
||||
controller = typeof AbortController !== 'undefined' ? new AbortController() : {} as AbortController
|
||||
}
|
||||
|
||||
if (lastArg === 'useLazyQuery') {
|
||||
asyncDataOptions.lazy = true;
|
||||
}
|
||||
|
||||
const queryKey = customQueryKey || getQueryKey(path, unref(input))
|
||||
const watch = isRef(input) ? [...(asyncDataOptions.watch || []), input] : asyncDataOptions.watch
|
||||
const isLazy = lastArg === 'useLazyQuery' ? true : (asyncDataOptions.lazy || false)
|
||||
|
||||
return useAsyncData(queryKey, () => (client as any)[path].query(unref(input), {
|
||||
signal: controller?.signal,
|
||||
...trpc
|
||||
}), {
|
||||
...asyncDataOptions,
|
||||
watch: isRef(input) ? [...(asyncDataOptions.watch || []), input] : asyncDataOptions.watch
|
||||
watch,
|
||||
lazy: isLazy
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -53,10 +53,10 @@ type DecorateProcedure<
|
||||
> = TProcedure extends AnyQueryProcedure
|
||||
? {
|
||||
useQuery: <
|
||||
ResT = inferTransformedProcedureOutput<TProcedure>,
|
||||
DataE = TRPCClientErrorLike<TProcedure>,
|
||||
DataT = ResT,
|
||||
PickKeys extends KeysOf<DataT> = KeysOf<DataT>,
|
||||
ResT = inferTransformedProcedureOutput<TProcedure>,
|
||||
DataE = TRPCClientErrorLike<TProcedure>,
|
||||
DataT = ResT,
|
||||
PickKeys extends KeysOf<DataT> = KeysOf<DataT>,
|
||||
>(
|
||||
input: MaybeRef<inferProcedureInput<TProcedure>>,
|
||||
opts?: AsyncDataOptions<ResT, DataT, PickKeys> & {
|
||||
@@ -68,6 +68,22 @@ type DecorateProcedure<
|
||||
queryKey?: string
|
||||
},
|
||||
) => AsyncData<PickFrom<DataT, PickKeys> | null, DataE>,
|
||||
useLazyQuery: <
|
||||
ResT = inferTransformedProcedureOutput<TProcedure>,
|
||||
DataE = TRPCClientErrorLike<TProcedure>,
|
||||
DataT = ResT,
|
||||
PickKeys extends KeysOf<DataT> = KeysOf<DataT>,
|
||||
>(
|
||||
input: MaybeRef<inferProcedureInput<TProcedure>>,
|
||||
opts?: Omit<AsyncDataOptions<ResT, DataT, PickKeys>, 'lazy'> & {
|
||||
trpc?: TRPCRequestOptions
|
||||
/**
|
||||
* The custom unique key to use.
|
||||
* @see https://nuxt.com/docs/api/composables/use-async-data#params
|
||||
*/
|
||||
queryKey?: string
|
||||
},
|
||||
) => AsyncData<PickFrom<DataT, PickKeys> | null, DataE>,
|
||||
query: Resolver<TProcedure>
|
||||
} : TProcedure extends AnyMutationProcedure ? {
|
||||
mutate: Resolver<TProcedure>
|
||||
|
||||
Reference in New Issue
Block a user