-
-
Notifications
You must be signed in to change notification settings - Fork 933
fix: use different pagination types for the queries of a resource #4453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I think it can be considered as a feature. |
https://api-platform.com/docs/core/graphql/#using-the-page-based-pagination could be interpreted as it's already implemented. Same about the second issue i mentioned, https://api-platform.com/docs/core/pagination/#changing-the-number-of-items-per-page-client-side-for-a-specific-resource (that can only be disabled by resource/query, but only if enabled globally, and not the inverse) |
CHANGELOG.md
Outdated
|
||
## 2.7.0 | ||
|
||
* GraphQL: Add ability to use different pagination type from queries of a same resource (#4453) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* GraphQL: Add ability to use different pagination type from queries of a same resource (#4453) | |
* GraphQL: Add ability to use different pagination types for the queries of a resource (#4453) |
src/GraphQl/Type/TypeBuilder.php
Outdated
|
||
$resourcePaginatedCollectionType = new ObjectType($configuration); | ||
$this->typesContainer->set("{$shortName}Connection", $resourcePaginatedCollectionType); | ||
$this->typesContainer->set("{$shortName}Connection_{$paginationType}", $resourcePaginatedCollectionType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, the type should be:
shortNameCursorConnection
Could you please make the changes to obtain this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done.
src/GraphQl/Type/TypeBuilder.php
Outdated
'name' => "{$shortName}Connection", | ||
'description' => "Connection for $shortName.", | ||
'name' => "{$shortName}Connection_{$paginationType}", | ||
'description' => "Connection for $shortName. ({$paginationType})", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it should be:
Page connection for shortName
Thank you @webda2l. |
You're welcome! Thanks to you and CoopTilleuls for your work. :) |
See if considered as fix or not?
Use case:
By the way, there is still an issue about
paginationClientEnabled
that is available in the QueryCollection attribute (or even ApiResource attribute), but inactive per query (or even resource) if not enabled at default configuration level byapi_platform.defaults.pagination_client_items_per_page: true
But to resolve this another issue, it require more deeper changes.