aws / aws/aws-appsync-community
Using query variables does not generate the same errors as statically filled queries
- Dominant language
- HTML
- Stars
- 507
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
We've run into an issue with how error are not handled correctly when using Query Variables to fill a Query/Mutation.
Here is an example how it goes wrong:
Mutation:
```
mutation createUpdateTest($input: [CreateUpdateTestInput!]!) {
createUpdateTest(input: $input) {
items {
id
}
}
}
```
Query Variables:
```
{
"input": {
"testa": "test",
}
}
```
Output:
```
{
"data": null,
"errors": [
{
"path": null,
"locations": null,
"message": "The variables input contains a field that is not defined for input object type 'CreateUpdateTestInput' "
}
]
}
```
Note the lack of the missing field in the error
And here is an example how it goes correctly:
Mutation:
```
mutation createUpdateTest {
createUpdateTest(input: {testa: "test"}) {
items {
id
}
}
}
```
Output:
```
{
"data": null,
"errors": [
{
"path": null,
"locations": [
{
"line": 2,
"column": 21,
"sourceName": null
}
],
"message": "Validation error of type WrongType: argument 'input' with value 'ObjectValue{objectFields=[ObjectField{name='testa', value=StringValue{value='test'}}]}' is missing required fields '[test]' @ 'createUpdateTest'"
}
]
}
```
Note the actual showing of the missing required fields.
Have we made a mistake with our appsync configuration? Is this working as intended or is this a bug?
Contributor guide
Research direction
Start by reproducing the supplied mutation with query variables and the statically filled mutation, then compare their validation errors. The issue does not name repository files or tests; the work is complete when the cause is identified and variable validation either reports the missing required field consistently or the behavior is documented as intended.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, graphql
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100