Skip to content

Commit

Permalink
Added test for duplicate type definitions in constants
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbakker committed Dec 2, 2024
1 parent 9283bfe commit 601f8e8
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2069,6 +2069,30 @@ class CodeGenTest {
.containsExactly("TitleFilter", "MoveFilter")
}

@Test
fun `Dedupe type names in Constants to support multiple schema files`() {
val schema = """
type Query {
q1: String
}
type Query {
q2: String
}
""".trimIndent()

val result = CodeGen(
CodeGenConfig(
schemas = setOf(schema),
packageName = basePackageName
)
).generate()
val type = result.javaConstants[0].typeSpec
assertThat(type.typeSpecs).extracting("name").containsExactly("QUERY")
assertThat(type.typeSpecs[0].fieldSpecs).extracting("name")
.contains("Q1", "Q2")
}

@Test
fun generateUnion() {
val schema = """
Expand Down

0 comments on commit 601f8e8

Please sign in to comment.