Skip to content

Add ability to define relationships in Schema differently when resource is main and included #121

@neomerx

Description

@neomerx

Relationship could be represented by all resource identities (type and id) in the relationship, or a link, or a combination of data, link and meta (real world example - paging (20 identities, links for more data and some meta with paging info)).
The lib currently supports all these combinations. Which is good. But I want moar 😄 I want to be able to

  • include some resources + links + paging meta when resource is main
  • keep only link to relationship data when resource is within included

something like this

{
    "data" : {
        "type" : "posts",
        "id"   : "1",
        "attributes" : {
            "..."
        },
        "relationships" : {
            "comments" : {
                "data" : [
                    { "type":"comments", "id":"5" }
                ],
                "links" : [
                    "<paging links for the rest of data here>"
                ],
                "meta" : {
                    "total-pages": "...",
                    "page-size": "..."
                }
            }
        }
    },
    "included" : [{
        "type"  : "comments",
        "id"    : "5",
        "attributes" : {
            "..."
        },
        "relationships" : {
            "replies" : {
                "links" : {
                    "self" : "<only link here, no identities when resource is included>"
                }
            }
        }
    }]
}

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions