jasci
07/08/2021, 8:24 PMinput UserUpdateInput {
firstName: String
lastName: String
shippingAddress: AddressInput
phone: String
}
And this mutation:
updateUser(where: UserWhereUniqueInput!, data: UserUpdateInput!): User!
If I run this mutation and provide only firstName
and phone
for example. I can see that in my resolver I have args object with 2 properties that I have provided (only firstName
and phone
).
The question is that I’ve seen implementations that use *setNull
fields, like:
input UserUpdateInput {
firstName: String
lastName: String
shippingAddress: AddressInput
shippingAddress_setNull: Boolean
phone: String
phone_setNull: Boolean
}
I’m told that the reason is that by default the fields that are optional and not provided are set to null
but I don’t see that.
And it’s used to distinguish if a user really wants to set the field as null
or just hasn’t provided a value.
But in my case I don’t see not provided values to be set null
. Can you please help to understand what is the proper way to implement that?
Thank you.
P.S. API with Apollo Server.