graphql-ruby: Passing empty array in a variable returns an error
The following mutation works as expected:
mutation {
AdjustRoles(input: {
role_names: []
}) {
clientMutationId
viewer {
id active_role_names
}
}
}
However the same mutation using variables:
mutation AdjustRolesMutation($role_names: [String]!) {
AdjustRoles(input: {
role_names: $role_names
}) {
clientMutationId
viewer {
id active_role_names
}
}
}
Variables
{ "role_names": [] }
Causes the following error:
{
"errors": [
{
"message": "Variable role_names of type [String]! was provided invalid value",
"locations": [
{
"line": 1,
"column": 30
}
],
"value": null,
"problems": [
{
"path": [],
"explanation": "Expected value to not be null"
}
]
}
]
}
Looks like the empty array is being treated as null.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 2
- Comments: 17 (8 by maintainers)
So, the keys are hashes, but you need string keys: