Closed baseer closed 6 years ago
Currently, relationships (both to-one
and to-many
) could be updated as described in Updating a Resource’s Relationships
For example,
{
"data": {
"type": "articles",
"id": "1",
"relationships": {
"author": {
"data": { "type": "people", "id": "1" }
},
"tags": {
"data": [
{ "type": "tags", "id": "2" },
{ "type": "tags", "id": "3" }
]
}
}
}
}
You can send one or more relationships to update.
Updates in a way you linked currently is not supported out of the box, though, I beleive, are possible with lower level methods. I'll keep this issue open as a next enhancement to implement.
I see here a function that can be used to update a relationship endpoint: https://github.com/limoncello-php/framework/blob/master/components/Flute/src/Http/JsonApiBaseController.php#L282-L313
However, there are two different use cases in the json api, PATCH vs POST as defined here: http://jsonapi.org/format/#crud-updating-to-many-relationships
Basically PATCH is supposed to replace all members of the relationship and POST is simply supposed to add members to the relationship.
Which method does the
updateInRelationship()
function implement and is there an easy forupdateInRelationship()
to perform as both PATCH and POST methods as defined by the json api?