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

[FR] GraphQL: Return pagination information in query results #4847

Open
daltonrooney opened this issue Aug 29, 2019 · 5 comments

Comments

@daltonrooney
Copy link

commented Aug 29, 2019

In CraftQL, we can include a request for the total count and other pagination information along with our main query. The query format looks like this:

{
  entriesConnection {
    totalCount
    pageInfo {
      hasPreviousPage
      hasNextPage
      currentPage
      totalPages
      first
      last
    }
    entries {
      ...on Posts {
        title
        body
      }
    }
  }
}

At the very least, I can use totalCount plus the limit & current offset params to build a pagination component, but without totalCount I'm kind of stuck. I'm wondering if there's an equivalent in the new Craft GraphQL implementation or plans to add a similar feature.

@andris-sevcenko

This comment has been minimized.

Copy link
Member

commented Aug 29, 2019

@daltonrooney right, so the connection pattern was dropped because the whole edge pagination model relies on paging by cursor which is something that Craft does not support currently.

I'll look into adding totalCount for relational fields.

@narration-sd

This comment has been minimized.

Copy link
Contributor

commented Aug 29, 2019

@brandonkelly

This comment has been minimized.

Copy link
Member

commented Aug 29, 2019

@andris-sevcenko should probably just be count if that isn’t conflicting with something else; totalCount is a bit redundant.

@monochromat13

This comment has been minimized.

Copy link

commented Sep 16, 2019

+1 on this. Just came across the same issue.

@andris-sevcenko andris-sevcenko added this to the 3.4 milestone Sep 17, 2019

@andris-sevcenko

This comment has been minimized.

Copy link
Member

commented Sep 17, 2019

This would require some adjustments to eager-loading mechanics for Craft, so we've slated this for 3.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.