active_model_serializers
active_model_serializers copied to clipboard
Update docs for JSONAPI relationship links
Purpose
Fixes small typos and updated the docs on relationship links for JSONAPI.
Changes
Removed the 'data' key in the serialized relationship. Including it according to the current docs leads to unexpected behavior when using it with libraries like Ember Data.
This method returns an empty array if the relationship is not loaded even though they might exist. Passing an empty array as data tells clients that there are no existing relationships.
Instead data should not be sent at all so that the client uses the given nested resource link to fetch them.
Caveats
Related GitHub issues
Additional helpful information
@ksamc, thanks for your PR! By analyzing the annotation information on this pull request, we identified @vasilakisfil to be a potential reviewer
Interesting! I didn't know this method (https://github.com/rails-api/active_model_serializers/pull/1710) at all and I was fixing this issue from the ember's side in a serializer.
Looks good to me!
@ksamc @groyoh Needs rebase and revision following #1981
I think it makes sense to document include_data false as the usual case for including relationship links.
Please commit these changes because I almost losed my mind.