We have a requirement where a field may need to be cleared of its value - essentially setting it to null.
According to JSON:API spec, I should ensure the server accommodates partial updates (PATCH).
When I don't submit a value for a field I don't want to update in the PATCH request, along with a field I want to set to null and the deserialize the resource, unsurprisingly I can't tell which properties are needed to set to null and which were just not submitted in the PATCH request.
I understand nulls suck and I've already confirmed with the product owner that there is a business driver behind this requirement :-(
Going a bit nuts here - so I wondering if this is something that anyone has come across before.
Is it possible to do something like default the Resource properties to Optional.empty() and then if a null value is deserialized then I know I have to update that and ignore all the other optionals?
Hi
We have a requirement where a field may need to be cleared of its value - essentially setting it to null.
According to JSON:API spec, I should ensure the server accommodates partial updates (PATCH).
When I don't submit a value for a field I don't want to update in the PATCH request, along with a field I want to set to null and the deserialize the resource, unsurprisingly I can't tell which properties are needed to set to null and which were just not submitted in the PATCH request.
I understand nulls suck and I've already confirmed with the product owner that there is a business driver behind this requirement :-(
Going a bit nuts here - so I wondering if this is something that anyone has come across before.
Is it possible to do something like default the Resource properties to Optional.empty() and then if a null value is deserialized then I know I have to update that and ignore all the other optionals?
Many thanks
Ben