Cursor used for Pagination Expires - Alternate way to Paginate?

Hello All,

I currently have the below graphQL query which extracts all items in board.

Please note in the below example that the board id is not a real board. The cursor is also not a real cursor.

{
  boards(ids: 123456789) {
    items_page (limit: 500, cursor: "fhakahdfyiewhalfhdsanhdfsfwefewwfeM" ) {
      cursor
      items {
        name
        column_values {
          column {
            title
          }
          text
        }
      }
    }
  }
}

I have about 700 items in the board. The items_page has a maximum limit of returning 500 items.

I previously used the above query to return all the remaining items (after the 1st 500).

However today, we encountered the below message

    "error_code": "CursorException",
    "status_code": 200,
    "error_message": "CursorExpiredError: The cursor provided for pagination has expired. Please refresh your query and obtain a new cursor to continue fetching items",
    "error_data": {}
}

For our specific use case, we are not looking to refresh the cursor every 60 minutes. I am wondering if it’s possible to have a cursor that would not expire or somehow increase the query limit from like 500 to 1,000.

If that’s not possible, is there an alternate GraphQL that we can use to reliably grab all the items in the boards. Without having to worry about expiring cursor?

e.g. maybe something like page where 1st page gets 500 and 2nd page gets remaining items

Thanks,
Chris

I’m a bit confused, its taking you over an hour to retrieve all the items from the board?

1 Like

Hey Cody,

Thanks for responding. For my use case, the limitation is not the length of time the query takes.

The limitation is more about only being able to return 500 items with a single item_page query.

We would either want to somehow return all 700 items with a single query, or come up with two queries (like below)

The first query would return the 1st 500 items

The 2nd query would return the remaining items.

Unfortunately for our use case we can’t really support dynamically refreshing the cursor token from our end. In theory yes we could manually refresh the cursor token, but we we are looking for something more automated.

1 Like

I still don’t understand, if you have the cursor from the first query (that uses your criteria, not a cursor, and returns the cursor) and its still valid (since its only 60 seconds old at the max) why are you unable to immediately execute a second query to retrieve the next page of results using the cursor? Then in the second query, it returns a new cursor, that you use for the third query, and so on.

1 Like

Hi Cody,

The internal system that we use can’t grab the Cursor token that’s initially generated.

In Postman:

I can run the initial query, grab the cursor token, paste it in the subsequent query and get the the remaining results.

But unfortunately our internal system doesn’t have that capability to automatically grab that initial cursor token and then use it for the subsequent query.

So I’m wondering if there are workarounds.

If not, no worries.

Chris

1 Like

You will need to implement an external system/process that performs the monday interactions, and your internal system makes a call to that and waits for it to get all the results.

May I ask if this is a proprietary system or something off the beaten path? What language is this in that it cant store a variable and pass to another function call?

1 Like

There is also monday code (which is based on nodejs) which is in beta but lets you run code in the monday infrastructure within the apps framework. It may be entirely possible to write something there in javascript which your internal system sends data to, and queries from. That would act as an abstraction layer, where you can preprocess or handle the complex work, and your system just passes data in and out.

Have one follow up question here.

Is there a way to edit the below query, so that I sort on name by descending order?

{
  boards(ids: 123456789) {
    items_page(limit: 500) {
      cursor
      items {
        name
        column_values {
          column {
            title
          }
          text
        }
      }
    }
  }
}

The above query looks to by default sort on the name field by ascending order.

Wondering if there is a way to adjust the above query so we sort on the name field by descending order (Z-A).

I saw some references to query_params and sort by, but not sure how to incorporate into the query.

Best,
Chris

Hi there @christopher.matthews,

Can you please try something like this:

{
  boards(ids: 123456789) {
    items_page(
      limit: 500
      query_params: {order_by: [{column_id: "name", direction: desc}]}
    ) {
      cursor
      items {
        name
        column_values {
          column {
            title
          }
          text
        }
      }
    }
  }
}

Let me know how that goes!

Cheers,
Matias