Skip to content

Support for polymorphic relationship types #54

@tappleby

Description

@tappleby

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 })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions