support sub flows#980
Conversation
GitLab Pipeline ActionGeneral informationLink to pipeline: https://gitlab.com/code0-tech/development/sagittarius/-/pipelines/2544402924 Status: Failed Job summariesrspec: [cloud]Coverage report available at https://code0-tech.gitlab.io/-/development/sagittarius/-/jobs/14491577593/artifacts/tmp/coverage/index.html rspec: [ee]Coverage report available at https://code0-tech.gitlab.io/-/development/sagittarius/-/jobs/14491577592/artifacts/tmp/coverage/index.html rspec: [ce]Coverage report available at https://code0-tech.gitlab.io/-/development/sagittarius/-/jobs/14491577591/artifacts/tmp/coverage/index.html docs:previewDocumentation preview available at https://code0-tech.gitlab.io/-/development/telescopium/-/jobs/14491613946/artifacts/out/index.html rubocop841 files inspected, no offenses detected |
There was a problem hiding this comment.
Pull request overview
This PR replaces the old “function value” (NodeFunctionIdWrapper / node_functions.value_of_node_parameter) mechanism with a first-class SubFlow model that can be used as a node-parameter value, and wires it through GraphQL, persistence, and gRPC serialization. It also adds an optional cast field to flow settings and node parameters.
Changes:
- Introduces
SubFlow+SubFlowSettingmodels, tables, factories, and specs; updatesNodeParameterto usesub_flowinstead offunction_value. - Updates Flow create/update GraphQL inputs and response unions to accept/return
subFlowvalues (and removesNodeFunctionIdWrapper). - Adds
casttoflow_settingsandnode_parameters(GraphQL + persistence + gRPC), plus docs updates.
Reviewed changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/requests/graphql/mutation/namespace/projects/flows/update_mutation_spec.rb | Updates mutation spec to send/expect subFlow parameter values |
| spec/requests/graphql/mutation/namespace/projects/flows/create_mutation_spec.rb | Updates mutation spec to send/expect subFlow parameter values |
| spec/models/sub_flow_spec.rb | New model spec for SubFlow associations/validation |
| spec/models/sub_flow_setting_spec.rb | New model spec for SubFlowSetting associations/validation |
| spec/models/node_parameter_spec.rb | Replaces function_value expectations with sub_flow |
| spec/models/node_function_spec.rb | Removes value_of_node_parameter association expectations |
| spec/factories/sub_flows.rb | Adds factory for SubFlow |
| spec/factories/sub_flow_settings.rb | Adds factory for SubFlowSetting |
| spec/factories/node_parameters.rb | Removes function_value factory attribute |
| spec/factories/node_functions.rb | Removes value_of_node_parameter factory attribute |
| docs/graphql/union/nodeparametervalue.md | Documents FlowSubFlow as a possible union type |
| docs/graphql/object/nodeparameter.md | Documents new cast field on NodeParameter |
| docs/graphql/object/nodefunctionidwrapper.md | Removes docs for deprecated NodeFunctionIdWrapper |
| docs/graphql/object/flowsubflowsetting.md | Adds docs for FlowSubFlowSetting |
| docs/graphql/object/flowsubflow.md | Adds docs for FlowSubFlow |
| docs/graphql/object/flowsetting.md | Documents new cast field on FlowSetting |
| docs/graphql/input_object/nodeparametervalueinput.md | Replaces nodeFunctionId with subFlow input |
| docs/graphql/input_object/nodeparameterinput.md | Documents new cast input |
| docs/graphql/input_object/flowsubflowsettinginput.md | Adds docs for FlowSubFlowSettingInput |
| docs/graphql/input_object/flowsubflowinput.md | Adds docs for FlowSubFlowInput |
| docs/graphql/input_object/flowsettinginput.md | Documents new cast input on FlowSettingInput |
| docs/graphql/enum/errorcodeenum.md | Removes FUNCTION_VALUE_NOT_FOUND from documented error codes |
| db/structure.sql | Reflects schema changes: new tables + cast columns + removed FK/index |
| db/schema_migrations/20260520120000 | Adds checksum entry for the new migration |
| db/migrate/20260520120000_add_tucana_shared_flow_sub_flows.rb | Adds cast columns, creates sub_flow tables, removes old reference |
| app/services/namespaces/projects/flows/update_service.rb | Implements cast handling and subFlow update/clear logic |
| app/services/error_code.rb | Removes obsolete function_value_not_found error code |
| app/models/sub_flow.rb | New SubFlow model with gRPC conversion + validation |
| app/models/sub_flow_setting.rb | New SubFlowSetting model with gRPC conversion |
| app/models/node_parameter.rb | Switches from function_value to sub_flow; adds cast to gRPC |
| app/models/node_function.rb | Removes value_of_node_parameter association |
| app/models/flow_setting.rb | Adds cast to gRPC serialization |
| app/graphql/types/node_parameter_value_type.rb | Updates union to include FlowSubFlow and resolve SubFlow |
| app/graphql/types/node_parameter_type.rb | Adds cast field; returns sub_flow as the parameter value |
| app/graphql/types/node_function_id_wrapper_type.rb | Removes deprecated GraphQL type |
| app/graphql/types/input/node_parameter_value_input_type.rb | Replaces nodeFunctionId with subFlow; updates one-of validation |
| app/graphql/types/input/node_parameter_input_type.rb | Adds cast input |
| app/graphql/types/input/flow_sub_flow_setting_input_type.rb | Adds input type for sub-flow settings |
| app/graphql/types/input/flow_sub_flow_input_type.rb | Adds input type for sub-flow values |
| app/graphql/types/input/flow_setting_input_type.rb | Adds cast input for flow settings |
| app/graphql/types/flow_sub_flow_type.rb | Adds GraphQL object type for FlowSubFlow |
| app/graphql/types/flow_sub_flow_setting_type.rb | Adds GraphQL object type for FlowSubFlowSetting |
| app/graphql/types/flow_setting_type.rb | Adds cast field to FlowSetting GraphQL type |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def update_settings(t) | ||
| db_settings = flow.flow_settings.first(flow_input.settings.length) | ||
| flow_type_settings = flow.flow_type.flow_type_settings | ||
|
|
||
| flow_input.settings.each_with_index do |setting, index| | ||
| db_settings[index] ||= flow.flow_settings.build | ||
| db_settings[index].flow_setting_id = flow_type_settings[index]&.identifier | ||
| db_settings[index].object = setting.value | ||
| db_settings[index].cast = optional_input(setting, :cast) |
| flow_input.nodes.each do |node_input| | ||
| current_node = all_nodes[node_index] || NodeFunction.new(flow: flow) | ||
|
|
||
| update_node(t, current_node, node_input) | ||
| unless current_node.save | ||
| t.rollback_and_return! ServiceResponse.error( | ||
| message: 'Invalid node', | ||
| error_code: :invalid_node_function, | ||
| details: current_node.errors | ||
| ) | ||
| end | ||
|
|
| create_table :sub_flows do |t| | ||
| t.references :node_parameter, null: false, index: { unique: true }, | ||
| foreign_key: { to_table: :node_parameters, on_delete: :cascade } | ||
| t.references :starting_node, null: true, foreign_key: { to_table: :node_functions, on_delete: :restrict } |
| remove_reference :node_functions, :value_of_node_parameter, | ||
| null: true, | ||
| foreign_key: { to_table: :node_parameters, on_delete: :cascade } |
Resolves: #931