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

Adding custom suffix to generated types #389

Open
maory opened this issue Jun 7, 2022 · 5 comments
Open

Adding custom suffix to generated types #389

maory opened this issue Jun 7, 2022 · 5 comments
Labels
enhancement New feature or request good-first-issues

Comments

@maory
Copy link

maory commented Jun 7, 2022

With DGS codegen, I want the schema types to correspond my Model entity types.

For example let's assume that I have a query in my schema:

type Dog {
name: String!
}

My generated type will be <generated_types_package>.Dog.java
In most cases, I will have another class for my model object. <model_type_package>.Dog.java

What happens in this case that in my DataFetcher I need to declare explicitly on the type package prefix, which makes the code pretty hard to read.

My suggestion is to add a custom suffix to any schema generated type (not input)
<model_type_package>.Dog.java --> <model_type_package>.DogGQL.java

@srinivasankavitha
Copy link
Contributor

I can see that being hard to use. We can looking into improving that in the future. Feel free to open a PR if you would like to have that available sooner.

@srinivasankavitha srinivasankavitha added the enhancement New feature or request label Jun 7, 2022
@maory
Copy link
Author

maory commented Jun 7, 2022

@srinivasankavitha Thank you for your response.
I will check out that, Since I am using maven I will need another PR for the maven plugin to support such kind of config.

springmonster added a commit to springmonster/dgs-codegen that referenced this issue Jun 23, 2022
springmonster added a commit to springmonster/dgs-codegen that referenced this issue Jun 27, 2022
This reverts commit ce92bc3.
@xenoterracide
Copy link

+1, I'm going to name my entities <Name>Entity but would still like this to avoid potential conflicts and to match that kind of class naming convention

@srinivasankavitha
Copy link
Contributor

srinivasankavitha commented Oct 11, 2022 via email

@xenoterracide
Copy link

I'm using gradle, just FYI

BlasiusSecundus added a commit to BlasiusSecundus/dgs-codegen that referenced this issue Mar 23, 2023
… 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 added a commit to BlasiusSecundus/dgs-codegen that referenced this issue May 26, 2023
… 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 added a commit to BlasiusSecundus/dgs-codegen that referenced this issue Jun 20, 2023
… 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 added a commit to BlasiusSecundus/dgs-codegen that referenced this issue Sep 27, 2023
… 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 added a commit to BlasiusSecundus/dgs-codegen that referenced this issue Sep 27, 2023
… 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 added a commit to BlasiusSecundus/dgs-codegen that referenced this issue Jan 21, 2024
… 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 added a commit to BlasiusSecundus/dgs-codegen that referenced this issue Jan 21, 2024
… 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 added a commit to BlasiusSecundus/dgs-codegen that referenced this issue Aug 22, 2024
… 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 added a commit to BlasiusSecundus/dgs-codegen that referenced this issue Aug 22, 2024
… 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good-first-issues
Projects
None yet
Development

No branches or pull requests

3 participants