David
David
TtRPC
Created by David on 6/4/2024 in #❓-help
Best way to get the type of the first argument for .query or .mutation
I am creating an abstraction in which I expect the consumer to pass the whole object that is passed as the first argument of .query or .mutation. But im not sure if there is a helper type to get this type from our instance?
10 replies
TtRPC
Created by David on 11/14/2023 in #❓-help
"fetch failed" when building
Hi, we are running into an issue where building our production next app causes "fetch failed" errors for every page that is being generated. We have ssr set to false. How can we debug this?
TRPCClientError: fetch failed
at TRPCClientError.from (file:///home/david/mrb-docker-dev/www/mrb-monorepo/node_modules/.pnpm/@trpc+client@10.43.3_@trpc+server@10.43.3/node_modules/@trpc/client/dist/TRPCClientError-0de4d231.mjs:37:16)
at file:///home/david/mrb-docker-dev/www/mrb-monorepo/node_modules/.pnpm/@trpc+client@10.43.3_@trpc+server@10.43.3/node_modules/@trpc/client/dist/httpUtils-f58ceda1.mjs:128:36
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
meta: {},
shape: undefined,
data: undefined,
[cause]: TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11372:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
cause: AggregateError
at internalConnectMultiple (node:net:1114:18)
at afterConnectMultiple (node:net:1667:5) {
code: 'ECONNREFUSED',
]: [Array]
}
}
}
TRPCClientError: fetch failed
at TRPCClientError.from (file:///home/david/mrb-docker-dev/www/mrb-monorepo/node_modules/.pnpm/@trpc+client@10.43.3_@trpc+server@10.43.3/node_modules/@trpc/client/dist/TRPCClientError-0de4d231.mjs:37:16)
at file:///home/david/mrb-docker-dev/www/mrb-monorepo/node_modules/.pnpm/@trpc+client@10.43.3_@trpc+server@10.43.3/node_modules/@trpc/client/dist/httpUtils-f58ceda1.mjs:128:36
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
meta: {},
shape: undefined,
data: undefined,
[cause]: TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11372:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
cause: AggregateError
at internalConnectMultiple (node:net:1114:18)
at afterConnectMultiple (node:net:1667:5) {
code: 'ECONNREFUSED',
]: [Array]
}
}
}
25 replies
TtRPC
Created by David on 10/7/2023 in #❓-help
standaloneMiddleware: Merge ctx/meta/input types
Using standaloneMiddleware, it would be great to merge the types (ctx, input, meta) with what is already there when passing that middleware. In our case:
experimental_standaloneMiddleware<{ ctx: { user: { id: number } } }>()
experimental_standaloneMiddleware<{ ctx: { user: { id: number } } }>()
this is because we want to be sure user.id exists in the context before allowing the usage of this middleware, but when returning like this: next({ ctx: { ...ctx, newProp: '' } }) you would still want the context type to be merged with the original so your queries and mutations get the complete context.
1 replies
TtRPC
Created by David on 7/29/2023 in #❓-help
Do tracked properties still work when using useSuspenseQuery?
From the React Query docs:
By default, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.
By default, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.
3 replies
TtRPC
Created by David on 7/25/2023 in #❓-help
How would batching result in a single database query?
On the httpBatchStreamLink docs it says that multiple query calls could result in a single database query. How would that work? Should you expect the passed input to possibly be an array to allow for this?
After that, you can make use of batching by setting all your procedures in a Promise.all. The code below will produce exactly one HTTP request and on the server exactly one database query:
After that, you can make use of batching by setting all your procedures in a Promise.all. The code below will produce exactly one HTTP request and on the server exactly one database query:
5 replies
TtRPC
Created by David on 5/11/2023 in #❓-help
Have middleware require a "base" input
Is there a way to have middleware add a minimum required input, like an org id? So that every procedure with that middleware always at least gets that passed in
5 replies
TtRPC
Created by David on 12/8/2022 in #❓-help
Why do some examples create PrismaClient in context, and others don’t
Is there a specific reason to do this or not to do this? I can imagine with the new Prisma extension feature you could do some handy things like attaching multi tenancy data to each query beforehand
1 replies
TtRPC
Created by David on 9/23/2022 in #❓-help
Revalidate API route from procedure
Hi, is there a way to revalidate a statically generated page from a trpc procedure? https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration#using-on-demand-revalidation
3 replies