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

Settings to skip generation of include and select fields #85

Closed
oceandrama opened this issue Feb 17, 2023 · 2 comments
Closed

Settings to skip generation of include and select fields #85

oceandrama opened this issue Feb 17, 2023 · 2 comments

Comments

@oceandrama
Copy link

First of all, thanks for your project!

I'm using this package with trpc to generate inputs of procedures, like this

findMany: t.procedure.input(ArticleFindManyArgsSchema).query(({ input}) => {
  return prisma.article.findMany(input);
}),

Unfortunately with current limitations of TS (trpc/trpc#2150, microsoft/TypeScript#1213), it's impossible to correct infer return type if you are using select or include

trpc.article.findMany.useQuery(select: {id: true}}) // return type is still Article not {id: number}

so, I want to explicit exclude select and include from input arguments
Unfortunately with current limitation of Zod (#79, #41) it's impossible to do something like this

ArticleFindManyArgsSchema.omit({select: true, include: true})

so maybe you can extends settings like https://github.com/omar-dulaimi/prisma-zod-generator has (isGenerateSelect and isGenerateInclude) to omit this fields from schemas. Are there another solutions?

@oceandrama oceandrama changed the title Options not to generate include and select fields Settings to skip generation of include and select fields Feb 17, 2023
@chrishoermann
Copy link
Owner

@oceandrama Thanks for the suggestion. I wasn't aware that this does not work as expected.

In the latest version you can now opt out of the features by adding addIncludeType = false and addSelectType = false to the generator config. See docs.

I just removed the fields from the [Model]ArgTypeSchemas but the include and select schemas are still generated (if you have some use for it??)

@oceandrama
Copy link
Author

@chrishoermann Wow, blazing fast! Thanks a lot, it works perfectly! I think it maybe usefull to save include and select schemas, but now I'm not using it

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

No branches or pull requests

2 participants