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

Add config option to enable specific model actions #68

Merged

Conversation

lottamus
Copy link
Contributor

@lottamus lottamus commented Feb 20, 2023

Description

Currently, we're generating a route for every possible model action, sometimes resulting in unused code.

This PR adds an optional config to enable specific model actions.

Example Input:

generator trpc {
  provider           = "prisma-trpc-generator"
  generateModelActions = "create,delete,findFirst,findMany,findUnique,update,upsert"
}

Example output:

image

References

It would be much nicer to allow providing an array for generateModelActions, however it seems this currently is not possible: prisma/prisma#9511

Other

We could also expose this functionality at the model level too

/// @@Gen.model(actions: [create,delete,findFirst,findMany,findUnique,update,upsert])
model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
  posts Post[]
  books Book[]
}

@omar-dulaimi
Copy link
Owner

This is a cool addition. Thanks for your work on this and other PRs

@omar-dulaimi
Copy link
Owner

We should also pass these options values to Zod generator under the hood so it could skip any extra schemas from being generated. That is for a future thing of course.

@omar-dulaimi omar-dulaimi merged commit 89710fb into omar-dulaimi:master Feb 24, 2023
@omar-dulaimi
Copy link
Owner

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.

None yet

2 participants