Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use null type instead of optional for generated type #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nbaron1
Copy link

@nbaron1 nbaron1 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

@nbaron1 nbaron1 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