Skip to content

Also include next and totalResources for nested resources. #1035

Closed
@databrecht

Description

@databrecht

Is your feature request related to a problem? Please describe.
Retrieving a set of date entities returns, for example with:

  • api/v1/devices

Results in next links and total resources.

{
meta: {
  totalResources: 3
},
links: {
  self: "/api/v1/devices?page[size]=2",
  first: "/api/v1/devices?page[size]=2",
  last: "/api/v1/devices?page[size]=2&page[number]=2",
  next: "/api/v1/devices?page[size]=2&page[number]=2"
},
data: [...

However, when calling a nested endpoint which contains a list of data entities such as:

  • api/v1/locations//devices

It seems that totalResources as well as the next link is not included in the result which makes it hard for the client to paginate. Pagination works (the query parameters can be used) but the links and information of the total number of resources is omitted in the json result.

{
links: {
  self: "/api/v1/locations/008b34d8-7dfe-40f1-a422-3bff500744b8/devices",
  first: "/api/v1/locations/008b34d8-7dfe-40f1-a422-3bff500744b8/devices"
},
  data: [...
{

We have noticed that there is no count query executed for these kind of URIs which might indicate that this is intended and therefore I didn't log it as a bug.

Describe the solution you'd like
Results in nested results that are consistent with an entity list that is retrieve via the direct devices call. A next link probably is definitely desired since there is a prev link if you would would grab a page further in the order:

{
links: {
  self: "/api/v1/locations/008b34d8-7dfe-40f1-a422-3bff500744b8/devices?page[size]=1&page[number]=2",
  first: "/api/v1/locations/008b34d8-7dfe-40f1-a422-3bff500744b8/devices?page[size]=1",
  prev: "/api/v1/locations/008b34d8-7dfe-40f1-a422-3bff500744b8/devices?page[size]=1"
},
data: [...

So it feels inconsistent that you can use the links to get the prev yet have to construct the next links yourself.
The totalResources would definitely be convenient as well since it's more consistent to the other results.

Describe alternatives you've considered
Currently we will postprocess the json result and add the information ourselves, if there is a better solution, please advise.

Additional context
Version 4.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions