fast_jsonapi icon indicating copy to clipboard operation
fast_jsonapi copied to clipboard

`relationships` remains empty when using sparse fieldsets (`fields` in query)

Open everlast240 opened this issue 6 years ago • 2 comments

When include is used to include related documents (compound document) and you also have sparse fieldsets (you filter returned attributes with the fields parameter), the relationships attribute of the root resource remains empty. This is rather confusing because this way you have no way how to link the root resources (if multiple) to their corresponding included related resources.. I've identified the issue to come from here: https://github.com/Netflix/fast_jsonapi/blob/master/lib/fast_jsonapi/serialization_core.rb#L54 It works as expected if that line is commented out... Now I see a related issue: https://github.com/Netflix/fast_jsonapi/issues/304 - according to which there is a way to trick / work around this:

you must specify associations in the fields option if you want fast_jsonapi to populate the relationships hash appropriately

But I'm not sure if this is the JSONAPI v1 compliant way ...

So, if this is not considered a bug, maybe some documentation improvements should make this clear.

everlast240 avatar Aug 12 '19 12:08 everlast240

See also: https://github.com/Netflix/fast_jsonapi/commit/a363c90b#commitcomment-34658281

everlast240 avatar Aug 12 '19 14:08 everlast240

It seems Netflix has abandoned this project. The community created a new fork to continue supporting this project. Please refer https://github.com/fast-jsonapi/fast_jsonapi

kapilnarula avatar Oct 19 '19 05:10 kapilnarula