Design reusable subgraphs

A reusable subgraph can run in two contexts: as a node inside a parent graph, and as a standalone graph. Design reusable subgraphs to work correctly in both so they are easy to develop, test, and reuse.

Guard inputs for standalone runs

When a parent graph provides inputs, the boundary nodes receive values through wires. When the graph runs standalone, no parent is present and those inputs receive null. A graph that doesn't guard against null inputs will fail or produce unexpected results when run standalone.

Use an Is Input Valid node to check each input. If the input is valid, pass it directly to your logic. If not, route a fallback constant instead. An If node selects between the two paths based on the Is Input Valid result.

Example

The Conditional Logic Error (copy) graph with the Input node on the left and the Output node on the right. Each input (A and B) from the Input node passes through an Is Input Valid node. The True path uses the live input value; the False path uses a fallback constant (A = 2 or B = 4). An If node selects between the two before the value reaches the main logic. The Output node collects the Result.

Copy of Base - Conditional Logic Error

In this example, inputs A and B are each checked with an Is Input Valid node. When the graph runs inside a parent graph, the parent supplies A and B through the boundary nodes. When it runs standalone, Is Input Valid returns false for each, and the If node routes to the fallback constants (A = 2 and B = 4). The downstream Compare (A > B) node receives a valid value in both cases.

Mark the exposed boundary ports as Optional so the graph can run without a parent supplying values. Set the fallback constants to values that make the graph meaningful when tested in isolation.

Keep reusable subgraphs focused

A reusable subgraph works best when it does one thing. A subgraph that performs a single, well-named operation is easier to understand, test, and reuse than one that bundles several unrelated steps.

If a reusable subgraph grows complex, consider breaking it into smaller ones. Each can be tested independently, and reusable subgraphs can themselves use other reusable subgraphs.

Name ports clearly

Port names on the boundary nodes become the input and output labels on the reusable subgraph node in the parent graph. Write port names from the parent's perspective: what does the parent pass in, and what does it receive back?

A port named Target Component tells the parent what to supply. A port named input0 doesn't. See Graph readability for broader naming guidance.

Test reusable subgraphs standalone

Run the reusable subgraph on its own before using it in a parent graph. Running it standalone confirms that your null guards and fallback constants produce the expected output. Fix any issues at this stage rather than after it's wired into a larger graph.