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

fix(gatsby): correct hasNextPage pagination info when resultOffset is provided #32319

Merged
merged 1 commit into from
Jul 15, 2021

Conversation

angeloashmore
Copy link
Contributor

@angeloashmore angeloashmore commented Jul 9, 2021

Description

This PR fixes the hasNextPage field in the pageInfo data for paginated queries. When querying for paginated content using skip and limit, the hasNextPage field was returning false for anything other than the first page, even if it a next page of nodes exists.

Example query:

{
  allPrismicPage(limit: 2 skip: 2) {
    nodes {
      id
    }
    pageInfo {
    hasNextPage
    }
  }
}

If there were a total of 6 nodes, hasNextPage was returning false. It now returns true.

The logic for determining the value of hasNextPage is edited in this PR and includes comments describing the logic.

Documentation

Existing documentation: https://www.gatsbyjs.com/docs/schema-root-fields/#pagination-types

There is no need to update the documentation as this is a bug fix.

Related Issues

None

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jul 9, 2021
@vladar vladar added topic: GraphQL Related to Gatsby's GraphQL layer and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jul 15, 2021
Copy link
Contributor

@vladar vladar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thank you 👍

@vladar vladar added this to To cherry-pick in Release candidate via automation Jul 15, 2021
@vladar vladar added this to To cherry-pick in V3 Release Hotfixes via automation Jul 15, 2021
@vladar vladar changed the title fix: correct hasNextPage pagination info when resultOffset is provided fix(gatsby): correct hasNextPage pagination info when resultOffset is provided Jul 15, 2021
@vladar vladar added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label Jul 15, 2021
@gatsbybot gatsbybot merged commit 9f8a580 into gatsbyjs:master Jul 15, 2021
@angeloashmore
Copy link
Contributor Author

Thanks @vladar!

LekoArts pushed a commit that referenced this pull request Jul 16, 2021
@LekoArts LekoArts moved this from To cherry-pick to Backport PR opened in Release candidate Jul 16, 2021
gatsbybot pushed a commit that referenced this pull request Jul 16, 2021
… provided (#32319) (#32386)

(cherry picked from commit 9f8a580)

Co-authored-by: Angelo Ashmore <angeloashmore@users.noreply.github.com>
@LekoArts LekoArts moved this from Backport PR opened to Backported in Release candidate Jul 16, 2021
vladar added a commit that referenced this pull request Jul 23, 2021
gatsbybot pushed a commit that referenced this pull request Jul 23, 2021
* Revert "fix(gatsby): correct hasNextPage pagination info when resultOffset is provided (#32319)"

This reverts commit 9f8a580

* fix(gatsby): fixed pagination logic

* try to make tests less confusing
LekoArts pushed a commit that referenced this pull request Jul 26, 2021
* Revert "fix(gatsby): correct hasNextPage pagination info when resultOffset is provided (#32319)"

This reverts commit 9f8a580

* fix(gatsby): fixed pagination logic

* try to make tests less confusing

(cherry picked from commit 2dbe647)
LekoArts pushed a commit that referenced this pull request Jul 26, 2021
* Revert "fix(gatsby): correct hasNextPage pagination info when resultOffset is provided (#32319)"

This reverts commit 9f8a580

* fix(gatsby): fixed pagination logic

* try to make tests less confusing

(cherry picked from commit 2dbe647)

Co-authored-by: Vladimir Razuvaev <vladimir.razuvaev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes topic: GraphQL Related to Gatsby's GraphQL layer
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants