The FOREACH node iterates over an array and executes a subgraph for each item.Documentation Index
Fetch the complete documentation index at: https://hypha-docs.plinqx.app/llms.txt
Use this file to discover all available pages before exploring further.
Overview
FOREACH nodes enable:- Array Iteration: Loop over arrays of any size
- Item Access: Access current item and index in loop
- Subgraph Execution: Execute nodes for each iteration
- Concurrency Control: Limit parallel iterations
How It Works
Configuration
Collection Expression
Expression that resolves to an array:The collection expression must resolve to an array. Non-array values cause the node to fail.
Item Variables
Access current item and index in loop:- Item Variable: Default
item(configurable) - Index Variable: Default
index(configurable)
Concurrency
Control parallel iterations:- Max Concurrency: Maximum iterations running simultaneously
- Sequential: Set to 1 for sequential execution
- Parallel: Higher values for parallel execution
Loop Subgraph
Nodes inside the FOREACH loop:- Access Item: Use
{{item}}and{{index}}variables - Independent Execution: Each iteration runs independently
- Error Handling: Errors in one iteration don’t stop others (unless configured)
Output
FOREACH node provides output:Best Practices
Validate Collection
Ensure collection is an array before FOREACH
Set Concurrency
Configure appropriate concurrency limits
Handle Errors
Use TRY nodes inside loops for error handling
Limit Size
Consider array size - very large arrays may timeout
Use Cases
- Batch Processing: Process multiple records
- API Pagination: Iterate over paginated results
- Data Transformation: Transform each item in a list
- Parallel Operations: Execute operations for multiple items
Next Steps
PARALLEL Node
Execute multiple branches in parallel
Transform Node
Transform data in loops