Skip to content

Add supportsPagination to root/comment entity config in core-data #59520

@gaambo

Description

@gaambo

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, ...?

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions