nuwave / lighthouse

A framework for serving GraphQL from Laravel
https://lighthouse-php.com
MIT License
3.37k stars 438 forks source link

Providing an unknown field as if it were a list results in cryptic error #1893

Open TheOddler opened 3 years ago

TheOddler commented 3 years ago

When you provide an unknown field as if it were a list, rather than getting an error stating the field does not exist, you get the following error:

Argument 1 passed to GraphQL\Type\Definition\Type::getNullableType() must be an instance of GraphQL\Type\Definition\Type, null given, called in /src/vendor/webonyx/graphql-php/src/Validator/Rules/ValuesOfCorrectType.php on line 75

For example, I have this input type:

input SomeInput {
    name: String!
}

And in the query you add an unknown field like this:

{
  name: "Example"
  unknown: [
  ]
}

You'll get the error mentioned above.

However, if you add the unknown field like this:

{
  name: "Example"
  unknown: "Foo"
}

You simply get an error message stating "Field \"unknown\" is not defined by type SomeInput."

I would expect in both cases to get the error "Field \"unknown\" is not defined by type SomeInput.".

Steps to reproduce

  1. Create any input type
  2. Provide an extra field that is not present in the input type, and make it's value a list
  3. View error


v5.6.0

spawnia commented 3 years ago

Please open an issue with the upstream library https://github.com/webonyx/graphql-php. We can fix it in Lighthouse by updating our dependency after it has been fixed there.