Spine
Spine copied to clipboard
Globally specify operation serializer options
We'd like to globally specify OmitNullValues
as a default option when serializing, or perhaps even be able to specify endpoint specific options...
What is your use case for this? Perhaps there is a way we can solve it without adding any more configuration options.
Current use case is as I mentioned, here's my Spine branch changes:
if isNewResource {
URL = router.URLForResourceType(resource.resourceType)
method = "POST"
options = [.IncludeToOne, .IncludeToMany, .OmitNullValues]
} else {
URL = router.URLForQuery(Query(resource: resource))
method = "PATCH"
options = [.IncludeID, .OmitNullValues]
}
Why do you want to omit null values? If it's because of overwriting attributes that weren't fetched, I recommend trying the dirty-checking
branch.
thanks @wvteijlingen yeah dirty checking also achieves what I wish for. However this still requires me to create an instance of SerializeOperation
to be able to assign options
.
I'd like to be able to globally specify all SerializeOperations always dirty check.