Skip to content

Conversation

longergrass
Copy link

@longergrass longergrass commented Feb 27, 2024

When dealing with optional data prisma generates the type as null or the desired type.
Currently the generator makes it undefined or the desired type.

For example the prisma generated type for the Post model is currently

export type Post = {
  id: number
  userId: number | null
}

however the generator creates the type as:

export const Post = Type.Object({
  id: Type.Number(),
  userId: Type.Optional(Type.Number()),
});

which is the same as number | undefined

Fixes: #19

@longergrass longergrass changed the title fix: null type instead of optional for generated type fix: use null type instead of optional for generated type Feb 27, 2024
@Dan-Shields
Copy link

I encountered the same and switching to m1212e/prismabox (a fork of this repo) fixed the issue by adding __nullable__ to its schemas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optional types in query results derive from typescript type
2 participants