For the complete documentation index, see llms.txt. This page is also available as Markdown.

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
            }
          }
        }
      }
    }
  }
}

Response includes requested data and endCursor of YXJyYXljb25uZWN0aW9uOjE=, which we'll use in Page 2:

Pass the first page's endCursor into first:

  • Begins directly on the second page

  • hasPreviousPage is now true

  • New endCursor is YXJyYXljb25uZWN0aW9uOjM=, let's use it on Page 3:

This time, for variety, let's just take 1, and return different fields:

Based on the query being adjust to first: 1, we should only see one item returned in page 3.

  • Only shows the fields requested (fields don't need to be the same each time)

  • Shows reviewType

  • Only shows 1 result, per first

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:

  • Returns 2 items

  • Last item

  • hasPreviousPage is true

  • startCursor of YXJyYXljb25uZWN0aW9uOjQ= will be used in before on the next page

Since we're moving backwards, we use before:

Continue with cursor

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