minor fixes
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"description": "SolidJS tRPC",
|
"description": "SolidJS tRPC",
|
||||||
"author": "OrJDev",
|
"author": "OrJDev",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "0.0.5-rc.1",
|
"version": "0.0.6-rc.1",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public",
|
"access": "public",
|
||||||
"tag": "next"
|
"tag": "next"
|
||||||
|
|||||||
@@ -392,35 +392,32 @@ export function createHooksInternal<
|
|||||||
opts?.().enabled !== false &&
|
opts?.().enabled !== false &&
|
||||||
!ctx.queryClient.getQueryCache().find(getArrayQueryKey(pathAndInput()))
|
!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;
|
opts?.().trpc?.abortOnUnmount ?? ctx?.abortOnUnmount ?? false;
|
||||||
const hook = __useQuery(
|
const hook = __useQuery(
|
||||||
() => getArrayQueryKey(pathAndInput()),
|
() => getArrayQueryKey(pathAndInput()),
|
||||||
(queryFunctionContext) => {
|
(queryFunctionContext) => {
|
||||||
const actualOpts = () => ({
|
const actualOpts = () => ({
|
||||||
...ssrOpts,
|
...opts?.(),
|
||||||
trpc: {
|
trpc: {
|
||||||
...ssrOpts?.trpc,
|
...opts?.()?.trpc,
|
||||||
...(shouldAbortOnUnmount
|
...(shouldAbortOnUnmount()
|
||||||
? { signal: queryFunctionContext.signal }
|
? { signal: queryFunctionContext.signal }
|
||||||
: {}),
|
: {}),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return (ctx.client as any).query(
|
return (ctx.client as any).query(
|
||||||
...getClientArgs(pathAndInput(), actualOpts())
|
...getClientArgs(pathAndInput(), actualOpts())
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
{ context: SolidQueryContext, ...ssrOpts } as any
|
{ context: SolidQueryContext, ...opts?.() } as any
|
||||||
) as UseTRPCQueryResult<TData, TError>;
|
) as UseTRPCQueryResult<TData, TError>;
|
||||||
hook.trpc = useHookResult({
|
hook.trpc = useHookResult({
|
||||||
path: pathAndInput()[0],
|
path: pathAndInput()[0],
|
||||||
});
|
});
|
||||||
|
|
||||||
return hook;
|
return hook;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,16 +25,9 @@ export function createSolidProxyDecoration<
|
|||||||
if (lastArg === "useMutation") {
|
if (lastArg === "useMutation") {
|
||||||
return (hooks as any)[lastArg](path, ...args);
|
return (hooks as any)[lastArg](path, ...args);
|
||||||
}
|
}
|
||||||
const [input, ...rest] = args;
|
|
||||||
return (hooks as any)[lastArg](
|
return (hooks as any)[lastArg](
|
||||||
() => getQueryKey(path, typeof input === "function" ? input() : input),
|
() => getQueryKey(path, (args[0] as any)()),
|
||||||
() => {
|
args[1]
|
||||||
let p = {};
|
|
||||||
for (const r of rest) {
|
|
||||||
p = { ...p, ...(typeof r === "function" ? r() : r) };
|
|
||||||
}
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user