lightward / mechanic-tasks

Public task repository for Mechanic (https://mechanic.dev)
https://tasks.mechanic.dev/
MIT License
62 stars 33 forks source link

"Move out-of-stock products to the end of a collection" - inner loop clobbers `result` from outer loop #401

Closed isaacbowen closed 1 day ago

isaacbowen commented 1 day ago

There's a bit in this task where we're traversing two graphql pagination loops at once. Both loops are currently using the variable result to store the graphql query results, which breaks pagination for the outer loop.

https://github.com/lightward/mechanic-tasks/blob/b5bf9cb2f2e76c63831652cd60bdcc8ab8f10396/docs/move-out-of-stock-products-to-the-end-of-a-collection/script.liquid#L296-L328

tekhaus commented 1 day ago

Good catch, and a good reminder that there will likely be more loops in loops constructs in tasks as the 2K variants support approaches.