patrick
patrick
TtRPC
Created by patrick on 10/27/2023 in #❓-help
cache craziness?
can someone sanity check something for me? i'm using sst + trpc + drizzleorm + aws + rds + postgres on the server, and i guess trpc + tanstack-query on the client side... when i do mutations, to say delete something from a list and go optimistically update the client state, via useUtils setData etc... everything is fine... then a few seconds later the browser does a request (tanstack query?) and gets OLD data back from "disk cache" and updates the view to how it was before my mutation! then a few seconds later it updates again with the correct data... i'm having a hard time figuring out which cacheing layer is screwing up... has anyone ever seen such behavior?
6 replies
TtRPC
Created by patrick on 9/8/2023 in #❓-help
query with no input reports error
No description
4 replies
TtRPC
Created by patrick on 3/6/2023 in #❓-help
Is it possible to narrow an output schema if the query optionally doesn't return all fields?
I have a router procedure that has an input schema that has an optional filter that changes the shape of the data to only include those fields (like sql select), but those records will fail the output schema which contains all of the fields as required. is there a way to construct a .output() specification that narrows the type, possibly using z.partial() so that these partial "rows" will pass output validation?
40 replies
TtRPC
Created by patrick on 1/28/2023 in #❓-help
dynamic router creation
has anyone been able to create a dynamic router? e.g. i pass in the schema and some metadata and it produces the same routes but they are selected down to the metadata? my use case is i want to have crud against a set of tables... so i create a zod schema for each entity and want to create a router that does list, get, create, update, and delete, but for that one table, then i create one of each of these one per table... with what i've written, i'm getting the dreaded ts(2742) error.... The inferred type of 'routerForTable' cannot be named without a reference to '../../node_modules/@trpc/server/dist/core/parser.js'. This is likely not portable. A type annotation is necessary trying to pass in the schema as T extends z.ZodObject<z.ZodRawShape, z.UnknownKeysParam>
5 replies