jsonapi icon indicating copy to clipboard operation
jsonapi copied to clipboard

Support renaming of relationships

Open mattpolzin opened this issue 3 years ago • 1 comments

This PR introduces the ability to rename relationships in the JSONAPI View.

Other changes in this PR are mostly to rename a few variables local to functions where I felt that it served clarity (like view -> parent_view).

Similar results can be achieved for attributes by writing custom functions of the same name as the attribute being exposed. I considered adding relationship renaming in a similar fashion, but I believe that with relationships you gain more by not needing to dig into the model and produce the relationship yourself than with attributes and at the same time there is less benefit to writing an entire function (I am not aware of use-cases beyond renaming the relationship that would benefit from this other than fabricating relationships that are not represented in the underlying data-source).

As a side note, fabricating relationships is supported as-is with the feature this PR provides, but it feels like an unusual enough desire to not document explicitly in the readme.

mattpolzin avatar Jun 10 '22 22:06 mattpolzin

Thanks for the PR @mattpolzin! I'll spend some time today reviewing this but at a quick glance this looks good and has test coverage 🎉

doomspork avatar Jul 11 '22 20:07 doomspork

I think I'll merge this soon and start working on release notes for a new release (there will have been a solid chunk of changes, not just this PR) if no one comments to say they are going to leave a review in the near future.

mattpolzin avatar Jan 09 '23 13:01 mattpolzin