Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination #7

Open
thiagogabriel opened this issue Mar 9, 2017 · 5 comments
Open

Pagination #7

thiagogabriel opened this issue Mar 9, 2017 · 5 comments

Comments

@thiagogabriel
Copy link

Since we should return a plain array with the items, where would we include the pagination metadata ?

The practice I know is do something like this:

{ "items" :
    [
        {
            "like_count": 0,
            "id": "string",
            "media_type": "comment",
            "owner": "string"
        },
        {
            "like_count": 0,
            "id": "string",
            "media_type": "comment",
            "owner": "string"
        },
        {
            "like_count": 0,
            "id": "string",
            "media_type": "comment",
            "owner": "string"
        }
    ],
  "meta":
    {
        "current_page": 1,
        "next_page": null,
        "total_pages": 1,
        "prev_page": null
    }
}
@agerace
Copy link
Member

agerace commented Mar 10, 2017

I'll have to check with @elbrujohalcon how we usually do this, but I think it depends on the project. Sometimes we use page numbers, sometimes we use a cursor. As far as I know, the paginated resources are the only ones that should get enveloped items, as you wrote above @thiagogabriel . I'm gonna check if there's no item on the momentary index for this and, if there isn't, add it .

@elbrujohalcon
Copy link
Member

Pagination can be in the headers, right @volbap ?

@elbrujohalcon
Copy link
Member

In any case, we can totally add pagination as an exception to that rule, if needed.

@volbap
Copy link

volbap commented Mar 10, 2017

Yeah, I would use the link headers as explained here. It seems to be a fair solution.

Also, let's try to avoid envelopes as well.

@volbap
Copy link

volbap commented Mar 10, 2017

What Jayme currently supports is a non-cursor based pagination, using these headers:
X-Total, X-Per-Page, X-Page

This kind of pagination, however, may not be quite useful for certain common scenarios, like a scroll feed. So, I would not make it a standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants