You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Compound documents require “full linkage”, meaning that every included resource MUST be identified by at least one resource identifier object in the same document. These resource identifier objects could either be primary data or represent resource linkage contained within primary or included resources.
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):
A compound document MUST NOT include more than one resource object for each type and id pair.
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.
The text was updated successfully, but these errors were encountered:
@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.
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.
The text was updated successfully, but these errors were encountered: