Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Related links must be allowed inside relationship documents #104

@alexpkalinka

Description

@alexpkalinka

In JSON:API docs the "Fetching Relationships" section says:

The top-level links object MAY contain self and related links, as described above for relationship objects.

And it gives the example response:

{
  "links": {
    "self": "/articles/1/relationships/author",
    "related": "/articles/1/author"
  },
  "data": {
    "type": "people",
    "id": "12"
  }
}

However, it seems like this library does not allow to generate such document. Here's my attempt:

new JsonApi\DataDocument(
    new JsonApi\ResourceIdentifier("people", "12"),
    new JsonApi\Link\SelfLink("/articles/1/relationships/author")
);

It gives:

{
    "data": {
        "type": "people",
        "id": "12"
    },
    "links": {
        "self": "/articles/1/relationships/author"
    }
}

But the related link can't be added because DataDocument constructor does not accept RelatedLink objects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions