Cap Collectif Developers - GraphQL API
Listing events
The following query looks up the 2 most recent events, and returns each event's title, content and URL:
{
events(first: 2) {
edges {
node {
title
body
url
}
}
}
}
Values of first
(and last
) arguments must be within 0-100. So if you want to retrieve more than 100 events you must use pagination.
We use a cursor based pagination, first let's add pageInfo
and totalCount
to our previous query :
{
events(first: 2) {
edges {
node {
title
body
url
}
}
totalCount
pageInfo {
hasNextPage
endCursor
}
}
}
Our pageInfo
object contains everything we need to page. In this example, the endCursor
value is YXJyYXljb25uZWN0aW9uOjM=
. You can use this value to request the next 2 events :
{
events(first: 2, after: "YXJyYXljb25uZWN0aW9uOjM=") {
totalCount
pageInfo {
hasNextPage
endCursor
}
edges {
node {
title
body
url
}
}
}
}