Providing an unknown field as if it were a list results in cryptic error
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.5k
- Forks
- 468
- Avg merge
- 3h 9m
- Merged PRs (30d)
- 2
Description
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
- Create any input type
- Provide an extra field that is not present in the input type, and make it's value a list
- View error
v5.6.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with an input type containing name and an unknown list-valued field, then inspect the validation path at vendor/webonyx/graphql-php/src/Validator/Rules/ValuesOfCorrectType.php around line 75. Compare it with the unknown scalar-field case. Done means both forms report that the field is not defined by type SomeInput.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100