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

Support array data for updating to-many relationships #56

Open
nikajukic opened this issue May 26, 2021 · 2 comments
Open

Support array data for updating to-many relationships #56

nikajukic opened this issue May 26, 2021 · 2 comments

Comments

@nikajukic
Copy link

I've noticed that array data in a request body isn't supported and it's actually a part of the JSON:API specification.

https://jsonapi.org/format/#crud-updating-to-many-relationships

Example body:

PATCH /articles/1/relationships/tags HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "data": [
    { "type": "tags", "id": "2" },
    { "type": "tags", "id": "3" }
  ]
}
params

:data=>[{:id=>"2", :type=>"tags"}, {:id=>"3", :type=>"tags"}]

It currently breaks with when I call params.from_jsonapi with

TypeError: no implicit conversion of Symbol into Integer
...lib/jsonapi_parameters/translator.rb:37:in `dig`

I would expect it to be parsed to:

tag_ids: [2, 3]

Thank you for this gem! 👍

@choosen
Copy link
Contributor

choosen commented May 26, 2021

Thank you very much for contribution.
We review your previous PR, which is nicely described.

We can take care of that as it's important feature and are adding it to backlog,
but you are also welcome to post your solution to it 😄

@nikajukic
Copy link
Author

Thanks! 😄

I'm not promising anything, but I'll try to propose a solution soon 😄

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