Skip to content

Support for polymorphic relationship types #54

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions