-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
In GraphQL we can mark a field that it is nullable or not by "!". But how to also mark that a field is required or optional?
Required means that this parameter must be passed, even if it is null.
Basically null has the meaning of "this property existed before, and I want to nullify its value". If there's no value, or the value needs not change (for requests, for example), it just shouldn't be sent.
For example an user have a birth day set in his profile, if he wants to update the birth day he must pass a value, but it is not allowed to pass null.
So, in this case a birth day type is not nullable, but it is optional, or user send a valida value or just not send this parameter.
This is supported by OpenAPI https://swagger.io/docs/specification/data-models/data-types/