I have a use case where the value can be "yes", "no" or "null" where "null" means "not present". Can I use the boolean type in GraphQL to denote this?
From the spec:
By default, all types in GraphQL are nullable; the null value is a valid response for all [types]. To declare a type that disallows null, the GraphQL Non‐Null type can be used.
In other words, unless you explicitly specify your field as non-null, null will always be a valid value for that field, regardless of whether the field is a boolean, another scalar type or an object type.
+----------+-------------------+
| type | allowed values |
+----------+-------------------+
| Boolean | true, false, null |
| Boolean! | true, false |
+----------+-------------------+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With