LittleLily
TTCTheo's Typesafe Cult
•Created by Xiangyi Li on 12/4/2023 in #questions
How does tRPC.io and TypeScriptlang.org displays type with ^?
There's a vscode extension for it
https://marketplace.visualstudio.com/items?itemName=Orta.vscode-twoslash-queries
4 replies
DTDrizzle Team
•Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
It seems like most of that query could be written with the query API and a
with
clause to do all the CTEs using relations instead44 replies
Page couldn't be rendered statically because it used `cookies`
Even though the detection of dynamic routes/pages is mentioned in the docs somewhere, I think it would be better if it was made a little more obvious and upfront in the docs that the detection of dynamic vs static routes isn't always going to work, and I think it should recommend that you should probably just explicitly set force dynamic on routes that you know will use cookies, because otherwise the build will just decide to fail randomly one day when you refactor code that is functionally identical but stumps the detection in nextjs
9 replies
Page couldn't be rendered statically because it used `cookies`
It seems like the most likely cause for getting the error is the failure of the nextjs auto-detection of dynamic routes based on use of cookies/etc due to it not being able to follow the chain of calls that results in cookies being used. It's happened to me a few times where I had a page that used cookies, then I moved the cookie usage to an external file that the page imported instead, and that must break the auto-detection and so nextjs thinks the page can be statically rendered even though it can't in reality. If that's the situation you're in then setting force-dynamic is the correct solution since it likely already needed to be dynamic, it just wasn't able to be detected.
9 replies
Error building create-t3-app: Page couldn't be rendered statically because it used `cookies`
It's specifically only occurring when I make a trpc call on a page/server component to a procedure that requires auth from cookies. Weirdly though if I call the same authentication function that trpc uses directly from the page instead it works, just not when trpc does it
4 replies
Vanilla Client Error Handling
also interested in knowing what the best solution for globally handling errors when using
createTRPCProxyClient
is. I found this discussion https://github.com/trpc/trpc/discussions/2036 but none of the solutions there seem to really be what I want. I'd like to be able to return custom responses to the client like 302 redirects on auth failures and such, but it seems like only createTRPCNext
really supports that with its responseMeta
field.10 replies
How does trpc typing work
And you probably want to use method chaining like trpc does, which means instead of setting a property on a class, you have a method which returns a new class instance containing the functions that can be called from that point (I prefer implementing that without classes at all and just returning objects with functions inside them)
8 replies
TTCTheo's Typesafe Cult
•Created by cadams on 11/3/2023 in #questions
Do you manually create Zod schemas for your Prisma models?
It's also good for adding openapi metadata for zod-openapi
11 replies
TTCTheo's Typesafe Cult
•Created by cadams on 11/3/2023 in #questions
Do you manually create Zod schemas for your Prisma models?
There's a second argument to createSelectSchema/createUpdateSchema that lets you extend/refine the definition of each field to add stuff like min/max bounds, extra validation like email/url/regex, and you can put custom messages in there too if you want
11 replies
TTCTheo's Typesafe Cult
•Created by JulieCezar on 11/9/2023 in #questions
How can I write this type with Zod?
You have an extra level of nesting of a text property with an array + object inside, try removing one of the
{ text: z.array(z.object(...)) }
levels4 replies