From 5b9afdd4dc3c5c2b8bedda2d12c9fb6a5547c461 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Thu, 17 Aug 2023 18:33:02 +1200 Subject: [PATCH] DOC Document maximumLimit in GraphQL schema (#329) --- .../02_query_plugins.md | 25 +++++++++++++++++++ en/04_Changelogs/5.1.0.md | 1 + 2 files changed, 26 insertions(+) diff --git a/en/02_Developer_Guides/19_GraphQL/02_working_with_dataobjects/02_query_plugins.md b/en/02_Developer_Guides/19_GraphQL/02_working_with_dataobjects/02_query_plugins.md index bd5a585be..b985fa1bf 100644 --- a/en/02_Developer_Guides/19_GraphQL/02_working_with_dataobjects/02_query_plugins.md +++ b/en/02_Developer_Guides/19_GraphQL/02_working_with_dataobjects/02_query_plugins.md @@ -64,6 +64,31 @@ isn't something we do in Silverstripe CMS. You can ignore `edges.node` and just you want to. [/notice] +#### Limiting pagination + +To change the limit for items per page for a given type, you can set the `maximumLimit` property on the `paginateList` plugin in the schema: + +**app/_graphql/models.yml** +```yaml +MyProject\Models\ProductCategory: + operations: + read: + plugins: + paginateList: + maximumLimit: 10 +``` + +To change the default limit globally, set the max_limit configuration on the `PaginationPlugin` itself: + +```yaml +SilverStripe\GraphQL\Schema\Plugin\PaginationPlugin: + max_limit: 10 +``` + +[notice] +If you want to _increase_ the limit beyond the default value, you will also need to set a new `default_limit` configuration value on the `PaginationPlugin`. +[/notice] + #### Disabling pagination Just set it to `false` in the configuration. diff --git a/en/04_Changelogs/5.1.0.md b/en/04_Changelogs/5.1.0.md index d3dcce467..cdc7a2161 100644 --- a/en/04_Changelogs/5.1.0.md +++ b/en/04_Changelogs/5.1.0.md @@ -128,6 +128,7 @@ SilverStripe\SessionManager\Models\LoginSession: - The [`ListboxField`](api:SilverStripe\Forms\ListboxField) now has a react component, and can be used in react-powered contexts such as within elemental blocks - A new [`FieldsValidator`](api:SilverStripe\Forms\FieldsValidator) class has been added, which simply calls [`validate()`](api:SilverStripe\Forms\FormField::validate()) on all data fields in the form to ensure fields have valid values. Functionally equivalent to an empty [`RequiredFields`](api:SilverStripe\Forms\RequiredFields) validator. - A configuration option has been added to [`GarbageCollectionService`](api:SilverStripe\SessionManager\Services\GarbageCollectionService) to limit the number of items it removes each time you run garbage collection on session data. See [garbage collection](/developer_guides/cookies_and_sessions/managing_sessions/#garbage-collection) for more details. +- In your GraphQL schemas, you can now define the pagination limit at a schema level. See [limiting pagination](/developer_guides/graphql/working_with_dataobjects/query_plugins/#limiting-pagination) in the GraphQL documentation for more details. ## API changes