Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connectionFromArray incorrectly calculates hasPreviousPage when paginating with first/after #286

Open
smoak opened this issue Jul 27, 2020 · 1 comment

Comments

@smoak
Copy link

smoak commented Jul 27, 2020

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.

@Kosai106
Copy link

Duplicate #58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants