refinedev/refine

[DOC]: clarify rowCount retrieval and improve pagination examples

lnikitadobrenkol opened this issue · 0 comments

Documentation issue

The issue relates to existing sections of the documentation concerning data fetching hooks. The current documentation lacks explicit details on how Refine retrieves the total row count for paginated data via the x-total-count header.

Links to relevant sections:

  1. useList Hook Documentation
  2. useInfiniteList Hook Documentation
  3. Cursor-Based Pagination Guide in useInfiniteList

Describe the thing to improve

Currently, the Refine documentation lacks explicit information on how the rowCount for paginated data is retrieved from server-side pagination. More specifically:

  • It isn't clear how Refine determines rowCount if it's not explicitly provided by the backend.
  • Developers may be confused regarding the behaviour of the useList and useInfiniteList hooks with server-side pagination.
  • The documentation does not provide sufficient details on the use of the x-total-count header or fallback mechanisms for obtaining the total count of rows.

Suggested Improvements:

  1. Clarify Documentation in Hook Guides:

    • Add a dedicated section to the useList and useInfiniteList hook guides explaining how the total row count is retrieved using the x-total-count header.
    • Include examples or code snippets demonstrating proper usage.
  2. Update Data Fetching Guide:

    • In the data fetching guide, provide a thorough explanation of the getList method and how it handles paginated data and total row count retrieval.
    • Explain the fallback mechanism used if the x-total-count header is absent.

These additions will provide clear guidance to developers on how Refine determines the rowCount and how to ensure accurate pagination data is fetched.

Describe the solution (optional)

To improve the experience of beginners and readers, consider these solutions:

  1. Add Detailed Explanations:

    • Hook Guides: Include a new sub-section in the useList and useInfiniteList hook guides specifically covering how Refine retrieves the rowCount from the x-total-count header during server-side pagination. Make it clear how the total count is obtained, even when not directly provided by the backend, and describe the fallback mechanism.
    • Data Fetching Guide: Update the guide to include a step-by-step explanation of the getList method's behavior. Emphasize its role in data retrieval, including how it ensures accurate pagination.
  2. Provide Code Examples:

    • Add practical examples demonstrating how the x-total-count header is used within a real-world data provider implementation, including cursor-based pagination.
    • Highlight the fallback logic when the header is absent, providing best practices for consistent data retrieval.
  3. Cross-Link Pages:

    • Ensure consistent cross-referencing between the hooks documentation and the data fetching guide so readers can easily find all relevant details.
  4. General Grammar Fixes:

    • Review the existing documentation for minor grammar issues and fix where appropriate.