No input field null validation on non nullable fields

I am going to say again that this is a bug and here is spec to support this claim of a bug:

http://spec.graphql.org/June2018/#sec-Null-Value

2.9.5 deals exclusively with inputs. Null values can either be specifically provided as null or understood as null if not given.

GraphQL has two semantically different ways to represent the lack of a value:

  • Explicitly providing the literal value: null.
  • Implicitly not providing a value at all.

For example, these two field calls are similar, but are not identical:

{
 field(arg: null)
 field
}

The first has explictly provided null to the argument “arg”, while the second has implicitly not provided a value to the argument “arg”. These two forms may be interpreted differently. For example, a mutation representing deleting a field vs not altering a field, respectively. Neither form may be used for an input expecting a Non‐Null type.

(Added emphasis on the last line)

Go to this live mutation from GraphQL, https://graphql.org/learn/schema/#input-types

And change the variables to [removing stars]:

{
  "ep": "JEDI",
  "review": {
    "commentary": "This is a great movie!"
  }
}

And it will trigger the error

Object of type “ReviewInput” is missing required field “stars”

3 Likes