I’m currently working on a project where instead of storing entities server side, I’m encoding them into a sort of meta String. This is because these entities will potentially be PATCHED/POSTED extremely often and don’t need server side authority. For example, you could do this by having it in the meta { } section…
{
“jsonapi”: {
“version”: “1.0”
},
“data”: {
“id”: “123”,
“type”: “test”,
“attributes”: {
“foo”: “bar”
}
},
“meta”: {
“payload”: “YADFE&YEDF&” // encoded “foo: bar”
}
}
But ideally I want to be able to put the encoded entity’s data into its ID, as this will allow me to easily add them as relationships in other resources. As currently, if you wanted to pass multiple of these entities as relationships to another resource, you’d end up with some weird array business going on in the meta tags or something? So ideally something like this;
{
“jsonapi”: {
“version”: “1.0”
},
“data”: {
“id”: “YADFE&YEDF&_123”, // encoded “foo: bar”
“type”: “test”,
“attributes”: {
“foo”: “bar”
}
}
}
So an ID containing the encoded info seems like a good idea to me - the only problem then is that PATCHing the entity would affect its ID. So my question then is;
Can you let a PATCH operation on an entity change its ID? (Maybe using a 303 response to the new entity ID?)
Or otherwise, how would you handle encoded entities in this way?
Thanks