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

Enabling generateAsInternal in combination with nonempty sealedClassesForEnumsMatching generates invalid classes definitions #6212

Open
marosseleng opened this issue Oct 21, 2024 · 0 comments

Comments

@marosseleng
Copy link

Version

4.0.1

Summary

I have my apollo service defined in build.gradle.kts as follows:

apollo {
    service("myService") {
        packageName.set("...")
        schemaFile.set(file("..."))

        introspection {
            ...
        }
        generateAsInternal = true
        sealedClassesForEnumsMatching.set(setOf(".*"))
    }
}

I enabled sealedClassesForEnumsMatching just recently, because I wanted to access the raw value of the UNKNOWN__ constant. However, the generated classes for UNKNOWN__ constant looks like this:

private internal class UNKNOWN__MyModelClass(
  override val rawValue: String,
) : MyModelClass.UNKNOWN__ {
  override fun equals(other: Any?): Boolean {
    if (other !is UNKNOWN__MyModelClass) return false
    return this.rawValue == other.rawValue
  }

  override fun hashCode(): Int = this.rawValue.hashCode()

  override fun toString(): String = "UNKNOWN__($rawValue)"
}

If i disable generateAsInternal = true the problem doesn't occur, only private modifier remains on the generated class' definition.

The build then fails on invalid syntax.

I believe this is a bug.

Steps to reproduce the behavior

No response

Logs

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant