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

docs: Add pagination links docs #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

marcelobarreto
Copy link

@marcelobarreto marcelobarreto commented May 10, 2021

Adds pagination links to the docs

image

image

@richmolj
Copy link
Contributor

This is great, thanks @marcelobarreto ❤️ I really appreciate the screenshots 💯

I wonder if we can give a brief (1-2 sentence) overview of pagination links, linking to the relevant JSON:API docs. Then show how to do it globally, then how to do on-demand (and why you might want to do this). I also think the pagination_links_on_demand = false is not needed right? And I think they should never show up for #show right?

@marcelobarreto
Copy link
Author

Yes, my bad, we don't need the pagination_links_on_demand = false. And yes, of course, I'll be updating it in a couple hours. 🤙

Copy link
Contributor

@richmolj richmolj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comments but great to see @marcelobarreto ❤️

{% include h.html tag="h3" text="3.4 Custom Endpoint URLs" a="custom-endpoint-urls" %}
{% include h.html tag="h3" text="3.4 Pagination Links" a="pagination-links" %}

Requesting big collections can result into slow responses sometimes. In order to avoid this, you could use [pagination](https://jsonapi.org/format/#fetching-pagination). It'll break your response into smaller pieces that will make your server responds faster. Paginations links can be present in your response in the following ways:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true, but rendering links is different from paginating in general. Personally I don't render the links, but I use page[size], page[number] and stats[total]=count to do the same. I think the benefit here is a little less burden on the client.


{% include h.html tag="h4" text="3.4.1 Showing by default" a="pagination-links-showing-by-default" %}

With this configuration, all the responses will return the pagination links
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For brevity, I would change to "Globally:"


{% include h.html tag="h4" text="3.4.2 When requested" a="pagination-links-when-requested" %}

You can showing the pagination links when it was requested in the URL with `?pagination_links=true`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Or on-demand when requested in the URL with ?pagination_links=true"

end
{% endhighlight %}

Pagination links won't show up for *#show* actions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this line - should already be an expectation, their presence is a bug.

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

Successfully merging this pull request may close these issues.

2 participants