-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
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
-
Visit the link above.
-
Click the button
Fetch more
to simulate reaching the bottom of list. -
Continue to click the button
Fetch more
until all of the data is fetched (4996 items). -
Click the button
Fetch more
one more time to simulate the final request that returns an empty array. -
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.