Skip to content

Relay pagination omits pageInfo fields #2521

@r0busta

Description

@r0busta

For some reason, the relayPagination implementation doesn't copy the response pageInfo but instead picks only specific fields.

This behavior doesn't seem correct as it does not conform to the Relay spec. The spec says that the server MAY return hasPreviousPage: true for the forward pagination and hasNextPage: true for the backward one. However, the urql implementation assumes that hasPreviousPage for the forward pagination and hasNextPage, for the backward one, respectively, response fields can be ignored.

I'm happy to contribute a fix for this.

urql version & exchanges:

  • urql@^2.2.2
  • @urql/exchange-graphcache@^4.4.3

Expected behavior

relayPagination() returns all pageInfo fields regardless of to query variables.

Actual behavior

relayPagination() returns only:

  • endCursor and hasNextPage when query vars have after
  • startCursor and hasPreviousPage when query vars have before

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Oh no! A bug or unintented behaviour.help wanted ⛏️Extra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions