I have two examples, which are almost identical:
This works:http://ift.tt/1Vr6G7C
This does not:http://ift.tt/1Rv1Mk7
Click on the name of the city, to change the client's address. Then click on rollback to get back the original relation.
The only difference in the two examples is the way, how relationships are represent in the payload. The working example uses data
relationships: {
address: {
data: {id: 1, type: 'addresses'}
}
},
the other one uses link:
relationships: {
address: {
links: {
related: "/addresses/1"
}
}
},
JSON API spec says:
A "relationship object" MUST contain at least one of the following:
- links: a links object containing at least one of the following:
- self: a link for the relationship itself (a "relationship link"). ...
- related: a related resource link
- data: resource linkage
- meta: a meta object that contains non-standard meta-information about the relationship.
I would expect that ember data behaves the same in both cases, and the (valid) payload format should not have effect on it.
Is it the only way to get this work, is to change the backend to return a payload with relation data?
Aucun commentaire:
Enregistrer un commentaire