Skip to content

Offset-based pagination fetchMore updates loading state inconsistently #12932

@colinlawrence

Description

@colinlawrence

Issue description

I have identified a bug in the Apollo Client behaviour when using offset-based pagination with fetchMore. When using fetchMore at the end of a list, the loading state updates to true but then never updates to false when the returned data is an empty array (before the data is merged into the cache). This issue seems to be related to defining the returned object with an array field and having a large number of items in the list.

Link to reproduction

https://codesandbox.io/p/devbox/nifty-lake-fvhdxm

Reproduction steps

  1. Visit the link above.

  2. Click the button Fetch more to simulate reaching the bottom of list.

  3. Continue to click the button Fetch more until all of the data is fetched (4996 items).

  4. Click the button Fetch more one more time to simulate the final request that returns an empty array.

  5. Note that the loading state does not return to false.

Expected behaviour

The loading state should return to false when all of the data is fetched.

Actual behaviour

The loading state does not return to false. It seems that the merged pagination data is being passed to the cache but this is not triggering events downstream.

Additional notes

Updating the total item count to 4995 items and performing the reproduction steps does not result in the same behaviour as the loading state returns to false as expected.
Updating the item schema definition and removing the attributes array field does not result in the same behaviour as the loading state returns to false as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions