fixed tRPC createInfiniteQuery no refresh when input change #1

This commit is contained in:
OrJDev
2022-10-17 00:06:57 +03:00
parent c7f622a0cc
commit c613af8d9a
3 changed files with 8 additions and 7 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "solid-trpc", "name": "solid-trpc",
"version": "0.0.8", "version": "0.0.9",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "solid-trpc", "name": "solid-trpc",
"version": "0.0.8", "version": "0.0.9",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@babel/core": "^7.18.13", "@babel/core": "^7.18.13",
+1 -1
View File
@@ -3,7 +3,7 @@
"description": "SolidJS tRPC", "description": "SolidJS tRPC",
"author": "OrJDev", "author": "OrJDev",
"license": "MIT", "license": "MIT",
"version": "0.0.8", "version": "0.0.9",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
+5 -4
View File
@@ -176,9 +176,7 @@ export function createSolidQueryHooks<TRouter extends AnyRouter>() {
TError TError
> >
): CreateInfiniteQueryResult<TQueryValues[TPath]["output"], TError> { ): CreateInfiniteQueryResult<TQueryValues[TPath]["output"], TError> {
const [path, input] = pathAndInput();
const ctx = useContext(); const ctx = useContext();
if ( if (
typeof window === "undefined" && typeof window === "undefined" &&
opts?.enabled !== false && opts?.enabled !== false &&
@@ -190,9 +188,12 @@ export function createSolidQueryHooks<TRouter extends AnyRouter>() {
return __createInfiniteQuery( return __createInfiniteQuery(
pathAndInput as any, pathAndInput as any,
({ pageParam }) => { ({ pageParam }) => {
const actualInput = { ...((input as any) ?? {}), cursor: pageParam }; const actualInput = {
...((pathAndInput()[1] as any) ?? {}),
cursor: pageParam,
};
return (ctx.client as any).query( return (ctx.client as any).query(
...getClientArgs([path, actualInput], opts) ...getClientArgs([pathAndInput()[0], actualInput], opts)
); );
}, },
opts as any opts as any