Problem/Motivation
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`.
Steps to reproduce
- Create a View with more than 1 page worth of results.
- Call the View from GraphQL.
- Update the call adding `page=1`
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)
Proposed resolution
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`.
Remaining tasks
Create a fork and a patch.
User interface changes
None
API changes
Both items_per_page and page will be supported.
executeWithQueryParams(queryParams: [{key: "page", value: $page},{key: "items_per_page", value: $items_per_page}]) {
Data model changes
None
Issue fork graphql_core_schema-3484236
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
queenvictoria commentedComment #4
czigor commentedI'm working on this.
Comment #5
czigor commentedComment #7
czigor commentedComment #10
das-peter commented@czigor Would you have any hint on how I can define get multiple values for a queryParams value? I've tried all possible notations but can't seem to get that going.
The previous handling had explicit detection of
$filter['expose']['multiple']to differentiate between String and [String].This has been removed by this adjustment and I don't think there is a way to get that functionality going with the current implementation.
Comment #11
das-peter commentedCreated a follow-up ticket for my open question: #3556134: Views: Re-introduce typed filter values.
Comment #12
czigor commented@das-peter Thanks for the feedback, multiple values were indeed ignored during this ticket. Let's continue in #3556134: Views: Re-introduce typed filter values..