Problem/Motivation

Postponed on #2100637: REST views: add special handling for collections

Link relations are used to point to next steps when using a REST API. A common use case for REST link relations is pagination through collections. For example, you can use the IANA link relations such as next and previous, as follows:

Link: <http://example.iana.org/collection/1>; rel="first",
      <http://example.iana.org/collection/100>; rel="last",
      <http://example.iana.org/collection/3>; rel="next",
      <http://example.iana.org/collection/2>; rel="previous",

Views is our tool for producing collections. We should add pagination to that.

Proposed resolution

TBD

Remaining tasks

Determine where this should be added

Comments

sepgil’s picture

After a short talk with klausi, we agreed that we need to add the pagination into the serializers, since each format may or may not define where to list the links. So for hal+json it would be in an object called '_links' which contains sub-objects like next, previous and so on, similar to the link objects for the entites. See the example in the hal+json specification.
Therefore I would suggest to implement the pagination for hal+json first. Later we can decide if and how we should implement for other formats.

linclark’s picture

Yes, I agree. We could potentially also add the links using the HTTP Link header, but for hypertext-aware formats such as HAL we should also include the links directly in the message body.

sepgil’s picture

StatusFileSize
new2.64 KB

Yeah, you are right. I haven't thought of adding the links to the HTTP headers...
Here is a first, very hacky patch, which will simply add the links directly into the top array through the serializer style plugin. It shouldn't be to complicated however, to use this functionality so that we can add the links to the headers.
The more complex problem is how to pass the links to the correspondent format serializer, so that it can process them. I've tried looking into that, but I don't have the insights on symfony and the whole serialization stuff to implement that.

linclark’s picture

Unfortunately, I don't think we can do it at this level. It requires the Serializer to know too much about the format that it is outputting.

linclark’s picture

I forgot that I had started on something called an EntityCollection when we were in Portland. I think that adding the EntityCollection normalizer would give us a place to handle pagination. See #2003108: Switch Views RSS to use Serializer/Zend

klausi’s picture

clemens.tolboom’s picture

Issue summary: View changes
Status: Active » Postponed
Related issues: +#2100637: REST views: add special handling for collections

I could use some help @ #2100637: REST views: add special handling for collections and probably make this issue a duplicate one.

This one is at least postponed on #2100637: REST views: add special handling for collections

wim leers’s picture

Title: Add pagination to Views in REST responses » REST views: pagination link relations
Status: Postponed » Active
Issue tags: +VDC
wim leers’s picture

dawehner’s picture

I don't see why this is blocked on #2100637: Add special handling for collections in REST?

Well, that issue actually implements this issue or at least would be certainly required to make any progress here.

wim leers’s picture

Title: REST views: pagination link relations » [PP-1] REST views: pagination link relations
Status: Active » Postponed

Oh, I see, because we don't even have such pagination REST URLs working right now, so even though we could add Link headers, we'd have no URLs to point to.

dawehner’s picture

Exactly.

simone960’s picture

Really need this pagination feature. Hope this can be added to 8.1 later

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

richardbporter’s picture

StatusFileSize
new2.5 KB

I've got a use case for this functionality. I'm not exactly sure how it relates to #2100637 but I've re-rolled this patch against 8.2.x because #3 seemed not to apply anymore. I had trouble generating an interdiff from #3 as well.

richardbporter’s picture

I'm sorry - I just noticed the status was marked as postponed. I think my last patch can be disregarded.

clemens.tolboom’s picture

Issue summary: View changes

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

wim leers’s picture

Category: Task » Feature request

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

wim leers’s picture

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

smustgrave’s picture

Title: [PP-1] REST views: pagination link relations » REST views: pagination link relations
Status: Postponed » Active

Blocker seemed like it landed a while ago.