jasminb/jsonapi-converter

Handling local identifier ("lid") when creating resource

Opened this issue · 4 comments

Hello,

I'm writing client for API which requires base resource with included relationship resources during creation. I need to use "lid" to identify those resources in request. Is there any way to handle such case in this library?

Thanks for your help

Hey @maksym-szymczak can you provide an example of what you are trying to achieve, I'm a bit slow today 😄

I want to create request body that will look like this:
{ "data": { "type": "person", "attributes": { "firstName": "Jonh", "lastName": "Smith" }, "relationships": { "otherPersons": { "data": [ { "lid": "1", "type": "otherPerson" }, { "lid": "2", "type": "otherPerson" } ] } }, "included": [ { "lid": "1", "type": "otherPerson", "attributes": { "firstName": "Joe", "lastName": "Doe" } }, { "lid": "2", "type": "otherPerson", "attributes": { "firstName": "Jane", "lastName": "Doe" } } ] } }

So server can create the base resource (person) and also relationship resources provided as "included"
https://jsonapi.org/format/1.1/#document-resource-object-identification

@maksym-szymczak got it, lib is not in sync with the spec, will add support and let you know here.

@jasminb Great, thanks a lot!