Skip to content

Commit

Permalink
Allow dynamic inputs for array map subgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
SorsOps committed May 16, 2024
1 parent 48ae1ac commit 1d19e79
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 1 addition & 3 deletions packages/graph-engine/src/nodes/array/arraySubgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ export default class ArraySubgraph<T, V> extends SubgraphNode {

if (!input) throw new Error("No input node found in subgraph");


input.annotations['ui.editable'] = false;
input.annotations[annotatedDynamicInputs] = true;

input.addInput("value", {
type: AnySchema,
Expand All @@ -45,7 +44,6 @@ export default class ArraySubgraph<T, V> extends SubgraphNode {
visible: false,
annotations: {
"ui.editable": false,
"ui.hidden": true,
[hideFromParentSubgraph]: true
}
});
Expand Down
7 changes: 3 additions & 4 deletions packages/graph-engine/src/nodes/generic/subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export default class SubgraphNode extends Node {

//Get the existing inputs
const existing = this.inputs;

//Iterate through the inputs of the input node in the inner graph
Object.entries(input.inputs).map(([key, value]) => {

Expand All @@ -61,16 +60,16 @@ export default class SubgraphNode extends Node {
noPropagate: true
});
} else {
//Note its possible that the input key still does not exist due to an annotation ,etc
//Update the value
this.inputs[key].setValue(value.value, {
this.inputs[key]?.setValue(value.value, {
noPropagate: true
});
}
//TODO handle deletions and mutations
});

console.log('updating value')
//Handle updates from the inner graph
this.setOutput("value", output.outputs.value.value, output.outputs.value.type);
});
}

Expand Down
3 changes: 3 additions & 0 deletions packages/graph-engine/src/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ export const canConvertSchemaTypes = (
if (src.type == "array" && target.$id == ANY_ARRAY) {
return true;
}
if (src.type == "array" && target.type == 'array') {
if (target.items?.$id === ANY) return true;
}

switch (src.$id) {
case COLOR:
Expand Down

0 comments on commit 1d19e79

Please sign in to comment.