typegraphql-prisma icon indicating copy to clipboard operation
typegraphql-prisma copied to clipboard

feat: allow for custom action mapping function

Open mwillbanks opened this issue 2 years ago • 3 comments

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.

mwillbanks avatar Sep 16 '22 03:09 mwillbanks

This also appears on the surface that it would solve #306

mwillbanks avatar Sep 16 '22 03:09 mwillbanks

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 😃

MichalLytek avatar Sep 19 '22 13:09 MichalLytek

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!

mwillbanks avatar Sep 19 '22 14:09 mwillbanks