-
Notifications
You must be signed in to change notification settings - Fork 99
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
feat(#389): allow templating for generated Java / Kotlin class names #535
base: master
Are you sure you want to change the base?
feat(#389): allow templating for generated Java / Kotlin class names #535
Conversation
Hi @BlasiusSecundus! Thank you for opening this PR, I am actively looking into this. In the meantime, could you please resolve the conflicts? |
9bb7f71
to
2cb13d9
Compare
I have resolved conflicts. However, when running the tests locally I saw
I have not noticed this before, and this also happens on master branch, so I think this should not be related to my PR. |
938bf05
to
7aa0855
Compare
@BlasiusSecundus Regarding the |
49c094c
to
4e88294
Compare
I rebased and resolved the conflicts. The aforementioned error still occurs on my machine (asl on master), but the CI build job ran successfully (on my forked repo at least). So maybe this is something related to my local setup only, I'll check. |
@BlasiusSecundus @congotej |
8cf71ae
to
8d2dc23
Compare
Btw. This PR should also address issue #323 |
0f12a5f
to
4f6277c
Compare
@srinivasankavitha @congotej don't mean to rush you but can you please review this? If there's any changes expected, please let us know. We've been eagerly waiting for this one. |
Hi - apologies for the delayed responses on this PR. Could you please elaborate on how this feature would be useful for the projects you are working with? Is it more to address code readability when working with generated types? The plugin itself is designed to do a few things well, and imo, over time we've added way too many customizations already that are making this hard to maintain and ensure correctness. I'm hesitant to add more feature flags unless they really make it worth the maintenance cost. |
For example, you have a
Essentially yes, It makes the code much easier to read. (Is that
This feature is meant to be an equivalent of OpenAPI Generator's |
I agree with your point about there being too many customizations. However, lack of this feature causes too much confusion and conflicts, as @BlasiusSecundus pointed out above. We resorted to adding manual prefixes to our graphql types to overcome the conflicts but that has led to much more confusion and chaos on the consumer side as this made our types from one particular repo out-of-sync with the naming convention that the rest of our types follow. This is especially painful given that some of these types are exposed to the rest of the world (via a graphql api for devs). Hope this feature will be available soon. |
@srinivasankavitha @congotej what do you think? |
@paulbakker and I discussed this and we will merge this after some testing on our end. Thanks for the PR contribution! |
This Feature will be of great help to avoid conflicts and readability, waiting for this one!!!!! |
I agree with @SankarshanDudhate ! We are following |
I tested this with a random test schema, and get some compilation issues because the naming isn't applied everywhere, it looks like. Example schema:
E.g. this generates
Naming I configured: @BlasiusSecundus can you look into this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test and fix use of interfaces.
@paulbakker Thank you for the review and testing! Ill fix the issue of course and will add a test case for this scenario. At first glance the problem seems to be that for the |
@BlasiusSecundus if you need help finishing this, I can jump in. If yes, would you suggest forking your repo or do you prefer some other approach? |
Hi thanks @SankarshanDudhate. The fix is already in progress on my side, it just so happened that I have a lack of time lately and could not finish it yet. But it is not forgotten, I hope I can finish it in the near future. |
So I would ask for some more time, but for now I would not suggest to fork it and start working on it separately, as it would probably just duplicate the effort. |
I feel you on the lack of time. Don't mean to rush you, just offering for help. I'll fork it in the meantime and try to finish it. |
Sure, feel free to give it a try. |
16e69fa
to
0deb5a4
Compare
… names Adds an optional `nameTemplate` input parameter to the plugin, allowing customization of the generated Java / Kotlin class names. The following template variables are supported: - name - the original name of the class - schemaType - the GraphQL schema type (Type, Input, Interface, Enum) The default value for this new property is null. In this case the output will be identical to the current one. Examples: Given an original class name `Person` and schema type `Type`: - null -> Person - "{name}GraphQL{schemaType}" -> PersonGraphQLType - "{name}GraphQL" -> PersonGraphQL - "{name}{schemaType}" -> PersonType
@SankarshanDudhate meanwhile I managed to work on the fix, see the updated version of the PR. cc @paulbakker , could you please retest/validate the fix? |
Adds an optional
nameTemplate
input parameter to the plugin, allowing customization of the generated Java / Kotlin class names.The following template variables are supported:
The default value for this new property is null. In this case the output will be identical to the current one.
Examples:
Given an original class name
Person
and schema typeType
: