Pagination Best Practices
Always use limit and offset for efficient pagination with consistent ordering.
Best Practiceβ
query GetAtomsPage($limit: Int!, $offset: Int!) {
total: atoms_aggregate {
aggregate {
count
}
}
atoms(
limit: $limit
offset: $offset
order_by: { created_at: desc }
) {
term_id
label
}
}
Key Pointsβ
- Always include order_by for consistent results
- Fetch total count using aggregates
- Use reasonable limits (10-100 items per page)
- Calculate offset as
(page - 1) * limit