Open
Description
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'
}