Skip to content

Schema generator reports false positive unsatisfiable input object cycle #4214

Description

@RafeArnold

Per the spec, cyclic input object fields of non-nullable list type with non-nullable items are valid since the field value can be an empty list. However, the NoUnbrokenInputCycles rule reports these input objects as invalid.

To reproduce, run the following code:

import graphql.schema.idl.NoopWiringFactory;
import graphql.schema.idl.RuntimeWiring;
import graphql.schema.idl.SchemaGenerator;
import graphql.schema.idl.SchemaParser;

public class Main {
    public static void main(String[] args) {
        String query = """
                  input Example {
                    self: [Example!]!
                    value: String
                  }
                
                  type Query {
                    example(example: Example): String
                  }
                """.stripIndent();
        TypeDefinitionRegistry typeDefinitionRegistry = new SchemaParser().parse(query);
        RuntimeWiring runtimeWiring = RuntimeWiring.newRuntimeWiring().wiringFactory(new NoopWiringFactory()).build();
        new SchemaGenerator().makeExecutableSchema(typeDefinitionRegistry, runtimeWiring);
    }
}

Observe an InvalidSchemaException is thrown with the message [self!] forms an unsatisfiable cycle

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    keep-openTells Stale Bot to keep PRs and issues open

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions