mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-14 12:14:40 +01:00
feat: add useLazyQuery composable
This commit is contained in:
@@ -40,7 +40,7 @@ export function createNuxtProxyDecoration<TRouter extends AnyRouter> (name: stri
|
||||
|
||||
const [input, otherOptions] = args
|
||||
|
||||
if (lastArg === 'useQuery') {
|
||||
if (['useQuery', 'useLazyQuery'].includes(lastArg)) {
|
||||
const { trpc, queryKey: customQueryKey, ...asyncDataOptions } = otherOptions || {} as any
|
||||
|
||||
let controller: AbortController
|
||||
@@ -54,6 +54,10 @@ 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))
|
||||
return useAsyncData(queryKey, () => (client as any)[path].query(unref(input), {
|
||||
signal: controller?.signal,
|
||||
|
||||
Reference in New Issue
Block a user