omar-dulaimi / prisma-trpc-generator

Prisma 2+ generator to emit fully implemented tRPC routers
MIT License
675 stars 34 forks source link

Add config to hide model name in procedure #67

Closed emab closed 1 year ago

emab commented 1 year ago

Description

This PR adds an optional boolean configuration variable for the generator called showModelNameInProcedure which is true by default.

When enabled the generated output is slightly modified - instead of getting names like this:

The model name "X" is removed leaving only:

The reason I think people may like this (I do personally) is that the tRPC router name itself provides the context of what object you're mutating or querying.

userRouter.findFirst({ where: { id: 1 } }) reads perfectly fine wheras userRouter.findFirstUser({ where: { id: 1 } }) seems overly verbose.

Interested to hear your thoughts!

References

Discussion thread:

omar-dulaimi commented 1 year ago

I like how this simplifies and shortens the names. Code looks good to me. Just make sure to document the new flag across the README.

Other than that, we're ready to merge

emab commented 1 year ago

I like how this simplifies and shortens the names. Code looks good to me. Just make sure to document the new flag across the README.

Other than that, we're ready to merge

Added the flag to the table - let me know if you'd like an example with flag on / off in the README as well.

omar-dulaimi commented 1 year ago

Released in https://github.com/omar-dulaimi/prisma-trpc-generator/releases/tag/1.1.0

Thank you for your contribution!