From e69dacf07af37dc8100da70e288144f8d4609457 Mon Sep 17 00:00:00 2001 From: Robert Soriano Date: Sat, 29 Oct 2022 19:26:32 -0700 Subject: [PATCH] import useAsyncData from #app --- src/runtime/client.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/runtime/client.ts b/src/runtime/client.ts index 42845d7..f2f4a90 100644 --- a/src/runtime/client.ts +++ b/src/runtime/client.ts @@ -7,6 +7,8 @@ import type { import { createFlatProxy, createRecursiveProxy } from '@trpc/server/shared' import { hash } from 'ohash' import type { DecoratedProcedureRecord } from './types' +// @ts-expect-error: Nuxt internal +import { useAsyncData } from '#app' /** * Calculates the key used for `useAsyncData` call @@ -18,7 +20,10 @@ export function getQueryKey( return input === undefined ? path : `${path}-${hash(input || '')}` } -function createNuxtProxyDecoration(name: string, client: inferRouterProxyClient) { +/** + * @internal + */ +export function createNuxtProxyDecoration(name: string, client: inferRouterProxyClient) { return createRecursiveProxy((opts) => { const args = opts.args @@ -35,14 +40,12 @@ function createNuxtProxyDecoration(name: string, clie const queryKey = getQueryKey(path, input) if (lastArg === 'mutate') { - // @ts-expect-error: Nuxt internal return useAsyncData(queryKey, () => (client as any)[path][lastArg](input), { ...asyncDataOptions as Record, immediate: false, }) } - // @ts-expect-error: Nuxt internal return useAsyncData(queryKey, () => (client as any)[path][lastArg](input), asyncDataOptions as Record) }) }