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

Option to opt-out of "One" suffix for generated create/update/delete mutations (v 0.21.0)

Open mdesousa opened this issue 1 year ago • 6 comments

Is your feature request related to a problem? Please describe. Version 0.21.0 changes the name of generated mutations from createXYZ to createOneXYZ (similar for update / delete). This introduces a sizable effort to migrate to Prisma 4 and typgraphql-prisma 0.21.0. Also, I personally liked the old naming convention better 😬. It was clear and concise... the One suffix doesn't really add much value.

Describe the solution you'd like Would you consider adding an option to opt-out of the One suffix? Or alternatively, check with the community and go back to the old approach if there is sufficient support?

Thanks! Otherwise, v 0.21.0 looks great... typegraphql-prisma is an amazing package, appreciate all the work that goes into it.

mdesousa avatar Jul 11 '22 11:07 mdesousa

typegraphql-prisma always tries to minimize the translations and traction between Prisma DMMF and generated resolvers. Having to adjust, transform and simplify is currently out of scope because otherwise I couldn't even follow with the changes and upgrades of Prisma Client API and features.

However, I agree that this breaking change might be hard to upgrade for users that have an existing GraphQL API. We definitely can have a generator option to use the "standard" naming, but I can't provide any ETA for that.

MichalLytek avatar Jul 11 '22 12:07 MichalLytek

Because of the scope of this change, is there a reason this particular release was not marked as a breaking change (1.0.0)? Does typegraphql-prisma follow semver for versioning?

SheaBelsky avatar Jul 26 '22 20:07 SheaBelsky

@SheaBelsky Please read about semver in 0.x releases

https://semver.org/

Major version zero (0.y.z) is for initial development. Anything MAY change at any time. The public API SHOULD NOT be considered stable.

npm treats 0.x releases as 0.major.minor: https://github.com/npm/node-semver#caret-ranges-123-025-004

MichalLytek avatar Jul 26 '22 20:07 MichalLytek

TIL - sorry for my initial misunderstanding!

SheaBelsky avatar Jul 26 '22 20:07 SheaBelsky

Rather than trying to define "standard", I would vote for something more generic like an explicit rename mapping in generator config (createOne: create).

Also, @MichalLytek, there are several generator examples in the docs that are now wrong due to this change. For example, showing createCategory as the key when it should now be createOneCategory for the TS to be valid.

aldeed avatar Jul 27 '22 11:07 aldeed

@aldeed You're right. The problem deeps down even further - the Prisma input names are still using the old name, so we have in schema e.g. createOneCreator(data: CreatorCreateInput!): Creator! 😕

Explicit mapping is tricky as we already have hardcoded mapping like findManyUser -> users via the useOriginalMapping = true generator option.

MichalLytek avatar Jul 27 '22 12:07 MichalLytek