/
Non-null
To view this content, buy the book! 😃🙏
Or if you’ve already purchased.
Non-null
Non-null is a wrapper type. It wraps any other type and signifies that type can’t be null.
type User {
name: String!
}If we select User.name in a query:
query {
user(id: "abc") {
name
}
}then we will never get this response:
{
"data": {
"user": {
"name": null
}
}
}These two responses are valid:
{
"data": {
"user": {
"name": "Loren"
}
}
}{
"data": {
"user": null
}
}When there are multiple levels of non-null, the null propagates upward. We’ll see an example of this in Chapter 4: Errors.