Skip to content

Commit 4c162f0

Browse files
author
abluchet
committed
doc partial pagination
1 parent 9610017 commit 4c162f0

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

core/pagination.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,76 @@ class Book
205205
}
206206
```
207207

208+
## Partial pagination
209+
210+
When using the default pagination, a `COUNT` query will be issued against the current requested collection. This may have a
211+
performance impact on really big collections. The downside is that the information about the last page is lost (ie: `hydra:last`).
212+
213+
### Globally
214+
215+
The partial pagination retrieval can be configured for all resources:
216+
217+
```yaml
218+
# app/config/config.yml
219+
220+
api_platform:
221+
collection:
222+
pagination:
223+
partial: true # Disabled by default
224+
```
225+
226+
### For a Specific Resource
227+
228+
```php
229+
<?php
230+
231+
// src/AppBundle/Entity/Book.php
232+
233+
use ApiPlatform\Core\Annotation\ApiResource;
234+
235+
/**
236+
* @ApiResource(attributes={"pagination_partial"=true})
237+
*/
238+
class Book
239+
{
240+
// ...
241+
}
242+
```
243+
244+
### Client-side
245+
246+
#### Globally
247+
248+
```yaml
249+
# app/config/config.yml
250+
251+
api_platform:
252+
collection:
253+
pagination:
254+
client_partial: true # Disabled by default
255+
partial_parameter_name: partial # Default value
256+
```
257+
258+
The partial pagination retrieval can now be changed by toggling a query parameter named `partial`: `GET /books?partial=true`
259+
260+
#### For a Specific Resource
261+
262+
```php
263+
<?php
264+
265+
// src/AppBundle/Entity/Book.php
266+
267+
use ApiPlatform\Core\Annotation\ApiResource;
268+
269+
/**
270+
* @ApiResource(attributes={"pagination_client_partial"=true})
271+
*/
272+
class Book
273+
{
274+
// ...
275+
}
276+
```
277+
208278
Previous chapter: [Validation](validation.md)
209279

210280
Next chapter: [The Event System](events.md)

0 commit comments

Comments
 (0)