Summary
Using forward pagination (first/after) with connectionFromArray results in incorrect pageInfo.
Description
From the relay spec hasPreviousPage states:
If the client is paginating with first/after, then the client may return true if edges prior to after exist, if it can do so efficiently, otherwise may return false
However, hasPreviousPage is always false when using first/after:
return {
edges,
pageInfo: {
startCursor: firstEdge ? firstEdge.cursor : null,
endCursor: lastEdge ? lastEdge.cursor : null,
hasPreviousPage:
typeof last === 'number' ? startOffset > lowerBound : false,
hasNextPage: typeof first === 'number' ? endOffset < upperBound : false,
},
};
The tests also seem to be incorrect as well.
Expectation
hasPreviousPage should be true when forward pagination arguments are used. There is enough information to calculate if edges prior to after exist.