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

[Modern] ReactRelayPaginationContainer pageInfo warning #1852

Open
jfizz opened this issue Jun 2, 2017 · 10 comments
Open

[Modern] ReactRelayPaginationContainer pageInfo warning #1852

jfizz opened this issue Jun 2, 2017 · 10 comments

Comments

@jfizz
Copy link

jfizz commented Jun 2, 2017

The ReactRelayPaginationContainer complains about missing pageInfo fields whenever no edges are returned from a connection. Specifically, I am seeing this warning whenever pageInfo.endCursor === null. I am able to silence the warning by returning an empty string for pageInfo.endCursor. Is an empty string the expected value in this situation or am I missing something else?

Example response:

{
  "data": {
    "user": {
      "postsConnection": {
        "edges": [],
        "pageInfo": {
          "hasNextPage": false,
          "endCursor": null,
          "hasPreviousPage": false,
          "startCursor": null
        }
      }
    }
  }
}

Warning:

Warning: ReactRelayPaginationContainer: Cannot paginate without pageInfo fields in `MyView`. Be sure to fetch hasNextPage (got `false`) and endCursor (got `null`).
@programisti
Copy link

same issue here
It shows me warning

Warning: ReactRelayPaginationContainer: Cannot paginate without pageInfo fields in `ListPage`. Be sure to fetch hasNextPage (got `false`) and endCursor (got `null`).

I have defined pageInfo fields correctly

      fragment ListPage_viewer on Viewer {
        allPosts(first: $count, after: $cursor) @connection(key: "ListPage_allPosts") {
          pageInfo{
            hasNextPage
            endCursor
          }

@MM3y3r
Copy link
Contributor

MM3y3r commented Aug 5, 2017

Is there a fix for this one yet @JenniferWang @programisti ?

@programisti
Copy link

@MaximusDesign Im not sure, I did not played around since that, because I thought was too early to play with Relay Modern.

@Oxyaction
Copy link

Same problem, the warning appears even in case there are simply no edges.

@Jose4gg
Copy link

Jose4gg commented Sep 13, 2017

Same here...

@sibelius
Copy link
Contributor

the check is here

if (typeof hasMore !== 'boolean' || typeof cursor !== 'string') {

maybe we can improve this condition

@joonhocho
Copy link

joonhocho commented Sep 22, 2017

@sibelius I think it should be

 if (typeof hasMore !== 'boolean' || edges.length > 0 && typeof cursor !== 'string') { 

as warning happens when zero edges causing cursor to be null.
It's caused by empty connection.

@krvajal
Copy link

krvajal commented Oct 15, 2020

The warning seems correct, according to the spect endCursor and startCursor are not nullable strings. I agree that when there are no edges at all, there is no startCursor or endCursor. In that case the whole connection field should be null IMO.

Some effort to update the spec is happening here #2655

@stale
Copy link

stale bot commented Dec 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Dec 25, 2020
@stale stale bot removed the wontfix label Apr 14, 2021
@stale
Copy link

stale bot commented Jan 9, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants