jsonapi_parameters icon indicating copy to clipboard operation
jsonapi_parameters copied to clipboard

Support for polymorphic relationship types

Open tappleby opened this issue 3 years ago • 0 comments

Are there any plans to support polymorphic relationships? We have a few relationships in our API where it would be useful to gain access to the type along with the id (they are all 1-1 relations).

I think a custom handler might work for these use-cases, since there is some extra processing that would need to happen on the params to lookup the correct model based on the API type.

If using a custom handler is the recommended approach, it would be handy to specify resource_handlers per-request instead of globally since not every relationship with the same name would necessarily need to be polymorphic.

I was picturing something like this:

params.from_jsonapi(resource_handlers: { author: :handle_belongs_to_polymorphic })

tappleby avatar Apr 29 '21 00:04 tappleby