What problem does this address?
When using useEntityRecords, the returned object also contains totalItems and totalPages based on the getEntityRecordsTotalItems and getEntityRecordsTotalPages selectors. Those selectors use meta values of the queries, but those meta values only get set if the entity config has supportsPagination enabled.
See resolvers.js.
At the moment, only the postType and taxonomy entity kinds support pagination. Which means for comments, one can use the per_page query arg, and it works (because it's passed to the REST API), but getEntityRecords does not return the total items and total pages.
I guess the reason behind this is, that comments are under the root kind, and things like site options etc. do not really need pagination. But actually, the globalStyles entity config supports pagination.
A workaround is to use apiFetch and the X-WP-Total headers oneself. But getEntityRecords / useEntityRecords is such a handy feature and nice abstraction over that.
What is your proposed solution?
Enable supportsPagination to the comment entity config in core-data/src/entities.js. Because the underlying api endpoint does in fact support pagination.
There may be other entities that benefit from this support, like menus, menuItems, plugins, ...?
What problem does this address?
When using
useEntityRecords, the returned object also containstotalItemsandtotalPagesbased on thegetEntityRecordsTotalItemsandgetEntityRecordsTotalPagesselectors. Those selectors use meta values of the queries, but those meta values only get set if the entity config hassupportsPaginationenabled.See
resolvers.js.At the moment, only the
postTypeandtaxonomyentity kinds support pagination. Which means for comments, one can use theper_pagequery arg, and it works (because it's passed to the REST API), butgetEntityRecordsdoes not return the total items and total pages.I guess the reason behind this is, that comments are under the root kind, and things like site options etc. do not really need pagination. But actually, the globalStyles entity config supports pagination.
A workaround is to use apiFetch and the X-WP-Total headers oneself. But getEntityRecords / useEntityRecords is such a handy feature and nice abstraction over that.
What is your proposed solution?
Enable
supportsPaginationto the comment entity config in core-data/src/entities.js. Because the underlying api endpoint does in fact support pagination.There may be other entities that benefit from this support, like menus, menuItems, plugins, ...?