Closed cacholong closed 1 year ago
Hi,
It's not very obviously documented, but there is a cleanPatchProps
config setting, which takes an array of the names of the jsonapi 'items' that should be preserved when cleaning the patch. These can be any of 'links', 'meta', and 'relationships'.
In your case I think all you need to do is add the following config:
const conf = {
cleanPatch: true,
cleanPatchProps: ['meta']
}
jsonapiModule = createJsonapiModule(this.api, conf)
Then just make sure your patch object has a top-level meta
section containing the appropriate data.
Let us know if this works for you!
Hi @mrichar1,
Thank you for the quick reply. That does the trick. Awesome.
Greetings,
Durk
Great - glad that worked as expected!
Hello @mrichar1,
I'm working on a project using the jsonapi-vuex library which is a great library. The api i'm developing against has some additional option using a meta object. I'm using cleanPatches. When i send the PATCH request the following body is send.
The request body is missing the added custom object meta which is probably removed by the library. All works fine with a POST request. The object is added as ....._jv.meta = { .... }.
I was wondering if something like that would be possible for the PATCH request also with a resulting request body like blow.
I think this should be possible when looking at the JSON:API specification. https://jsonapi.org/format/#document-resource-objects
I'm looking forward to your reply.
Best regards,
Durk