Kranga
Kranga
TtRPC
Created by Kranga on 5/4/2024 in #❓-help
All my mutations are failing due to an empty body after upgrading to 11.0.0-rc.362
TRPCError: JSON Parse error: Unexpected EOF\n at new TRPCError (/mnt/c/Users/Ángel/IdeaProjects/back/node_modules/.pnpm/@trpc+server@11.0.0-rc.362/node_modules/@trpc/server/dist/unstable-core-do-not-import/error/TRPCError.mjs:51:12)\n at <anonymous> (/mnt/c/Users/Ángel/IdeaProjects/back/node_modules/.pnpm/@trpc+server@11.0.0-rc.362/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/contentType.mjs:23:30)\n at processTicksAndRejections (:12:39) I have tried debugging in http/contentType.mjs and I found the request body is coming empty even if it shows a body on the browser devtools. Originally happened after upgrading a lot of rc.xxx versions at once but I pinpointed it on rc.362. The mutation works fine on rc.361 even using rc.364 on the client. I am using bun as the runtime.
2 replies
TtRPC
Created by Kranga on 12/23/2023 in #❓-help
Subscription types are not inferred while queries and mutations are working fine
No description
3 replies
TtRPC
Created by Kranga on 7/28/2023 in #❓-help
Procedure return types are getting inferred as any
Hi, I just created a prisma + trpc backend which uses prisma-trpc-generator to generate trpc routers from the prisma schema. I noticed that while procedure parameters are correctly typed the return type is not getting inferred. This is not a monorepo-related issue since I moved my client to the server directory and the return types are inferred as TProcedure["_def"]["_config"]["transformer"] extends DefaultDataTransformer ? Serialize<TProcedure["_def"]["_output_out"]> : TProcedure["_def"]["_output_out"], a type that despite not being any behaves exactly like any, not providing any type-checks or autocompletion. Is there any tsconfig that "just works" for trpc? I have spent so much time fiddling with my tsconfig.json and can't get it to work.
4 replies
TtRPC
Created by Kranga on 11/28/2022 in #❓-help
Is it possible to call a query from another query defined in the same router?
Say I have some code like the following:
t.router({
compute_all: t.procedure
.query(async ({ctx, input})=>{
//Receives an array of computable objects and applies the transformation defined in compute_one
const result = await Promise.all(input.datasets.map(x=>/*SOMETHING_SHOULD_BE_HERE*/));
return result;
}),
compute_one: t.procedure
.query(async ({ctx, input})=>{
const result = '...';//Fetches data and does some transformation on it
return result;
})
})
t.router({
compute_all: t.procedure
.query(async ({ctx, input})=>{
//Receives an array of computable objects and applies the transformation defined in compute_one
const result = await Promise.all(input.datasets.map(x=>/*SOMETHING_SHOULD_BE_HERE*/));
return result;
}),
compute_one: t.procedure
.query(async ({ctx, input})=>{
const result = '...';//Fetches data and does some transformation on it
return result;
})
})
Is it posible to reuse the compute_one query logic within the compute_all query without extracting the common logic outside the router? I have tried doing it via instantiating a client using that same router and executing the query as usual from within the query but I get 'default' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. due to the router=>client=>router circular reference.
3 replies
TtRPC
Created by Kranga on 10/20/2022 in #❓-help
Trouble inferring the type of a very simple structure of nested routers
10 replies