jsonapi-converter: Pagination of primary data not supported

It seems pagination of primary data is not supported; this is because readObjectCollection returns List<T> - the return type is not able to expose pagination links (or meta information, for that matter).

The JSON below represents paginated primary data. The total size of the primary data is m but only n results are returned:

{
    "data": [
        {
          // object 1
        },
        { 
          // object 2
        },
        {
          // object n
        }
    ],
    "links": {
        "first": null,
        "last": "http://example.com/nodes/?page=m",
        "prev": null,
        "next": "http://example.com/nodes/?page=2",
    }
}

The ResourceConverter will represent the first page of results in a List<T> with a size() of n. The client has no way of knowing if the results are paginated or not, because List doesn’t expose any pagination state.

Per the spec, pagination MAY be supported, and if so, MUST be represented by a top-level links object:

Pagination

A server MAY choose to limit the number of resources returned in a response to a subset (“page”) of the whole set available.

A server MAY provide links to traverse a paginated data set (“pagination links”).

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.

The following keys MUST be used for pagination links:

  * first: the first page of data
  * last: the last page of data
  * prev: the previous page of data
  * next: the next page of data

Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (12 by maintainers)

Commits related to this issue

Most upvoted comments

@emetsger will take the code you written to handle links and incorporate it into the proposal from @bradtofel.