Open markst opened 8 years ago
Perhaps readonly relationships is adequate for my use case.
"jobTitle": ToOneRelationship(JobTitle).readOnly()
I think this is related to this issue. But if I have an optional relationship:
var skills: LinkedResourceCollection?
Spine insists on updating that defined relationship within operation updateRelationships()
.
Since it's optional I don't wish to update.
Perhaps the filter need to be updated to check for nil?
let relationships = resource.fields.filter { field in
return field is Relationship && !field.isReadOnly && field.isUpdatable && resource.value(forField: field.name) != nil
}
I suppose it's difficult then to identify whether a relationship is being removed or not?
A LinkedResourceCollection internally keeps that of what resources were added and removed. What is the problem you run into? Spine crashes because the skills
variable is nil?
Attributes can be omitted with
OmitNullValues
serialization options, however if a relationship doesn't exist a null payload will be delivered to relationship URL.Debug - {"data":null}