I am just getting started with workflows and am having difficulty cycling through records. I am trying to use the variables {{first}}
and {{after}}
to cycle through the records.
fetchAllJobs
let allJobs = [];
let hasNextPage = true;
let afterCursor = null;
while (hasNextPage) {
// Call the GraphQL query function with the correct variables
const response = await getJobberJobs({ first: 10, after: afterCursor });
// Ensure that response structure matches the expected format
const jobs = response.data.jobs.nodes;
allJobs = allJobs.concat(jobs);
// Update pagination variables
hasNextPage = response.data.jobs.pageInfo.hasNextPage;
afterCursor = response.data.jobs.pageInfo.endCursor;
}
return allJobs;
Any ideas?