Nodes’ outputs are immutable, meaning that expressions like $('NodeName').all()|first() return a copy of data, so any changes thereto only available within the current run of a node that tries to mutate the data.
You also do not actually need Aggregate node as you are doing aggregation within the Code node. The Code node output doesn’t account for its previous run output.
Could you share the output of Fetch Contacts node (any run of it). Preferably as pinned data in the node.
Upd: previous version most likely has put the workflow into infinite loop. The order of inputs to Merge matters. My apologies.
A bit of a blind shot but try this:
We need:
a NoOp node just as a loop re-entry point and a bypass
Merge to have both previous iteration data and new data from Fetch Contacts paired together
Code node just appends new data to rows (well, along with copying previous content of rows whatever it is) and bypasses nextPageToken. Note the Code node mode is set to Once for each item. There will be only item in the output from Merge but this makes the code cleaner with no need to decompose and traverse $input.all.
Please test and lmk if it worked. And if it does, please mark this post as a Solution.
I am using the Monday API, which uses graphql queries and returns a cursor token, which then have to provided in the next query.
The loop solution works for 7-8k values, but after then my smaller self hostes setup crashes because of the data duplications.
I have not figured out how to implement http module pagination with cursor tokens…