ERROR: no data, execute node first (Paginating with a cursor)

I’m attempting to paginate requests to a graphQL API. I pasted the workflow below minus the authorization code node which comes just prior to the request.

The problem is that on my first run, there will be no cursor, so it should be empty. On my subsequent runs, I’ll receive a cursor from the API call and I can use it to get the next bit of data. But when I try to run it, the first run fails with “ERROR: no data, execute “Set cursor” node first”. I can’t seem to get it to treat the value as null instead of erroring out.

One solution that seems to bypass this issue is having the set cursor node run first with this logic:

{{$if($runIndex == 0, “”, $json.data.visits.pageInfo.endCursor)}}

It feels like what I was doing before should work though. If a node is referenced that hasn’t run yet, it should return as undefined, null, or something like that rather than erroring out.

Hi @Giovanni_Segar, glad to hear you figured out a way to achieve this already.

If a node is referenced that hasn’t run yet, it should return as undefined, null, or something like that rather than erroring out

Seeing the “Set cursor” nodes comes directly before your “Get visits” node throwing the error you could use an expression of {{ $json.cursor }} to achieve this. This expression wouldn’t try to access data from a node that might or might not have run, so wouldn’t throw the error you have encountered.

In this particular instance, I actually have one call between the cursor and the API call to get the authorization code from my refresh token. I left it out to avoid exposing creds.

I have to do that call each time because the token expires relatively quickly. But if I were to move the set cursor to be in between the calls so I can reference without a node name, I’d run into the same issue because the cursor would need to reference a node that may or may not have run yet.

In this case, I found a workaround, but I think it’d be better to handle these cases with null/undefined and just present a warning to the user