3

I have been trying to figure out how I want to implement pagination in my graphql api. I was thinking of following Relay Cursor Connections Specification

This is simple enough building something that looks like

{
  allFilms {
    edges {
      cursor
      node {
        id
        title
      }
    }
    pageInfo {
      hasNextPage
      hasPreviousPage
      startCursor
      endCursor
    }
  }
}

My question is around the cursor. I always thought the cursor was the equivalent of an id/primary key. From my reading it is not. It is a point/location in the connection.

Can someone explain to me what it is and where it comes from. Is this a NoSql concept? I am guessing when connecting to a relational database the cursor would be the id/primary key?

Ryan-Neal Mes
  • 6,003
  • 7
  • 52
  • 77

1 Answers1

1

Not quite sure if this helps, but there is a short explanation here: In GraphQL what's the meaning of "edges" and "node"?

The cursor is a string to help identify where to include page breaks (or at least pagination which I take to mean page breaks) but perhaps that was already explained.

Rick Henderson
  • 326
  • 3
  • 14