Skip to content

Including relations of relations requires include to be listed twice. #149

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

Closed
sonthonaxrk opened this issue Oct 29, 2015 · 11 comments
Closed
Labels
Milestone

Comments

@sonthonaxrk
Copy link
Contributor

http://jsonapi.org/format/#fetching-includes

In order to request resources related to other resources, a dot-separated path for each relationship name can be specified:


Currently a request like this will fail to include anything.

/articles/1?include=comments.author

However it will work if I include comments and comments.author.

/articles/1?include=comments,comments.author
@sonthonaxrk sonthonaxrk changed the title Including relations of relations is not currently possible. Including relations of relations requires include to be listed twice. Oct 29, 2015
@jerel
Copy link
Member

jerel commented Oct 29, 2015

I had noticed this quirk also. Do you feel like it's a bug or a feature. I'm not sure that including comments.author without comments makes sense.

@sonthonaxrk
Copy link
Contributor Author

From the spec:

Because compound documents require full linkage, intermediate resources in a multi-part path must be returned along with the leaf nodes

I think it's a bug. The JSON API spec asks for intermediate resources to be returned. Right now DRF-JSON API doesn't return anything.

@jerel jerel added the bug label Oct 29, 2015
@jerel
Copy link
Member

jerel commented Oct 29, 2015

Ah yes. It does spell it out there in the spec.

@sonthonaxrk
Copy link
Contributor Author

I'm happy to fix this myself over the weekend.

@jsenecal
Copy link
Member

It's not a bug, but rather a missing feature IMO... Including comments.author is very different from including comments-author and including comments.author without including comments would be silly...

The cited specs is talking about the comment-author I think...

@sonthonaxrk
Copy link
Contributor Author

@jsenecal are you sure including comments.author is different from comments,comments.author? Other than the latter being redundant?

@jsenecal
Copy link
Member

Yes, well, I do understand the redundancy.

The example we have here might not be the best one.

Let's use comments.tags...
Not all comments have tags. Including all comments when we really are in fact interested in tags is wasted machine time.

@jsenecal
Copy link
Member

Although, reading the spec referenced by #149 (comment) it appears that it is actually the other way around and that including comments.author should include all comments as well. Sorry for the confusion/back and forth.

comments-tags would be for when one wants all the tags with the least amount of comments possible.

Feel free to work on this but be warned that it's a feature easy to break as the tests in place are not covering all the possible use cases (like relations to self).

@jsenecal jsenecal added this to the 2.0 release milestone Oct 29, 2015
@sonthonaxrk
Copy link
Contributor Author

Talking of tests some of the utils.py methods don't have any, before I write a fix, I'd like to make some headway on that.

Some of the functions are quite long and might be more testable if broken up.

@jerel
Copy link
Member

jerel commented Nov 4, 2015

@jsenecal
Copy link
Member

@rollokb any success on implementing broken tests ?

@jerel jerel closed this as completed in 3c9ab18 Feb 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants