kensho-technologies/graphql-compiler

Filtering on a non-null field does not work correctly

Opened this issue · 1 comments

Given a schema:

type RootSchemaQuery {
  Foo: Foo
}

type Foo {
  name: String!
}

and a query that includes a filter for the name field:

{
  Foo {
    name @output(out_name: "name") @filter(op_name: "=", value: ["$foo_name"])
  }
}

The compiler returns a GraphQLCompilationError with the message Cannot apply "=" filter to non-leaf"

It appears that this validation code doesn't consider the actual field type when it encounters a GraphQLNonNull.

Removing the ! from the field in the schema allows the query to run.

Thanks! I think for the moment, we're sadly pretty sloppy and inconsistent in our support of non-null types in the schema. Hoping we soon get a chance to do a thorough pass throughout the codebase and make it all work nicely.