I am trying to find a workaround for implementation of updating multiple objects in one request. I am aware of issue github issue #795 and also read comment here. I am trying to implement what krainboltgreene said.
I have an object errand in database where it has a field dirty default as false. I need a request to bulk update dirty field for many rows of object errand
In single update:
PATCH /errands/1 HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
{
"data": {
"type": "errands",
"id": "1",
"attributes": {
"dirty": true
}
}
For multiple objects update I am planning to do something as:
POST /errand_dirty_list/0/relationships/errands HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
{
"data": [
{ "type": "errands", "id": "123" },
{ "type": "errands", "id": "124" }
]
}
Or may be do something like this:
POST /errand_dirty_list HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
{
"data": {
"type": "errand_dirty_list",
"attributes": {
"dirty_errands": [123, 124, 125]
}
}
For both workaround cases, I need to response a fake resource identifier object id because my database do not have the object errand_dirty_list.
My question is is this way of workaround to implement multiple object update as single request still valid as JSONAPI specification? If not, is there any other way that still work and compliance with current JSONAPI specification?