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

relayStylePagination read method clobbers pageInfo.startCursor and pageInfo.endCursor #8267

Closed
migueloller opened this issue May 19, 2021 · 5 comments · Fixed by #8438
Closed

Comments

@migueloller
Copy link

Intended outcome:
With a query as follows:

query {
  someConnectionField {
    edges {
      node {
        id
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}

I would expect endCursor to be the value returned from the API, not "".

Actual outcome:
Even though the API returns a valid cursor in endCursor, the relayStylePagination type policy attempts to read it from edges[0].cursor (or the last edge's cursor) and completely replaces the one in `pageInfo.

These should default to pageInfo.{startCursor,endCursor} and not "".

let startCursor = "";
let endCursor = "";

How to reproduce the issue:
Perform a query as described above while using relayStylePagination.

@meliborn
Copy link

Having the same issue, can't use relayStylePagination() at all. Cursors are always empty.

@meliborn
Copy link

meliborn commented May 24, 2021

So i just copied all implementation and replaced

let startCursor = "";
let endCursor = "";

By

let { startCursor } = existing.pageInfo;
let { endCursor } = existing.pageInfo;

@dlqqq
Copy link

dlqqq commented Jun 28, 2021

This is a serious issue. Relay-style pagination is one of the core features offered by all GraphQL implementations, and is included in the official GraphQL docs. Can this please receive further attention?

@benjamn
Copy link
Member

benjamn commented Jun 28, 2021

@migueloller @diracs-delta @meliborn Please have a look at this PR and let me know if it meets your expectations: #8438

benjamn added a commit that referenced this issue Jun 29, 2021
@dlqqq
Copy link

dlqqq commented Jun 29, 2021

@benjamn Gave your PR a quick glance, it looks good to me. Glad it was (relatively) easy! I was just about to submit a PR earlier, but you beat me to it 😅 . TYSM!

benjamn added a commit that referenced this issue Jun 29, 2021
benjamn added a commit that referenced this issue Jun 29, 2021
…licy `read` functions (#8438)

Should fix #8267, taking inspiration from @migueloller's suggestion in
#8267 (comment)
@hwillson hwillson removed this from the MM-2021-06 milestone Jul 29, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants