Skip to content

Related links must be allowed inside relationship documents #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alexpkalinka opened this issue Mar 16, 2020 · 2 comments
Closed

Related links must be allowed inside relationship documents #104

alexpkalinka opened this issue Mar 16, 2020 · 2 comments
Labels

Comments

@alexpkalinka
Copy link

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.

@alexpkalinka alexpkalinka changed the title Related links must me allowed inside relationship documents Related links must be allowed inside relationship documents Mar 16, 2020
@f3ath f3ath added the bug label Mar 17, 2020
f3ath added a commit to f3ath/json-api-php that referenced this issue Mar 17, 2020
@f3ath f3ath closed this as completed in 4eb1497 Mar 17, 2020
@f3ath
Copy link
Contributor

f3ath commented Mar 17, 2020

@alexpkalinka
Copy link
Author

Wow, this was fast!
Yes, it works correctly now. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants