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

Enum imports when using includeEnumImports do not generate a static import statement in the generated types file. #595

Open
anjana-keshav opened this issue Aug 26, 2023 · 1 comment

Comments

@anjana-keshav
Copy link

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.

@ellebrecht
Copy link

I can confirm this issue is still present with the latest version 6.1.0 that we're using.

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

No branches or pull requests

2 participants