Skip to content

Commit 2b34b39

Browse files
authored
Merge pull request #980 from code0-tech/#931-support-sub-flows
support sub flows
2 parents 6ebc43b + b74a181 commit 2b34b39

43 files changed

Lines changed: 580 additions & 108 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/graphql/types/flow_setting_type.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ class FlowSettingType < Types::BaseObject
66

77
authorize :read_flow
88

9+
field :cast, String,
10+
null: true,
11+
description: 'The cast applied to the flow setting'
12+
913
field :flow_setting_identifier, String,
1014
null: false,
1115
method: :flow_setting_id,

app/graphql/types/input/flow_setting_input_type.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ module Input
55
class FlowSettingInputType < Types::BaseInputObject
66
description 'Input type for flow settings'
77

8+
argument :cast, String,
9+
required: false,
10+
description: 'The cast applied to the flow setting'
811
argument :value, GraphQL::Types::JSON, required: true,
912
description: 'The value of the flow setting'
1013
end

app/graphql/types/input/node_parameter_input_type.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ module Input
55
class NodeParameterInputType < Types::BaseInputObject
66
description 'Input type for Node parameter'
77

8+
argument :cast, String,
9+
required: false,
10+
description: 'The cast applied to the parameter'
811
argument :value, Types::Input::NodeParameterValueInputType, required: true,
912
description: 'The value of the parameter'
1013
end

app/graphql/types/input/node_parameter_value_input_type.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ class NodeParameterValueInputType < Types::BaseInputObject
77

88
argument :literal_value, GraphQL::Types::JSON,
99
required: false, description: 'The literal value of the parameter'
10-
argument :node_function_id, Types::GlobalIdType[::NodeFunction],
11-
required: false, description: 'The function value of the parameter as an id'
1210
argument :reference_value, Types::Input::ReferenceValueInputType,
1311
required: false, description: 'The reference value of the parameter'
12+
argument :sub_flow_value, Types::Input::SubFlowValueInputType,
13+
required: false, description: 'The sub-flow value of the parameter'
1414

15-
require_one_of %i[node_function_id literal_value reference_value]
15+
require_one_of %i[literal_value reference_value sub_flow_value]
1616
end
1717
end
1818
end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# frozen_string_literal: true
2+
3+
module Types
4+
module Input
5+
class SubFlowValueInputType < Types::BaseInputObject
6+
description 'Input type for sub-flow parameter values'
7+
8+
argument :function_identifier, String,
9+
required: false,
10+
description: 'The function identifier to execute'
11+
argument :settings, [Types::Input::SubFlowValueSettingInputType],
12+
required: false,
13+
description: 'The sub-flow settings'
14+
argument :signature, String,
15+
required: true,
16+
description: 'The sub-flow signature'
17+
argument :starting_node_id, Types::GlobalIdType[::NodeFunction],
18+
required: false,
19+
description: 'The starting node to execute'
20+
21+
require_one_of %i[starting_node_id function_identifier]
22+
end
23+
end
24+
end
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
module Types
4+
module Input
5+
class SubFlowValueSettingInputType < Types::BaseInputObject
6+
description 'Input type for sub-flow settings'
7+
8+
argument :default_value, GraphQL::Types::JSON,
9+
required: false,
10+
description: 'The default value of the sub-flow setting'
11+
argument :hidden, Boolean,
12+
required: false,
13+
description: 'Whether the sub-flow setting is hidden'
14+
argument :identifier, String,
15+
required: true,
16+
description: 'The identifier of the sub-flow setting'
17+
argument :optional, Boolean,
18+
required: false,
19+
description: 'Whether the sub-flow setting is optional'
20+
end
21+
end
22+
end

app/graphql/types/node_function_id_wrapper_type.rb

Lines changed: 0 additions & 9 deletions
This file was deleted.

app/graphql/types/node_parameter_type.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ class NodeParameterType < Types::BaseObject
66

77
authorize :read_flow
88

9+
field :cast, String, null: true, description: 'The cast applied to the parameter'
910
field :parameter_definition, Types::ParameterDefinitionType, null: false,
1011
description: 'The definition of the parameter'
1112
field :value, Types::NodeParameterValueType, null: true, description: 'The value of the parameter'
1213

1314
def value
1415
if object.reference_value.present?
1516
object.reference_value
16-
elsif object.function_value.present?
17-
object.function_value
17+
elsif object.sub_flow.present?
18+
object.sub_flow
1819
else
1920
object.literal_value
2021
end

app/graphql/types/node_parameter_value_type.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ module Types
44
class NodeParameterValueType < Types::BaseUnion
55
description 'Represents a parameter value for a node.'
66

7-
possible_types Types::LiteralValueType, Types::ReferenceValueType, Types::NodeFunctionIdWrapperType,
8-
description: 'The value can be a literal, a reference, or a node function id.'
7+
possible_types Types::SubFlowValueType, Types::LiteralValueType, Types::ReferenceValueType,
8+
description: 'The value can be a literal, a reference, or a sub-flow.'
99

1010
def self.resolve_type(object, _context)
1111
case object
1212
when ReferenceValue
1313
Types::ReferenceValueType
14-
when NodeFunction
15-
Types::NodeFunctionIdWrapperType
14+
when SubFlow
15+
Types::SubFlowValueType
1616
else
1717
Types::LiteralValueType
1818
end
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# frozen_string_literal: true
2+
3+
module Types
4+
class SubFlowValueSettingType < Types::BaseObject
5+
description 'Represents a sub-flow setting.'
6+
7+
field :default_value, GraphQL::Types::JSON,
8+
null: true,
9+
description: 'The default value of the sub-flow setting.'
10+
field :hidden, Boolean,
11+
null: true,
12+
description: 'Whether the sub-flow setting is hidden.'
13+
field :identifier, String,
14+
null: false,
15+
description: 'The identifier of the sub-flow setting.'
16+
field :optional, Boolean,
17+
null: true,
18+
description: 'Whether the sub-flow setting is optional.'
19+
end
20+
end

0 commit comments

Comments
 (0)