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.
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:
and this query:
and no variable values provided:
...the expected behavior is that
after
is absent from thecontext.arguments
object passed to the resolver function, but insteadafter
is present with an explicitnull
value: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