Regarding pagination links, the specification says:
Pagination links MUST appear in the links object that corresponds to a collection. To paginate the primary data, supply pagination links in the top-level links object. To paginate an included collection returned in a compound document, supply pagination links in the corresponding links object.
But I´m confused about the included-collection part. What does “corresponding” refer to? Does it refer to the links object of the relationship object of the included collection?
That would make sence to me. But in this case, wouldn´t it violate the following?
Any pagination links in a relationship object MUST paginate the relationship data, not the related resources.
The solution is using a relationship link with the include query parameter as the pagination links within a relationship object:
Furthermore, related resources can be requested from a relationship endpoint:
GET /articles/1/relationships/comments?include=comments.author HTTP/1.1
Accept: application/vnd.api+json
In this case, the primary data would be a collection of resource identifier objects that represent linkage to comments for an article, while the full comments and comment authors would be returned as included data.