typegraphql-prisma
typegraphql-prisma copied to clipboard
feat: allow for custom action mapping function
Provides the ability to provide a custom mapping function for actions when the default behavior is not ideal. This provides a route that fixes #327 by allowing a custom mapping function to define naming criteria.
This also appears on the surface that it would solve #306
Thanks for your contribution! ❤️
However, I found this approach a bit overkill in terms of fixing the no plural form and fallback naming issue. I would like to not introduce yet another way to provide customization by config/configuration like custom functions in custom files.
I prefer to be consistent and stick with the comment "directives" in the prisma schema file to provide custom plural form of the model name for some conflicting words.
/// @@TypeGraphQL.plural(form: "equipments")
/// or
/// @@TypeGraphQL.model(plural: "equipments")
model Equipment {
id String @id @default(cuid())
}
I have done it on my local branch, will try to add tests and docs and publish new release today 😃
Directives are fine to me, yes, my solution was overkill was looking for a way to provide the ability to overwrite any name that was generated which was why I went the custom mapping route, but this solves my direct problem, look forward to seeing it in the codebase!