Skip to content

Commit c70aaed

Browse files
committed
Test a union loop that doesn't include the union being built
1 parent 6076716 commit c70aaed

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎src/test/kotlin/graphql/kickstart/tools/SchemaParserTest.kt‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,21 @@ class SchemaParserTest {
290290
assertEquals(error.message, "Union 'Result' contains itself through Result -> Media -> Result at line 6, column 23.")
291291
}
292292

293+
@Test
294+
fun `parser should throw descriptive exception when nested unions list each other`() {
295+
val error = assertThrows(SchemaError::class.java) {
296+
unionParser(
297+
"""
298+
|union Result = Book | A
299+
|union A = B
300+
|union B = C
301+
|union C = A | Movie
302+
""".trimMargin())
303+
}
304+
305+
assertEquals(error.message, "Union 'A' contains itself through A -> B -> C -> A at line 8, column 11.")
306+
}
307+
293308
@Test
294309
fun `parser should throw descriptive exception when union lists itself`() {
295310
val error = assertThrows(SchemaError::class.java) {

0 commit comments

Comments
 (0)