LakeQL
Overview
  • Introduction
Server Setup
  • createApiServer
  • defineConfig
  • Yoga Configuration
Authentication
  • JWT Authentication
  • Permissions
  • Scope Authorization
Schema Builder
  • Builder Configuration
  • Scalar Types
  • Comparison Types
  • Pagination
  • Input Validation
Customization
  • Custom Queries & Mutations
  • Extending Core
  • CORS Configuration
GitHub
LakeQL
  1. API
  2. Schema Builder
  3. Pagination

On this page

  1. Paging input
  2. PageInfo output
  3. ConnectionInterface
  4. Configuring maxRecordsPerPage
  5. Example query

Pagination

Built-in page-based pagination with Paging input, PageInfo output, and ConnectionInterface.

LakeQL uses offset-based pagination (page + perPage) rather than cursor-based pagination. This maps naturally to Trino's LIMIT and OFFSET clauses and provides predictable navigation for tabular data.

Paging input #

The Paging input type is available on all generated query fields:

1
2
3
4
5
input Paging {
  page: Int = 1
  perPage: Int = 100
}
FieldDefaultConstraints
page1Must be ≥ 1
perPage100Must be ≥ 1 and ≤ maxRecordsPerPage

PageInfo output #

Every paginated response includes a PageInfo object:

1
2
3
4
5
6
7
8
9
type PageInfo {
  currentPage: Int!
  hasNext: Boolean!
  hasPrevious: Boolean!
  maxPages: Int!
  nextPage: Int
  previousPage: Int
}
FieldDescription
currentPageThe current page number
hasNextWhether more pages exist after the current one
hasPreviousWhether pages exist before the current one
maxPagesTotal number of pages based on totalCount and perPage
nextPagePage number for the next page (null if on last page)
previousPagePage number for the previous page (null if on first)

ConnectionInterface #

All paginated query responses conform to the ConnectionInterface:

1
2
3
4
5
6
interface ConnectionInterface<T> {
  totalCount: number
  pageInfo: PageInfoInterface
  nodes: T[]
}

In GraphQL, this looks like:

1
2
3
4
5
6
type UserConnection {
  totalCount: Int!
  pageInfo: PageInfo!
  nodes: [User!]!
}

Configuring maxRecordsPerPage #

The maximum allowed value for perPage is controlled by:

  1. The API_MAX_RECORDS_PER_PAGE environment variable (default: 2000 )
  2. The maxRecordsPerPage option in defineConfig
1
2
3
4
5
6
7
8
import { defineConfig } from "@lakeql/api/config"
import { allConfigs } from "./generated/configs"

export default defineConfig({
  allConfigs,
  maxRecordsPerPage: 500, // override the env default
})

Requesting more than maxRecordsPerPage returns a validation error.

Example query #

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
query PaginatedUsers {
  users(paging: { page: 2, perPage: 25 }) {
    totalCount
    pageInfo {
      currentPage
      hasNext
      hasPrevious
      maxPages
      nextPage
      previousPage
    }
    nodes {
      id
      name
      email
    }
  }
}

Previous page

Comparison Types

Next page

Input Validation