Enum imports when using includeEnumImports do not generate a static import statement in the generated types file.
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 217
- Forks
- 116
- PR merge metrics
- No merged PRs in 30d
Description
The custom annotation follows the below schema:
type Person @annotate(name: "ValidPerson", type: "validator", inputs: {types: [HUSBAND, WIFE]}) {
name: String
}
This is expected to generate a Java class looking like the below:
package com.netflix.graphql.dgs.codegen.tests.generated.types;
import com.test.validator.ValidPerson;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
@ValidPerson(
types = [com.enums.PersonType.HUSBAND, com.enums.PersonType.WIFE]
)
public class Person {
private String name;
// Ignoring other boilerplate code because it is irrelevant to this example.
}
Note that in the build.gradle file, the following has been added:
generateJava {
//...
generateCustomAnnotations = true,
includeImports = mapOf(Pair("validator", "com.test.validator")),
includeEnumImports = ["ValidPerson": ["types": "com.enums.PersonType"]]
}
However, the generated class looks like the below instead:
package com.netflix.graphql.dgs.codegen.tests.generated.types;
import com.enums.PersonType.HUSBAND;
import com.enums.PersonType.WIFE;
import com.test.validator.ValidPerson;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
@ValidPerson(
types = [HUSBAND, WIFE]
)
public class Person {
private String name;
// Ignoring other boilerplate code because it is irrelevant to this example.
}
Since Java expects all enum imports to be static, the above-generated code causes a compile time error.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the includeEnumImports configuration from build.gradle into the generator that writes the generated types file. Compare the expected static imports with the current enum-member imports; done means the generated annotation uses static imports and the resulting Java compiles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin
- Domain
- build-system, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100