File tree Expand file tree Collapse file tree 4 files changed +100
-1
lines changed Expand file tree Collapse file tree 4 files changed +100
-1
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ api_platform:
79
79
80
80
swagger :
81
81
# The swagger api keys.
82
- api_keys : []
82
+ api_keys : []
83
83
84
84
collection :
85
85
# The default order of results.
@@ -113,6 +113,16 @@ api_platform:
113
113
# The name of the query parameter to set the number of items per page.
114
114
items_per_page_parameter_name : ' itemsPerPage'
115
115
116
+ # To allow partial pagination for all resource collections.
117
+ # This improves performances by skipping the `COUNT` query.
118
+ partial : true
119
+
120
+ # To allow the client to enable or disable the partial pagination.
121
+ client_partial : true
122
+
123
+ # The name of the query parameter to enable or disable the partial pagination.
124
+ partial_parameter_name : ' partial' # Default value
125
+
116
126
mapping :
117
127
# The list of paths with files or directories where the bundle will look for additional resource files.
118
128
paths : []
Original file line number Diff line number Diff line change @@ -205,6 +205,76 @@ class Book
205
205
}
206
206
` ` `
207
207
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\C ore\A nnotation\A piResource;
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\C ore\A nnotation\A piResource;
268
+
269
+ /**
270
+ * @ApiResource(attributes={"pagination_client_partial"=true})
271
+ */
272
+ class Book
273
+ {
274
+ // ...
275
+ }
276
+ ` ` `
277
+
208
278
Previous chapter : [Validation](validation.md)
209
279
210
280
Next chapter : [The Event System](events.md)
Original file line number Diff line number Diff line change @@ -219,6 +219,23 @@ api_platform:
219
219
220
220
The whole configuration seen before will no longer work and Doctrine will recover its default behavior.
221
221
222
+ # ## Partial Pagination
223
+
224
+ When using the default pagination, the Doctrine paginator will execute a `COUNT` query on the collection. The result of the
225
+ ` COUNT` query is used to compute the latest page available. With big collections this can lead to quite long response times.
226
+ If you don't mind not having the latest page available, you can enable partial pagination and avoid the `COUNT` query :
227
+
228
+ ` ` ` yaml
229
+ # app/config/config.yaml
230
+
231
+ api_platform:
232
+ collection:
233
+ pagination:
234
+ partial: true # Disabled by default
235
+ ` ` `
236
+
237
+ More details are available on the [pagination documentation](pagination.md#partial-pagination).
238
+
222
239
Previous chapter : [Security](security.md)
223
240
224
241
Next chapter : [Operation Path Naming](operation-path-naming.md)
Original file line number Diff line number Diff line change 54
54
9 . [ Pagination] ( core/pagination.md )
55
55
1 . [ Disabling the Pagination] ( core/pagination.md#disabling-the-pagination )
56
56
2 . [ Changing the Number of Items per Page] ( core/pagination.md#changing-the-number-of-items-per-page )
57
+ 3 . [ Partial Pagination] ( core/pagination.md#partial-pagination )
57
58
10 . [ The Event System] ( core/events.md )
58
59
11 . [ Content Negotiation] ( core/content-negotiation.md )
59
60
1 . [ Enabling Several Formats] ( core/content-negotiation.md#enabling-several-formats )
80
81
2 . [ Force Eager] ( core/performance.md#force-eager )
81
82
3 . [ Override at Resource and Operation Level] ( core/performance.md#override-at-resource-and-operation-level )
82
83
4 . [ Disable Eager Loading] ( core/performance.md#disable-eager-loading )
84
+ 3 . [ Partial Pagination] ( core/performance.md#partial-pagination )
83
85
18 . [ Operation Path Naming] ( core/operation-path-naming.md )
84
86
1 . [ Configuration] ( core/operation-path-naming.md#configuration )
85
87
2 . [ Create a Custom Operation Path Naming] ( core/operation-path-naming.md#create-a-custom-operation-path-resolver )
You can’t perform that action at this time.
0 commit comments