Skip to content

Support for multiple type in the same relationship #54

Description

@daniel-m-dd

Is your feature request related to a problem? Please describe.

When fetching a resource (say an article) I can get either

{
  "data": {
    "id": "1",
    "type": "articles",
    "attributes": { "title": "A" },
    "relationships": { "author": { "data": { "id": "1", "type": "human" } } }
  }
}

or

{
  "data": {
    "id": "1",
    "type": "articles",
    "attributes": { "title": "A" },
    "relationships": { "author": { "data": { "id": "xorg", "type": "bot" } } }
  }
}

Describe the solution you'd like

I would like to be able to Marshal/Unmarshal such a json api structure.

Describe alternatives you've considered

Tried to find a smart way to use StringIdentifier but not working.
I also tried to define twice the relationship field in my golang struct with the same json author key

type Article struct {
...
HumanAuthor        HumanAuthor `jsonapi:"relationship" json:"author"`
BotAuthor              BotAuthor `jsonapi:"relationship" json:"author"`
}

but the same json field cannot co-exist.

Additional context
Add any other context or screenshots about the feature request here.

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions