The ReactRelayPaginationContainer complains about missing pageInfo fields whenever no edges are returned from a connection. Specifically, I am seeing this warning whenever pageInfo.endCursor === null. I am able to silence the warning by returning an empty string for pageInfo.endCursor. Is an empty string the expected value in this situation or am I missing something else?
Example response:
{
"data": {
"user": {
"postsConnection": {
"edges": [],
"pageInfo": {
"hasNextPage": false,
"endCursor": null,
"hasPreviousPage": false,
"startCursor": null
}
}
}
}
}
Warning:
Warning: ReactRelayPaginationContainer: Cannot paginate without pageInfo fields in `MyView`. Be sure to fetch hasNextPage (got `false`) and endCursor (got `null`).
same issue here
It shows me warning
Warning: ReactRelayPaginationContainer: Cannot paginate without pageInfo fields in `ListPage`. Be sure to fetch hasNextPage (got `false`) and endCursor (got `null`).
I have defined pageInfo fields correctly
fragment ListPage_viewer on Viewer {
allPosts(first: $count, after: $cursor) @connection(key: "ListPage_allPosts") {
pageInfo{
hasNextPage
endCursor
}
Is there a fix for this one yet @JenniferWang @programisti ?
@MaximusDesign Im not sure, I did not played around since that, because I thought was too early to play with Relay Modern.
Same problem, the warning appears even in case there are simply no edges.
Same here...
the check is here https://github.com/facebook/relay/blob/3c89c917f62bd5437e0fb24bf78a1cf3de4f8e93/packages/react-relay/modern/ReactRelayPaginationContainer.js#L515
maybe we can improve this condition
@sibelius I think it should be
if (typeof hasMore !== 'boolean' || edges.length > 0 && typeof cursor !== 'string') {
as warning happens when zero edges causing cursor to be null.
It's caused by empty connection.
The warning seems correct, according to the spect endCursor and startCursor are not nullable strings. I agree that when there are no edges at all, there is no startCursor or endCursor. In that case the whole connection field should be null IMO.
Some effort to update the spec is happening here https://github.com/facebook/relay/pull/2655
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
same issue here
It shows me warning
I have defined pageInfo fields correctly