aws-appsync-community
aws-appsync-community copied to clipboard
Incorrect handling of GraphQL variables when no value is supplied
If a variable is used for a nullable query argument, the resolver function will see an explicit null
even if no value was provided for the variable.
For example, given this schema snippet:
type Item {
name: String!
}
type Query {
items(after: String): [Item!]
}
and this query:
query MyQuery($after: String) {
items(after: $after) {
name
}
}
and no variable values provided:
Operation: MyQuery, Variables: {}
...the expected behavior is that after
is absent from the context.arguments
object passed to the resolver function, but instead after
is present with an explicit null
value:
{
"after": null
}
This makes it impossible to differentiate between absent and null
when the client is using variables.
Here is the relevant section of the GraphQL spec: https://spec.graphql.org/October2021/#sec-Coercing-Variable-Values
Hey @sbaird32 , thanks for reaching out. are you seeing this behavior in JavaScript resolvers or in a VTL template?
In JavaScript resolvers.