Skip to content

Conversation

webda2l
Copy link
Contributor

@webda2l webda2l commented Sep 18, 2021

Q A
Branch? main?
Tickets #...
License MIT
Doc PR api-platform/docs#...

See if considered as fix or not?

Use case:

...
#[QueryCollection(name: 'collectionQueryCursor', resolver: MiscCollectionResolver::class)]
#[QueryCollection(name: 'collectionQueryPage', resolver: MiscCollectionResolver::class, paginationType: 'page', paginationItemsPerPage:12, paginationClientEnabled: true)]
...

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 by api_platform.defaults.pagination_client_items_per_page: true
But to resolve this another issue, it require more deeper changes.

@webda2l webda2l changed the title Fix handling multi pagination type for same resource fix: handling multi pagination type for same resource Sep 18, 2021
@alanpoulain
Copy link
Member

I think it can be considered as a feature.

@webda2l
Copy link
Contributor Author

webda2l commented Sep 18, 2021

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.
But as you want! :)

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)

@webda2l webda2l marked this pull request as ready for review September 18, 2021 19:29
CHANGELOG.md Outdated

## 2.7.0

* GraphQL: Add ability to use different pagination type from queries of a same resource (#4453)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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)


$resourcePaginatedCollectionType = new ObjectType($configuration);
$this->typesContainer->set("{$shortName}Connection", $resourcePaginatedCollectionType);
$this->typesContainer->set("{$shortName}Connection_{$paginationType}", $resourcePaginatedCollectionType);
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done.

'name' => "{$shortName}Connection",
'description' => "Connection for $shortName.",
'name' => "{$shortName}Connection_{$paginationType}",
'description' => "Connection for $shortName. ({$paginationType})",
Copy link
Member

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

@webda2l webda2l changed the title fix: handling multi pagination type for same resource fix: use different pagination types for the queries of a resource Sep 20, 2021
@alanpoulain alanpoulain merged commit 0f734fa into api-platform:main Sep 20, 2021
@alanpoulain
Copy link
Member

Thank you @webda2l.

@webda2l
Copy link
Contributor Author

webda2l commented Sep 20, 2021

Thank you @webda2l.

You're welcome! Thanks to you and CoopTilleuls for your work. :)

@webda2l webda2l deleted the multi-pagination-type branch September 20, 2021 14:42
webda2l added a commit to webda2l/core that referenced this pull request Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants