-
Notifications
You must be signed in to change notification settings - Fork 29
docs: Add pagination links docs #37
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ Links | |
* [Autolinking](#autolinking) | ||
* [Endpoint Validation](#endpoint-validation) | ||
* [Links-On-Demand](#links-on-demand) | ||
* [Pagination Links](#pagination-links) | ||
* [Custom Endpoint URLs](#custom-endpoint-urls) | ||
|
||
</div> | ||
|
@@ -225,7 +226,33 @@ Graphiti.configure do |c| | |
end | ||
{% endhighlight %} | ||
|
||
{% 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: | ||
|
||
{% 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For brevity, I would change to "Globally:" |
||
|
||
{% highlight ruby %} | ||
Graphiti.configure do |c| | ||
c.pagination_links = true | ||
end | ||
{% endhighlight %} | ||
|
||
{% 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` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Or on-demand when requested in the URL with |
||
|
||
{% highlight ruby %} | ||
Graphiti.configure do |c| | ||
c.pagination_links_on_demand = true | ||
end | ||
{% endhighlight %} | ||
|
||
Pagination links won't show up for *#show* actions. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
{% include h.html tag="h3" text="3.5 Custom Endpoint URLs" a="custom-endpoint-urls" %} | ||
|
||
To change the URL associated with a Resource: | ||
|
||
|
There was a problem hiding this comment.
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]
andstats[total]=count
to do the same. I think the benefit here is a little less burden on the client.