Skip to content

Collection returned by the collection data provider must implement PaginatorInterface to return totalCount field #6968

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

Closed
Jdikasa opened this issue Feb 13, 2025 · 3 comments
Labels

Comments

@Jdikasa
Copy link

Jdikasa commented Feb 13, 2025

API Platform version(s) affected: 4.0

Description
I encountered an issue when trying to get the "totalCount" from "paginationInfo" in graphql, while using "page" pagination in API Platform used in Laravel. The following error is displayed:

"extensions": { "debugMessage": "Collection returned by the collection data provider must implement ApiPlatform\\State\\Pagination\\PaginatorInterface to return totalCount field.", "file": "/Users/myUser/folder/projectname/vendor/api-platform/graphql/State/Processor/NormalizeProcessor.php", "line": 212, ... }

How to reproduce

  1. Open the Model file, setup the pagination type :

#[ApiResource(
paginationType: 'page',
)
class MyModel extends Model
{
}

  1. write the graphql query :

query getMyModdel ($page: Int) { demandes (page: $page){ collection{ id } paginationInfo{ totalCount } } }

the same issue occurs when trying to get "hasNextPage"

Additional Context

•	API Platform Version: 4.0
•	PHP Version: 8.2
•	Framework: Laravel 11
@soyuka
Copy link
Member

soyuka commented Feb 14, 2025

@toitzi did you did you experiment this or have an idea where it comes from?

@toitzi
Copy link
Contributor

toitzi commented Feb 14, 2025

@soyuka no i haven't but i will look into it

Copy link

stale bot commented Apr 15, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 15, 2025
@stale stale bot closed this as completed Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants