Skip to navigation

Pagination and sorting

Pagination

Every list query (for example grants or disclosures) accepts page and limit arguments and returns a collection plus metadata.

query GrantsPage {
grants(page: 2, limit: 50) {
collection { id grantNumber }
metadata { currentPage totalPages totalCount hasNextPage nextPage }
}
}
  • page starts at 1. Omitting it, or passing 0, returns the first page.
  • limit defaults to 50. The maximum is 200, and larger values return 200 records.

To read every record, request page: 1, then keep requesting metadata.nextPage until hasNextPage is false.

Sorting

List queries accept sortField and sortDirection.

query DisclosuresOldestFirst {
disclosures(sortField: created_at, sortDirection: ASC) {
collection { id disclosureNumber title }
}
}
  • sortField is created_at or updated_at. Each list query has its own enum type, such as DisclosureSortFieldEnum for disclosures; use that type when you pass sortField as a variable. Any other value fails query validation with extensions.status 400.
  • sortDirection is ASC or DESC. The default is DESC.
  • Every list query defaults to updated_at, so the most recently updated records come first.