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

1 Like

Hello! I had the exact same need.
When a node isn’t excuted yet, it’ll be great to get “undefined” or something when we’ll try to call it so we call handle this state :pray:

@Giovanni_Segar What’s your workaround? I’m having the same issue.

@MutedJam I also believe this should be the case.

My problem:
{{ $node["nodeName"] }} returns [no data, execute "nodeName" node first]

{{ typeof $node["nodeName"] }} returns object

{{ $node["nodeName"].json }} returns [no data, execute "nodeName" node first]

{{ 'json' in $node["nodeName"] }} returns true

{{ typeof $node["nodeName"].json }} returns [no data, execute "nodeName" node first]

FUN FACT: {{ 'randomAnything' in $node["nodeName"] }} returns true

I’m confused :thinking: :exploding_head:

Workaround (or maybe the “correct” way to do it):

{{ $node["nodeName"].runIndex >= 0 ? $node["nodeName"].json : "" }}

I’m still confused :grinning: :thinking:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.