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

generateImmutableModels = true conflicts with generateNoArgsConstructorOnly = true #1285

Open
asoftwareguy opened this issue Aug 1, 2023 · 0 comments
Labels
bug Something isn't working good-first-issue Good for newcomers

Comments

@asoftwareguy
Copy link

asoftwareguy commented Aug 1, 2023

Issue Description

When configuring the Gradle plugin, I want the code generator to produce immutable objects, so I set the config as:

graphqlCodegen {
    // other config...
    generateImmutableModels = true
}

This still produced the public constructor, so I tried adding:

graphqlCodegen {
    // other config...
    generateImmutableModels = true
    generateNoArgsConstructorOnly = true
}

This resulted in non-compiling code.

Steps to Reproduce

The steps to reproduce should be the same as listed above. None of the other config values I had defined seemed to affect the behavior.

Expected Result

When generateImmutableModels is set to true, the all args constructor should be generated as package-private regardless of the setting for generateNoArgsConstructorOnly.

Actual Result

generateNoArgsConstructorOnly = true completely eliminates the all args constructor, resulting in non-compiling code.
generateNoArgsConstructorOnly = true leaves a public constructor, so the object is not immutable.

Your Environment and Setup

  • graphql-java-codegen version: 5.8.0
  • Build tool: Gradle
def graphqlCodegenSourcesDir = "$buildDir/generated/sources/graphqlCodegen"
sourceSets.main.java.srcDirs += graphqlCodegenSourcesDir

graphqlCodegen {
    graphqlSchemas {
        rootDir = "$projectDir/src/main/resources/graphql"
    }
    generateApis = false
    generateEqualsAndHashCode = true
    generateImmutableModels = true
    generateNoArgsConstructorOnly = true
    generateToString = true
    modelValidationAnnotation = '@javax.annotation.Nonnull'
    outputDir = new File(graphqlCodegenSourcesDir)
    packageName = 'a.b.c.graphql.model'
}
@asoftwareguy asoftwareguy added the bug Something isn't working label Aug 1, 2023
@kobylynskyi kobylynskyi added the good-first-issue Good for newcomers label Nov 9, 2023
@kobylynskyi kobylynskyi added this to the 5.9.0 milestone Nov 9, 2023
@kobylynskyi kobylynskyi removed this from the 5.9.0 milestone Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good-first-issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants