Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support for deeply-nested included resources? #957

Answered by sliverc
esmail asked this question in Q&A
Discussion options

Taking the familiar example of a blog post/article, would it be possible to return both the comments on the article and the authors of those comments?

The following quote (emphasis mine) leads me to believe this use case to be in-spec., but I'm not sure how to do so with DJA:

Note: Full linkage ensures that included resources are related to either the primary data (which could be resource objects or resource identifier objects) or to each other.

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

You must be logged in to vote

Yes this is possible as per specification include needs to be defined dotted.

So for your example the include query parameter should look like this:

GET /articles/1?include=comments.author HTTP/1.1

For this to work you define included_serializers in your serializers as per documentation.

Replies: 1 comment 1 reply

Comment options

Yes this is possible as per specification include needs to be defined dotted.

So for your example the include query parameter should look like this:

GET /articles/1?include=comments.author HTTP/1.1

For this to work you define included_serializers in your serializers as per documentation.

You must be logged in to vote
1 reply
Comment options

Forgot to say thanks for this. I was mistakenly thinking I needed to somehow reference author in MySerializer.Meta.fields. I'll try to circle back and PR in a quick mention of the in the docs.

Answer selected by esmail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #952 on July 06, 2021 18:46.

AltStyle によって変換されたページ (->オリジナル) /