Monorepo sharing schema problem
I have turborepo where I have two packages -> drizzle-schema and api-contracts
so I try to import some table definitions from drizzle-schema module to api-contracts, which have drizzle-zod installed to generate zod schemas
but when I import table definitions from drizzle-schema, and pass them to drizzle-zod functions, I get I type errors

35 Replies
here is table definition for example
I import it in the another package, but getting a type error

to debug this I installed drizzle-zod to drizzle-schema package, and tried to create a zod schema there
everything worked fine




here is how I build types

@⚡Z.E.U.S⚡ sorry for bothering sir, but can you give me suggestions please how to fix this
Hey, @👾Rnbsov! Can you check that both packages have the same version of drizzle orm installed?
sure, I've installed the same versions in both
one moment



current type issue seems to be smaller
Can you try to delete all node_modules and reinstall?
okay
same issue
try installing
drizzle-orm@latest
, drizzle-zod@latest
, then make sure versions are consistent across the applicationI'm getting so many problems with drizzle-zod
ugh
I've already decided to declare zod schemas (insert, select, update) in drizzle-schema package
though I still experience problems


@Ling Mai Jiānguǒ What are the chanches that updating drizzle-orm (drizzle-zod is already at latest) to latest will solve the issues?
giving a try to this one
updated

same issue persistes

Can I see the table schema that causes the problem?
Last time I tried to reuse
drizzle-zod
to share schemas between Front-end and Back-end, I found that drizzle-zod
was leaking into the client bundle (I don't remember if drizzle-orm
was leaking too.)
So I'm not sure if this is a good idea in general.
It would be nice if there was a way to code gen those schemas and then share them.@Ling Mai Jiānguǒ @⚡Z.E.U.S⚡ how do I handle my specific use case?
you should import from "zod/v4"
starting from
drizzle-zod@0.8.1
drizzle-zod is only compatible with v4thanks! this fixed the issue 😃👍
were there any release notes about the v4 compatibility?
wish it would be covered in the docs, so I created a PR that adds this information
https://github.com/drizzle-team/drizzle-orm-docs/pull/556
I've tried to move schema validators definitions from
drizzle-schema
package back to api-contracts
, so I've installed specific version of drizzle-zod@0.8.0
there (because @ts-rest
library is not yet compatible with zod
v4)and in
api-contracts/src/schema-validators.ts/
I try to import schemas definitions from drizzle-schema
package
but I get a type error:

I don't understand why creating validation schemas in
drizzle-schema
package works without any type problems, but if I try to import same table definitions and create validation schemas in api-contracts
package causes issues
@Ling Mai Jiānguǒ could you please help me on this one
@Andrii Sherman What might be the problem?
@Andrew Sherman @⚡Z.E.U.S⚡ @S. Reka What's the issue, should I create an github issue for this?