Skip to content

Able to use non input type as input type when wrapped in GraphQLList #2656

Closed

Description

@CNAChino

Describe the bug
The issue occurs when using GraphQLArgument builder with type as GraphQLList(an instance of GraphQLInputType) and wraps a non-input type like GraphQLObjectType.

Was also able to build a schema as shown in the following code.

To Reproduce

GraphQLObjectType graphQLObjectType = GraphQLObjectType.newObject().name("ObjectTypeA").build();

    GraphQLArgument argument = GraphQLArgument.newArgument()
        .name("testArg")
        .type(GraphQLList.list(graphQLObjectType))
        .build();

    GraphQLObjectType queryObject = GraphQLObjectType.newObject()
        .name("Query")
        .field(GraphQLFieldDefinition.newFieldDefinition()
            .name("testField")
            .argument(argument)
            .type(graphQLObjectType)
            .build())
        .build();

    GraphQLSchema schema = GraphQLSchema.newSchema()
        .query(queryObject)
        .additionalTypes(Collections.emptySet())
        .additionalDirectives(Collections.emptySet())
        .build();

Activity

  1. bbakerman commented on Dec 22, 2021

    @bbakerman
    Member

    Thanks for report - yup I can see this can be a bug because a list is both an input type and output type and its not until you put it into a context (argument or field) that you know if its incorrect or not.

    Type references could also create this problem.

    We could write an extra schema validation rule to catch this - that is once the schema is finalised - we would unwrap every argument / field and make sure the wrapped types are valid for the context.

  2. bbakerman commented on Jan 3, 2022

    @bbakerman
    Member

    The linked PR has addressed this

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions