From 97fb6459e586f0078559ece512ed682b2be3395c Mon Sep 17 00:00:00 2001 From: Andreas Marek Date: Tue, 19 May 2026 10:06:30 +1000 Subject: [PATCH] Fix input cycle validation for non-null lists --- .../validation/NoUnbrokenInputCycles.java | 15 ++---- .../NoUnbrokenInputCyclesTest.groovy | 50 +++++++++++++++++++ 2 files changed, 54 insertions(+), 11 deletions(-) diff --git a/src/main/java/graphql/schema/validation/NoUnbrokenInputCycles.java b/src/main/java/graphql/schema/validation/NoUnbrokenInputCycles.java index 22be3f7148..9eb061d070 100644 --- a/src/main/java/graphql/schema/validation/NoUnbrokenInputCycles.java +++ b/src/main/java/graphql/schema/validation/NoUnbrokenInputCycles.java @@ -6,7 +6,6 @@ import graphql.schema.GraphQLInputObjectField; import graphql.schema.GraphQLInputObjectType; import graphql.schema.GraphQLInputType; -import graphql.schema.GraphQLList; import graphql.schema.GraphQLNonNull; import graphql.schema.GraphQLSchemaElement; import graphql.schema.GraphQLType; @@ -63,17 +62,11 @@ private void check(GraphQLInputObjectType type, Set seen, List path) { diff --git a/src/test/groovy/graphql/schema/validation/NoUnbrokenInputCyclesTest.groovy b/src/test/groovy/graphql/schema/validation/NoUnbrokenInputCyclesTest.groovy index 2ead346116..a9f0889e3d 100644 --- a/src/test/groovy/graphql/schema/validation/NoUnbrokenInputCyclesTest.groovy +++ b/src/test/groovy/graphql/schema/validation/NoUnbrokenInputCyclesTest.groovy @@ -1,9 +1,12 @@ package graphql.schema.validation +import graphql.TestUtil import graphql.schema.GraphQLArgument import graphql.schema.GraphQLFieldDefinition import graphql.schema.GraphQLInputObjectField import graphql.schema.GraphQLInputObjectType +import graphql.schema.idl.SchemaGenerator +import graphql.schema.idl.SchemaParser import graphql.util.TraverserContext import spock.lang.Specification @@ -43,4 +46,51 @@ class NoUnbrokenInputCyclesTest extends Specification { then: errorCollector.containsValidationError(SchemaValidationErrorType.UnbrokenInputCycle) } + + def "input object cycles through a non-null list are allowed"() { + def sdl = """ + input Example { + self: [Example!]! + value: String + } + + type Query { + example(example: Example): String + } + """ + + when: + def registry = new SchemaParser().parse(sdl) + new SchemaGenerator().makeExecutableSchema(registry, TestUtil.getMockRuntimeWiring()) + + then: + noExceptionThrown() + } + + def "longer input object cycles through a non-null list are allowed"() { + def sdl = """ + input Foo { + bar: Bar! + } + + input Bar { + baz: Baz! + } + + input Baz { + foos: [Foo!]! + } + + type Query { + foo(foo: Foo): String + } + """ + + when: + def registry = new SchemaParser().parse(sdl) + new SchemaGenerator().makeExecutableSchema(registry, TestUtil.getMockRuntimeWiring()) + + then: + noExceptionThrown() + } }