Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BlasiusSecundus
Copy link

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

@congotej
Copy link

Hi @BlasiusSecundus! Thank you for opening this PR, I am actively looking into this. In the meantime, could you please resolve the conflicts?

@BlasiusSecundus BlasiusSecundus force-pushed the feature/389-cusomt-generated-class-name-templates branch from 9bb7f71 to 2cb13d9 Compare May 26, 2023 06:13
@BlasiusSecundus
Copy link
Author

I have resolved conflicts. However, when running the tests locally I saw KotlinCodeGenTest failing with errors like this one:

error: unresolved reference: fasterxml
import com.fasterxml.jackson.`annotation`.JsonProperty
           ^
error: cannot access built-in declaration 'kotlin.String'. Ensure that you have a dependency on the Kotlin standard library
import kotlin.String

I have not noticed this before, and this also happens on master branch, so I think this should not be related to my PR.

@BlasiusSecundus BlasiusSecundus force-pushed the feature/389-cusomt-generated-class-name-templates branch from 938bf05 to 7aa0855 Compare June 20, 2023 04:38
@mfjBiz
Copy link

mfjBiz commented Sep 27, 2023

@BlasiusSecundus
Hello, thank you for your work on this PR. We find it to be incredibly valuable for our use case.

Regarding the KotlinCodeGenTest failure you mentioned, I've checked out the latest master branch and it seems that the issue may have been resolved there.

@BlasiusSecundus BlasiusSecundus force-pushed the feature/389-cusomt-generated-class-name-templates branch 2 times, most recently from 49c094c to 4e88294 Compare September 27, 2023 17:45
@BlasiusSecundus
Copy link
Author

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.

@mfjBiz
Copy link

mfjBiz commented Sep 28, 2023

@BlasiusSecundus
Thank you for taking the time to rebase and resolve the conflicts. It's good to hear that the CI build job ran successfully on your forked repo.

@congotej
I noticed your previous comment about actively looking into this PR. Could I kindly ask for an update on the current status of this PR?
We're really looking forward to benefiting from this feature. Thank you!

@BlasiusSecundus BlasiusSecundus force-pushed the feature/389-cusomt-generated-class-name-templates branch from 4e88294 to 8cf71ae Compare January 21, 2024 15:55
… 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
@BlasiusSecundus BlasiusSecundus force-pushed the feature/389-cusomt-generated-class-name-templates branch from 8cf71ae to 8d2dc23 Compare January 21, 2024 16:00
@BlasiusSecundus
Copy link
Author

Btw. This PR should also address issue #323

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants