Skip to content
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

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

Open
Jdikasa opened this issue Feb 13, 2025 · 2 comments

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

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

No branches or pull requests

3 participants