Does allCards return more than 50 cards per query, or do we need to pass the ""first"" combined with ""after"" parameters?
Hey Nigel,Â
Â
Pipefy GraphQL API has a maximum limit of 50 objects for each request, but you can request less objects using the filter first.  allCards query has this limitation and it’s necessary to pass the parameters for Pagination.
Â
Here a pagination example:
Â
In each request you can query the pageInfo to bring the cursor for the next (or previous) list of 50 objects.Â
Â
{
allCards(pipeId: 1264926,first:5) {
edges {
node {
id
}
}
pageInfo {
endCursor
startCursor
}
}
}
Â
Here an example payload for the request:
{
"data": {
"allCards": {
"edges":
{
"node": {
"id": "368825599"
}
},
{
"node": {
"id": "369521028"
}
},
{
"node": {
"id": "373362189"
}
},
{
"node": {
"id": "373362192"
}
},
{
"node": {
"id": "375141382"
}
}
],
"pageInfo": {
"endCursor": "WyIxLjAiLCIyOC4wIiwzNzUxNDEzODJd",
"startCursor": "WyIxLjAiLCIzLjAiLDM2ODgyNTU5OV0"
}
}
}
}
Â
Â
Now you can use the startCursor for the next 5 objects:
Â
{
allCards(pipeId: 1264926,first:5,after:"WyIxLjAiLCIzLjAiLDM2ODgyNTU5OV0") {
edges {
node {
id
}
}
pageInfo {
endCursor
startCursor
}
}
}
Â
Â
Â
Hope it helps you.Â
Â
Â
Â
Thanks!!!Â
Â
Hi Marcos,
If we want to search for the next records using the "after", wouldn't it be correct to use the endCursor field instead of the startCursor ? I believe that the startCursor should be used if you want to go backwards using the "before". ???
HiÂ
Â
After posting these questions, I developed pagination routines usingÂ
Â
The wayÂ
Â
When we want to advance the pagination to the next records, we use endCursor + after. When we want to return to the previous records we use startCursor + before. See the following example:
Â
Â
{"query":"{ organizations { tables(first:10) { edges { cursor } pageInfo { startCursor endCursor hasNextPage hasPreviousPage } } } }"}
Â
This query will return the cursor of the first 10 tables of an organization:
Â
Â
{
  "data": {
    "organizations": Â
      {
        "tables": {
          "edges": b
            {
              "cursor": "MQ"
            },
            {
              "cursor": "Mg"
            },
            {
              "cursor": "Mw"
            },
            {
              "cursor": "NA"
            },
            {
              "cursor": "NQ"
            },
            {
              "cursor": "Ng"
            },
            {
              "cursor": "Nw"
            },
            {
              "cursor": "OA"
            },
            {
              "cursor": "OQ"
            },
            {
              "cursor": "MTA"
            }
          ],
          "pageInfo": {
            "startCursor": "MQ",
            "endCursor": "MTA",
            "hasNextPage": true,
            "hasPreviousPage": false
          }
        }
      }
    ]
  }
}
Â
Note that the first cursor is "MQ" and the last is "MTA", as returned in pageInfo: "startCursor": "MQ" and "endCursor": "MTA" .
Â
Now let's make a pagination of 3 in 3 records:
Â
{"query":"{ organizations { tables(first:3) { edges { cursor } pageInfo { startCursor endCursor hasNextPage hasPreviousPage } } } }"}
Â
In this case, for the example above, the records with cursor "MQ", "Mg" and "Mw" must be returned
Â
Executing the query, we have the following result:
Â
{
  "data": {
    "organizations":
      {
        "tables": {
          "edges": c
            {
              "cursor": "MQ"
            },
            {
              "cursor": "Mg"
            },
            {
              "cursor": "Mw"
            }
          ],
          "pageInfo": {
            "startCursor": "MQ",
            "endCursor": "Mw",
            "hasNextPage": true,
            "hasPreviousPage": false
          }
        }
      }
    ]
  }
}
Â
Confirming our initial expectations.
Â
Now we want to search for the next 3 records, which, according to our initial example, should return the cursors after "Mw", which are: "NA", "NQ" and "Ng" .
Â
For this we will use the "after" option and as a value we will use "endCursor", because we want the next 3 records after the last cursor, which in this case is "Mw":
Â
{"query":"{ organizations { tables(first:3, after:\"Mw\") { edges { cursor } pageInfo { startCursor endCursor hasNextPage hasPreviousPage } } } }"}
Â
The result will be:
Â
{
  "data": {
    "organizations": <
      {
        "tables": {
          "edges": r
            {
              "cursor": "NA"
            },
            {
              "cursor": "NQ"
            },
            {
              "cursor": "Ng"
            }
          ],
          "pageInfo": {
            "startCursor": "NA",
            "endCursor": "Ng",
            "hasNextPage": true,
            "hasPreviousPage": false
          }
        }
      }
    ]
  }
}
Â
That is, we obtained exactly the next expected records: "NA", "NQ" and "Ng".
Â
If in this case we used the startCursor + after, as suggested byÂ
Â
Finally, I hope that I was didactic enough to explain my understanding of how pagination should be carried out.
Reply
Join us in the Pipefy Community! 🚀
No account yet? Create an account
Login with your Pipefy credentials
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.