Cedalio
Search
K

Pagination

Cedalio automatically generates a connection type for paginating entries. If you're fetching by collection, or fetching many relation entries then you can provide arguments to paginate.
You can use the following arguments for pagination:
  • after: String — Fetch items after the provided cursor value.
  • before: String — Fetch items before the provided cursor value.
  • first: Int — Fetch the first provided entries in the result set, max 100.
  • last: Int — Fetch the last amount of entries in the result set, max 100.
You must provide either a first or last value when paginating results.
Schema
Generated types
First
Last
First + after
Last + Before
Last + after
type Post @model {
title: String
}
type Post {
id: ID!
title: String!
}
type PostConnection {
edges: [PostEdge]
pageInfo: PageInfo!
}
query {
postCollection(first: 100) {
edges {
node {
title
}
}
}
}
query {
postCollection(last: 100) {
edges {
node {
title
}
}
}
}
query {
postCollection(first: 100, after: "post_AAAAAAAAAA0000000000") {
edges {
node {
title
}
}
}
}
query {
postCollection(last: 100, before: "post_AAAAAAAAAA0000000000") {
edges {
node {
title
}
}
}
}
query {
postCollection(last: 100, after: "post_AAAAAAAAAA0000000000") {
edges {
node {
title
}
}
}
}
Items returned for first are sorted in the order in which you added them, with the first added item first in the list. For last, the first item in the list is the last item you added.

Connections

Collections return a [modelName]Connection type containing edges, and pageInfo fields of the types [[modelName]Edge] and PageInfo!, respectively.

Edges

The edges field returns the actual data as [[modelName]Edge]. Each [modelName]Edge entry contains both cursor, and node.
  • cursor — The cursor of the current item in the result set.
  • node — The current edge node. This will be of the type you're querying, for example Post.
Schema
Generated types
type Post @model {
title: String
}
type PostEdge {
cursor: String!
node: Post!
}
type Post {
id: ID!
title: String
}

PageInfo

The PageInfo! type that is returned for the field pageInfo inside of your [modelName]Connection type provides helpful data for the purposes of pagination.
  • startCursor: String — The cursor for the node in the current paginated result set.
  • endCursor: String — The cursor for the node in the current paginated result set.
  • hasNextPage: Boolean!true or false if there's a next page of results.
  • hasPreviousPage: Boolean!true or false if there is a previous page of results.

SchemaGenerated types

type Post @model {
title: String
}

Nested pagination

The previous types ([modelName]Connection, [modelName]Edge, PageInfo) and arguments (first, last, before, after) are available when you have a one-to-many, many-to-one, or many-to-many relationship between models.
schema.graphql
type Category @model {
name: String
posts: [Post]
}
type Post @model {
title: String
category: Category
}
Last modified 4mo ago