active_model_serializers icon indicating copy to clipboard operation
active_model_serializers copied to clipboard

Update docs for JSONAPI relationship links

Open ksamc opened this issue 9 years ago • 4 comments
trafficstars

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 avatar Sep 22 '16 06:09 ksamc

@ksamc, thanks for your PR! By analyzing the annotation information on this pull request, we identified @vasilakisfil to be a potential reviewer

mention-bot avatar Sep 22 '16 06:09 mention-bot

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!

vasilakisfil avatar Sep 22 '16 08:09 vasilakisfil

@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.

bf4 avatar Jan 10 '17 06:01 bf4

Please commit these changes because I almost losed my mind.

ghost avatar Mar 28 '17 20:03 ghost