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 for JSON API's Compound Documents #353

Open
alexchumak opened this issue Jul 7, 2015 · 5 comments
Open

Support for JSON API's Compound Documents #353

alexchumak opened this issue Jul 7, 2015 · 5 comments

Comments

@alexchumak
Copy link

Using combination of relationships and included related resources it is possible to avoid making many unnecessary API calls.

http://jsonapi.org/format/#document-compound-documents

"data": [
  {
    "id": "59d23d10-1aa3-11e5-8c51-f1d09152a8c3",
    "type": "activities",
    "attributes": {
      "ip": "x.x.211.243",
      "bot": false
    },
    "relationships": {
      "user_agent": {
        "data": {
          "type": "user_agents",
          "id": "1"
        }
      }
    }
  }
],
"included": [
  { "type": "user_agents", "id": "1", "attributes": { "os": "windows", "browser": "chrome" } }
]

After parsing that response activity.user_agent should be present, without any additional API calls.

Is there any appetite for adding this seemingly priceless functionality?

@hubert
Copy link
Contributor

hubert commented Jul 7, 2015

@alexchumak this is actively being worked on (by me), so i hope so :-)

https://github.com/hubert/her/tree/feature/jsonapi-compound-documents

it's not quite ready to be merged in but i'll PR soon. there is one bit of work i needed to do with regards to has_one associations were being handled in order to get this to work, so that will need to get merged and then this will come soon after.

comments welcome and appreciated.

@alexchumak
Copy link
Author

That's great news @hubert! I even forked it myself and was about start mucking around with it, but glad i asked first!

Looking forward to taking advantage of this functionality. Do you have any sense as to when this might get merged into master?

@will-r
Copy link
Collaborator

will-r commented Aug 4, 2015

Hello @hubert. We are keen to help with this if we can. I've merged your earlier work and I see that your has_one PR has been pulled in. The basic assembly of compound documents seems to work very well and I like the way it simply prevents a future api call. Thank you for that. Is there other work in this area that we could help to finish?

We are finding the jsonapi parsing quite fragile, especially around associations. I don't think that's related to the compound document parsing - more to do with #334 - but it becomes more important when bundles of stuff are being passed around. Happy to come up with something there too.

@hubert
Copy link
Contributor

hubert commented Sep 7, 2015

@will-r @alexchumak i'd encourage you to share your thoughts on PR #360

i have some qualms with it, but now that 0.8.0 has gone out, i'd be more inclined to merge it in if there are active users who would benefit.

@will-r do you have a example of the jsonapi parsing be fragile? i'd be keen to take a look.

@danielneis
Copy link

Hello,

it would be great if her could parse the associations sent on "relationships".
Here is an example json for a call with a has_one relationship:
https://gist.github.com/danielneis/255d4c931ca8191f5b8d0b2bc2a1c5ce

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

4 participants