diff --git a/package.json b/package.json index 14e6c5a..ef78730 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "SolidJS tRPC", "author": "OrJDev", "license": "MIT", - "version": "0.0.5-rc.1", + "version": "0.0.6-rc.1", "publishConfig": { "access": "public", "tag": "next" diff --git a/src/shared/hooks/createHooksInternal.tsx b/src/shared/hooks/createHooksInternal.tsx index 1099028..757e90b 100644 --- a/src/shared/hooks/createHooksInternal.tsx +++ b/src/shared/hooks/createHooksInternal.tsx @@ -392,35 +392,32 @@ export function createHooksInternal< opts?.().enabled !== false && !ctx.queryClient.getQueryCache().find(getArrayQueryKey(pathAndInput())) ) { - void ctx.prefetchQuery(pathAndInput(), opts as any); + void ctx.prefetchQuery(pathAndInput(), opts?.() as any); } - const ssrOpts = useSSRQueryOptionsIfNeeded(pathAndInput(), opts?.()); - // request option should take priority over global - const shouldAbortOnUnmount = + + const shouldAbortOnUnmount = () => opts?.().trpc?.abortOnUnmount ?? ctx?.abortOnUnmount ?? false; const hook = __useQuery( () => getArrayQueryKey(pathAndInput()), (queryFunctionContext) => { const actualOpts = () => ({ - ...ssrOpts, + ...opts?.(), trpc: { - ...ssrOpts?.trpc, - ...(shouldAbortOnUnmount + ...opts?.()?.trpc, + ...(shouldAbortOnUnmount() ? { signal: queryFunctionContext.signal } : {}), }, }); - return (ctx.client as any).query( ...getClientArgs(pathAndInput(), actualOpts()) ); }, - { context: SolidQueryContext, ...ssrOpts } as any + { context: SolidQueryContext, ...opts?.() } as any ) as UseTRPCQueryResult; hook.trpc = useHookResult({ path: pathAndInput()[0], }); - return hook; } diff --git a/src/shared/proxy/decorationProxy.ts b/src/shared/proxy/decorationProxy.ts index e9388a3..9829e97 100644 --- a/src/shared/proxy/decorationProxy.ts +++ b/src/shared/proxy/decorationProxy.ts @@ -25,16 +25,9 @@ export function createSolidProxyDecoration< if (lastArg === "useMutation") { return (hooks as any)[lastArg](path, ...args); } - const [input, ...rest] = args; return (hooks as any)[lastArg]( - () => getQueryKey(path, typeof input === "function" ? input() : input), - () => { - let p = {}; - for (const r of rest) { - p = { ...p, ...(typeof r === "function" ? r() : r) }; - } - return p; - } + () => getQueryKey(path, (args[0] as any)()), + args[1] ); }); }