Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling local identifier ("lid") when creating resource #265

Open
maksym-szymczak opened this issue Aug 17, 2023 · 4 comments
Open

Handling local identifier ("lid") when creating resource #265

maksym-szymczak opened this issue Aug 17, 2023 · 4 comments

Comments

@maksym-szymczak
Copy link

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

@jasminb
Copy link
Owner

jasminb commented Aug 17, 2023

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

@maksym-szymczak
Copy link
Author

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

@jasminb
Copy link
Owner

jasminb commented Aug 18, 2023

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

@maksym-szymczak
Copy link
Author

@jasminb Great, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants