beam-community / jsonapi

JSON:API Serializer and Query Handler for Elixir
https://hex.pm/packages/jsonapi
MIT License
490 stars 79 forks source link

Fix relationships spec & external relationship use-case #295

Closed mattpolzin closed 1 year ago

mattpolzin commented 1 year ago

The features of https://github.com/beam-community/jsonapi/pull/270 were broken in two ways that this PR fixes.

  1. The @spec for the relationships callback for JSONAPI.View actually did not allow for the various new structures a relationships callback is allowed to return under the above PR.
  2. The PR was intended to support (among other more general purposes) remapping of an attribute field to a relationship -- this is niche, but sometimes quite useful. The above PR and its tests failed to fully realize that goal by missing one small detail (lost in a merge conflict resolution, as it turns out).

This PR fixes both of these problems and adds test coverage for the latter.