Paginating queries

The Eduflow API supports paginating lists of data through standard GraphQL connections.

Example

first: 2 will pick the first 2 reviews from this Teacher review activity:

{
  activity(id: "5572112e-66ad-45de-bd83-1332df79f51c") {
    ... on TeacherReviewActivity {
      title
      activityType
      reviews(first: 2) {
        pageInfo {
          hasPreviousPage
          hasNextPage
          endCursor
        }
        edges {
          node {
            createdAt
            modifiedAt
            answers {
              booleanAnswer
              scaleAnswer
              textAnswer
              comment
              scaleAnswerPercentage
            }
            givers {
              email
            }
            receivers {
              email
            }
          }
        }
      }
    }
  }
}

The above example moves between 3 pages, passing the endCursor of the previous query into the after of the next page's. The initial (first) page doesn't need any after. The final page alters the fields queried and changes the amount returned.

Bonus: Start at last item and travel backwards

last: 2 instead of first:

{
  activity(id: "5572112e-66ad-45de-bd83-1332df79f51c") {
    ... on TeacherReviewActivity {
      title
      activityType
      reviews(last: 2) {
        pageInfo {
          hasPreviousPage
          hasNextPage
          startCursor
        }
        edges {
          node {
            reviewType
            createdAt
            modifiedAt
            answers {
              scaleAnswerPercentage
            }
            givers {
              email
            }
            receivers {
              email
            }
          }
        }
      }
    }
  }
}

GraphQL Terms

Term

Description

first

For slicing, fetch the items at the beginning

last

For slicing, beginning at last item

after

Accepts a cursor ID of where to continue paginating

cursor

ID of the cursor, in Eduflow, sometimes equal to pageInfo.endCursor

pageInfo

Structure containing cursor location, item count, previous/next page

  • startCursor

  • endCursor: Use this in the next page's after: to start on next page

  • hasPreviousPage

  • hasNextPage

edges

List of containing nodes (list of objects) of the connection

node

The object itself, e.g. User, Activity

See also

Last updated