rd
rd
Explore posts from servers
TtRPC
Created by rd on 6/9/2023 in #❓-help
All values in DecoratedProcedureRecord are of type any
I've stumbled across an issue and I'm not sure how to start diagnosing it... Basically in my IDE the return type of my createTRPCProxyClient<AppRouter>(...) call is a DecoratedProcedureRecord where every value is of type any. I'm seeing a lot of issues with TS seemingly struggling to work with this repo, I suspect that the types have become too complex with tRPC and the ORM I'm using. Is it possible that TS has just "given up" so returns any instead of the expected type? Or is it likely something else?
12 replies
TtRPC
Created by rd on 4/24/2023 in #❓-help
Error Handling vs Error Formatting
I'm a bit confused from the docs about how I should be handling errors on the server. The Error Handling section refers to handling errors client side right? More specifically, the ORM I'm using suggests delegating error handling to the server implementation. Where the ORM is throwing an instance of its internal NotFoundError class, I need to update the response http code to 404 and also hide the data associated with that error in production. Should I be doing this within the errorFormatter? Thanks!
8 replies
TtRPC
Created by rd on 4/6/2023 in #❓-help
Throwing fastify errors when using fastify adapter
Hello, I'm using fastifyTRPCPlugin from @trpc/server/adapters/fastify and trying to throw errors correctly. I usually use @fastify-sensible because I find the API clear, e.g. I can write things like fastify.httpErrors.forbidden() or fastify.httpErrors.unauthorized. However if I throw one of these in a tRPC procedure it seems the error code is always 500, assuming that's because tRPC is intercepting/handling them in some way? What's the best way to "solve" this? Thanks!
4 replies
TtRPC
Created by rd on 2/23/2023 in #❓-help
JSON inferred router output not matching
Hello. I have a procedure query which is returning Json from a postgresql db using Prisma. The type in the query on the server is showing up as JsonValue (definitions below). The inferred type from the router.procedure.query() on a createTRPCProxyClient instance comes back as expected, but the type definition using inferRouterOutputs<AppRouter> types the Json data as string | null. Any ideas? Thanks. New to tRPC so sorry if this is a no-brainer.
type JsonObject = { [Key in string]?: JsonValue };
interface JsonArray extends Array<JsonValue> {}
type JsonValue = string | number | boolean | JsonObject | JsonArray | null;
type JsonObject = { [Key in string]?: JsonValue };
interface JsonArray extends Array<JsonValue> {}
type JsonValue = string | number | boolean | JsonObject | JsonArray | null;
11 replies