2

I'm using below modules

https://www.drupal.org/project/entityqueue & JSON API

Through entity queue. I have added 5 Articles.

Now I would like to apply pagination on that.

We are accessing via

http://domain.com/jsonapi/my-5-articles?include=items

I tried to add include=items&items[paging]=1. but seems not working

I need to add limit & offset

If we do same in

http://domain.com/jsonapi/node/article?page[limit]=1

then we are getting

"links": {
"self": "http://domain.com/jsonapi/node/article?page%5Blimit%5D=1",
"next": "http://domain.com/jsonapi/node/article?page%5Boffset%5D=1&page%5Blimit%5D=1",
"last": "http://domain.com/jsonapi/node/article?page%5Boffset%5D=31&page%5Blimit%5D=1"
},

We are not able to get same in entityqueue.

How to add JSON API in views?

1

Is sounds like you're assuming functionality that may-or-may-not be there.

Assuming /jsonapi/my-5-articles is an alias for /jsonapi/entity_subqueue/$MY_QUEUE_MACHINE_NAME?include=items, items[paging] isn't a query param for pagination, only page is (with [] options for specifying page size & offsets).

It sounds like what you want, in terms of the JSON API spec, is a paginated compound document (i.e. the included property that has all your queue nodes for the items relationship). Per the JSON API spec:

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.

It's optional for the JSON API module to supply pagination links. If it does supply them, it will be in the links document property for the resource you're requesting.

Since you're wanting pagination for included resources, the spec says:

To paginate an included collection returned in a compound document, supply pagination links in the corresponding links object.

I'm assuming "corresponding links object" is different from "top-level links" and they're referring to links property for objects within the included array.

From a quick look over the JSON API docs/code it doesn't appear to support this functionality. That may or may not be the case, you'll need to see if it does. You should check the project's issue queue.

The specs' flexibility on this scenario means the authors may not have put the functionality in there. If that's the case, you'll need to figure out a workaround or implement your own solution here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.