- Issue created by @queenvictoria
- Merge request !21Issue #3484236 Support page and items_per_page parameters. → (Open) created by queenvictoria
I'm calling Views using GraphQL. I've tried setting the `page` parameter. However I always receive the first page regardless of the value of `page`.
executeWithQueryParams(queryParams: {key: "page", value: $page}) {
4. Note that the first (0 indexed) page is returned.
5. Also note that a warning appears in the Drupal logs
Warning: Undefined array key "items_per_page" in Drupal\graphql_core_schema\Plugin\GraphQL\DataProducer\ViewExecutor->resolve() (line 191 of /app/web/modules/contrib/graphql_core_schema/src/Plugin/GraphQL/DataProducer/ViewExecutor.php)
It seems as though the `page` parameter is checked for but not used:
public function resolve(ViewExecutable $executable, $page, $limit, $sortBy, $sortOrder, ?array $contextualFilters = [], ?array $filters = [], ?array $queryParams = []) {
$page = $page ?? 0;
if (!empty($queryParams['page'])) {
$limit = $queryParams['items_per_page'];
}
I propose a patch to support overriding `limit` and `page`.
Create a fork and a patch.
None
Both items_per_page and page will be supported.
executeWithQueryParams(queryParams: [{key: "page", value: $page},{key: "items_per_page", value: $items_per_page}]) {
None
Active
1.0
Code