Description
The jsonapi spec allows for altering relationship information either by PATCHing a resource and including the relationship information (https://jsonapi.org/format/#crud-updating-resource-relationships) or by sending PATCH, POST and DELETE requests to relationship URLs (https://jsonapi.org/format/#crud-updating-relationships).
jsonapi-vuex currently only supports the former and there are good reasons one might want to choose the latter. For instance, when updating a resource with many related resources (such as an article with many comments) we might have fetched only a subset of those related resources (because the results are paged, for example). If we PATCH said article and include the comments relationship in the patch, we will send an incomplete list of comments and unintentionally cause the server to delete many other comments from the relationship.
To support the latter, I think a diff style function which generates a list of patching actions (some of which are actually POST or DELETE in HTTP terms) might be useful. Something like:
todo = generate_patch_todo(new_data, old_data)
// todo =
// [
// ['PATCH', '/articles/1', {article_attributes}],
// ['POST', '/articles/1/rels/comments', [{comments, 5}]],
// ['DELETE', '/articles/1/rels/comments', [{comments, 2}, {comments,3}]]
//]
for (let todo_item of todo) {
dispatch(todo_item)
}