Open HendrikN opened 6 years ago
@HendrikN Do you think: https://github.com/twg/devour/pull/153 will bring us to spec compliance here?
@Auspicus, it is related, but not completely the same. That PR is a starting point to have (in this example) the ids of the students. But for this issue the whole student objects need to be present on the student_group->student relation, not only the ids.
@JaZo AFAIK that feature already exists when making a request and adding included relationships.
Indeed, but this issue is about relations from included items to items in the "main" data.
Any updates on this?
What's the problem Retrieving a relationship where the items are located in the primary "data" collection instead of the "included" collection won't return anything.
Steps to reproduce For example: The JSON-API returns a collection of students and the studentGroups the students are assigned to. The studentGroups are available in the included segment of the response. The data segment contains all the students. There's a hasOne relationship from a student to a studentGroup, and a hasMany from a studentGroup to the containing students. The JSON:
When I try to retrieve all the students in a studentGroup, it will return an empty collection, since the students are not in the included-segment of the response. The JSON API specification says about this:
Just adding the students to the included-segment as well, would be a violation of the spec (also, devour will enter an infinite loop when I do):
See: http://jsonapi.org/format/#document-compound-documents
How could this be fixed It looks like the code only takes the items in included in to account when parsing relationships. This should be concatted with the items in the primary data as well.