RE: Pagination (ISSUE-42)

How do we signal end of list with an IriTemplate?

I am seriously considering to drop the members property altogether and 
describe the collection outside of the response, in the resource which 
points to the collection.

The collection response would really consist only of the items, no meta 
info. The issue with that approach is that paging can only be expressed as 
Link headers with next, prev IANA rels if it has to come with the 
collection response. Using Link Headers is not necessarily bad, we do it 
already. So we could use it as an option.

Otoh if I tell the client

{
@id: /alice,
foaf:knows: /alice/friends,
hydra:collection [
   {
      hydra:manages: {
        hydra:property: foaf:knows
        hydra:subject: /alice
      },
      hydra:partial: ... IriTemplate for partial retrieval
    }]
}

It might just be what users need in many cases and often it might be 
preferable over page controls inside the partial collection.

Plus, no need for repeated @reverse properties on every collection item to 
make the :knows assertion. Plus, foaf:knows can be used as the equivalent 
of an extension relation type, which helps adoption. Plus, we do not break 
the range of foaf:knows by pointing to a response which is itself a 
hydra:Collection. Rather, /alice/friends are plain foaf:Person.

*If* we are able to signal the end of the partial collection, that is.

Best regards,
Dietrich





On February 13, 2015 10:02:05 AM <karol.szczepanski@gmail.com> wrote:

> Markus, Tomasz
>
>
>
> I feel both of you are right.
>
>
>
> Indeed I feel that we don't need a very special way of describing pagination
> to client. I think Hydra has already what is needed to do this.
>
>
>
> >From my experience, in most cases pagination is a call to same resources
> with extra parameters, defining either page+page size or offset+limit. From
> that point of view, I think templated links are good enough to address that.
> With two extra predicates with special meaning for page and page size notion
> (offset and limit can be easily calculated from each other) client will be
> informed how to craft the url to call a page of a collection. This pattern
> is already used for 'freetextQuery', where it has a special meaning not
> really bound to any resource property.
>
>
>
> Client doesn't need to know exact number of possible pages - in worst case
> scenario it will receive either an empty page or some other non 2XX
> response. Still, if needed this number can be provided with the response of
> the i.e. first page (which is usually called at the beginning).
>
>
>
> This approach won't need any special treating of collections and pages, and
> server will define whether the collection is actually pageable by providing
> a IriTemplate and templated links.
>
>
>
> What do you think about this?
>
>
>
> Regards
>
>
>
> Karol
>

Received on Friday, 13 February 2015 18:47:36 UTC