From 3b0609e3959b75b1815553116422c361e89b3586 Mon Sep 17 00:00:00 2001 From: Robert Soriano Date: Sun, 30 Oct 2022 21:09:42 -0700 Subject: [PATCH] allow passing of other client options --- src/client/index.ts | 5 +++-- src/server.ts | 23 +++++++++-------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/client/index.ts b/src/client/index.ts index be9f210..d4681e8 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -30,11 +30,12 @@ function createNuxtProxyDecoration(name: string, clie const path = pathCopy.join('.') - const [input, asyncDataOptions] = args + // @ts-expect-error: Additional options + const [input, { trpc, ...asyncDataOptions }] = args const queryKey = getQueryKey(path, input) - return useAsyncDataWithError(queryKey, () => (client as any)[path][lastArg](input), asyncDataOptions) + return useAsyncDataWithError(queryKey, () => (client as any)[path][lastArg](input, trpc), asyncDataOptions) }) } diff --git a/src/server.ts b/src/server.ts index 7194cf5..2fa6305 100644 --- a/src/server.ts +++ b/src/server.ts @@ -71,23 +71,18 @@ export function createNuxtApiHandler({ const path = getPath(event) if (path === null) { - const error = router.getErrorShape({ - error: new TRPCError({ - message: - 'Param "trpc" not found - is the file named `[trpc]`.ts or `[...trpc].ts`?', - code: 'INTERNAL_SERVER_ERROR', - }), - type: 'unknown', - ctx: undefined, - path: undefined, - input: undefined, - }) - throw createError({ statusCode: 500, statusMessage: JSON.stringify({ - id: -1, - error, + error: new TRPCError({ + message: + 'Query "trpc" not found - is the file named `[trpc]`.ts or `[...trpc].ts`?', + code: 'INTERNAL_SERVER_ERROR', + }), + type: 'unknown', + ctx: undefined, + path: undefined, + input: undefined, }), }) }