jsonapi_parameters
jsonapi_parameters copied to clipboard
Support for polymorphic relationship types
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 })