From c5a16e1fcccfa27ef5285537c83bd4a93ee8808d Mon Sep 17 00:00:00 2001 From: Niklas van Schrick Date: Sun, 8 Feb 2026 00:25:10 +0100 Subject: [PATCH] Add graphql input types for data type creation --- app/graphql/types/base_input_object.rb | 7 +++ app/graphql/types/data_type_type.rb | 2 +- .../input/data_type_identifier_input_type.rb | 17 ++++--- .../types/input/data_type_input_type.rb | 31 ++++++++++++ .../input/data_type_rule_config_input_type.rb | 48 +++++++++++++++++++ .../types/input/data_type_rule_input_type.rb | 17 +++++++ ..._type_rule_input_type_config_input_type.rb | 17 +++++++ app/graphql/types/input/flow_input_type.rb | 8 ++++ .../types/input/generic_mapper_input_type.rb | 6 ++- .../types/input/generic_type_input_type.rb | 8 ++-- .../types/input/translation_input_type.rb | 16 +++++++ .../input_object/datatypeidentifierinput.md | 13 +++++ docs/graphql/input_object/datatypeinput.md | 17 +++++++ .../input_object/datatyperuleconfiginput.md | 18 +++++++ .../graphql/input_object/datatyperuleinput.md | 12 +++++ .../datatyperuleinputtypeconfiginput.md | 12 +++++ docs/graphql/input_object/flowinput.md | 2 + .../input_object/genericmapperinput.md | 12 +++++ docs/graphql/input_object/generictypeinput.md | 12 +++++ docs/graphql/input_object/translationinput.md | 12 +++++ docs/graphql/object/datatype.md | 2 +- 21 files changed, 275 insertions(+), 14 deletions(-) create mode 100644 app/graphql/types/input/data_type_input_type.rb create mode 100644 app/graphql/types/input/data_type_rule_config_input_type.rb create mode 100644 app/graphql/types/input/data_type_rule_input_type.rb create mode 100644 app/graphql/types/input/data_type_rule_input_type_config_input_type.rb create mode 100644 app/graphql/types/input/translation_input_type.rb create mode 100644 docs/graphql/input_object/datatypeidentifierinput.md create mode 100644 docs/graphql/input_object/datatypeinput.md create mode 100644 docs/graphql/input_object/datatyperuleconfiginput.md create mode 100644 docs/graphql/input_object/datatyperuleinput.md create mode 100644 docs/graphql/input_object/datatyperuleinputtypeconfiginput.md create mode 100644 docs/graphql/input_object/genericmapperinput.md create mode 100644 docs/graphql/input_object/generictypeinput.md create mode 100644 docs/graphql/input_object/translationinput.md diff --git a/app/graphql/types/base_input_object.rb b/app/graphql/types/base_input_object.rb index 32c51240..b7261710 100644 --- a/app/graphql/types/base_input_object.rb +++ b/app/graphql/types/base_input_object.rb @@ -4,6 +4,13 @@ module Types class BaseInputObject < GraphQL::Schema::InputObject argument_class Types::BaseArgument + def self.inherited(subclass) + super + return if subclass.name.blank? + + subclass.graphql_name subclass.name.delete_prefix('Types::Input::').gsub('::', '').delete_suffix('Type') + end + def self.require_one_of(arguments) validates required: { one_of: arguments, message: "Only one of #{arguments.inspect} should be provided" } end diff --git a/app/graphql/types/data_type_type.rb b/app/graphql/types/data_type_type.rb index 4d59656a..82bcaee2 100644 --- a/app/graphql/types/data_type_type.rb +++ b/app/graphql/types/data_type_type.rb @@ -10,7 +10,7 @@ class DataTypeType < Types::BaseObject field :display_messages, [Types::TranslationType], null: true, description: 'Display message of the function' field :generic_keys, [String], null: true, description: 'Generic keys of the datatype' - field :identifier, String, null: false, description: 'The identifier scoped to the namespace' + field :identifier, String, null: false, description: 'The identifier of the datatype' field :name, [Types::TranslationType], method: :names, null: false, description: 'Names of the flow type setting' field :rules, Types::DataTypeRuleType.connection_type, null: false, diff --git a/app/graphql/types/input/data_type_identifier_input_type.rb b/app/graphql/types/input/data_type_identifier_input_type.rb index 337e2957..e1bdb08d 100644 --- a/app/graphql/types/input/data_type_identifier_input_type.rb +++ b/app/graphql/types/input/data_type_identifier_input_type.rb @@ -3,14 +3,17 @@ module Types module Input class DataTypeIdentifierInputType < Types::BaseInputObject - description 'Input type for data type identifier' + description 'Input for creation of a new DataTypeIdentifier' - argument :data_type_id, Types::GlobalIdType[::DataType], required: false, - description: 'Data type ID' - argument :generic_key, String, required: false, - description: 'Generic key value' - argument :generic_type, Types::Input::GenericTypeInputType, required: false, - description: 'Generic type information' + argument :data_type, Types::Input::DataTypeInputType, + required: false, + description: 'Data type' + argument :generic_key, String, + required: false, + description: 'Generic key value' + argument :generic_type, Types::Input::GenericTypeInputType, + required: false, + description: 'Generic type information' end end end diff --git a/app/graphql/types/input/data_type_input_type.rb b/app/graphql/types/input/data_type_input_type.rb new file mode 100644 index 00000000..d20e8797 --- /dev/null +++ b/app/graphql/types/input/data_type_input_type.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module Types + module Input + class DataTypeInputType < Types::BaseInputObject + description 'Input for creation of a data type' + + argument :aliases, [Types::Input::TranslationInputType], + required: false, + description: 'Name of the function' + argument :display_messages, [Types::Input::TranslationInputType], + required: false, + description: 'Display message of the function' + argument :generic_keys, [String], + required: false, + description: 'Generic keys of the datatype' + argument :identifier, String, + required: true, + description: 'The identifier of the datatype' + argument :name, [Types::Input::TranslationInputType], + required: true, + description: 'Names of the flow type setting' + argument :rules, [Types::Input::DataTypeRuleInputType], + required: true, + description: 'Rules of the datatype' + argument :variant, Types::DataTypeVariantEnum, + required: true, + description: 'The type of the datatype' + end + end +end diff --git a/app/graphql/types/input/data_type_rule_config_input_type.rb b/app/graphql/types/input/data_type_rule_config_input_type.rb new file mode 100644 index 00000000..0f8d49da --- /dev/null +++ b/app/graphql/types/input/data_type_rule_config_input_type.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +module Types + module Input + class DataTypeRuleConfigInputType < Types::BaseInputObject + description 'Input type for the config of a data type rule' + + # contains key + # contains type + # return type + # parent type + argument :data_type_identifier, Types::Input::DataTypeIdentifierInputType, + required: false, + description: 'Data type identifier' + + # contains key + argument :key, String, + required: false, + description: 'The key of the rule' + + # number range + argument :from, Integer, + required: false, + description: 'The minimum value of the range' + argument :steps, Integer, + required: false, + description: 'The step value for the range, if applicable' + argument :to, Integer, + required: false, + description: 'The maximum value of the range' + + # item of collection + argument :items, [GraphQL::Types::JSON], + required: false, + description: 'The items of the rule' + + # regex + argument :pattern, String, + required: false, + description: 'The regex pattern to match against the data type value.' + + # input types + argument :input_types, [Types::Input::DataTypeRuleInputTypeConfigInputType], + required: false, + description: 'The input types that can be used in this data type rule' + end + end +end diff --git a/app/graphql/types/input/data_type_rule_input_type.rb b/app/graphql/types/input/data_type_rule_input_type.rb new file mode 100644 index 00000000..c52fb197 --- /dev/null +++ b/app/graphql/types/input/data_type_rule_input_type.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Types + module Input + class DataTypeRuleInputType < Types::BaseInputObject + description 'Input for creation of a new DataTypeRule' + + argument :variant, Types::DataTypeRules::VariantEnum, + required: true, + description: 'The type of the rule' + + argument :config, Types::Input::DataTypeRuleConfigInputType, + required: true, + description: 'The config of the rule' + end + end +end diff --git a/app/graphql/types/input/data_type_rule_input_type_config_input_type.rb b/app/graphql/types/input/data_type_rule_input_type_config_input_type.rb new file mode 100644 index 00000000..1c8ab8f4 --- /dev/null +++ b/app/graphql/types/input/data_type_rule_input_type_config_input_type.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Types + module Input + class DataTypeRuleInputTypeConfigInputType < Types::BaseInputObject + description 'Input type for the config of a data type rule' + + argument :data_type_identifier, Types::Input::DataTypeIdentifierInputType, + required: true, + description: 'Data type identifier' + + argument :input_identifier, String, + required: true, + description: 'The input identifier that this configuration applies to' + end + end +end diff --git a/app/graphql/types/input/flow_input_type.rb b/app/graphql/types/input/flow_input_type.rb index 321f5cf9..4f2708b2 100644 --- a/app/graphql/types/input/flow_input_type.rb +++ b/app/graphql/types/input/flow_input_type.rb @@ -17,6 +17,14 @@ class FlowInputType < Types::BaseInputObject argument :type, Types::GlobalIdType[::FlowType], required: true, description: 'The identifier of the flow type' + + argument :input_type, Types::Input::DataTypeIdentifierInputType, + required: false, + description: 'The input data type' + + argument :return_type, Types::Input::DataTypeIdentifierInputType, + required: false, + description: 'The return data type' end end end diff --git a/app/graphql/types/input/generic_mapper_input_type.rb b/app/graphql/types/input/generic_mapper_input_type.rb index 09043fb0..cf5e40ea 100644 --- a/app/graphql/types/input/generic_mapper_input_type.rb +++ b/app/graphql/types/input/generic_mapper_input_type.rb @@ -6,10 +6,12 @@ class GenericMapperInputType < Types::BaseInputObject description 'Input type for generic mappers' argument :source_data_type_identifiers, [Types::Input::DataTypeIdentifierInputType], - required: true, description: 'The source data type identifier for the mapper' + required: true, + description: 'The source data type identifier for the mapper' argument :target, String, - required: true, description: 'The target data type identifier for the mapper' + required: true, + description: 'The target data type identifier for the mapper' end end end diff --git a/app/graphql/types/input/generic_type_input_type.rb b/app/graphql/types/input/generic_type_input_type.rb index c58d8255..2039f947 100644 --- a/app/graphql/types/input/generic_type_input_type.rb +++ b/app/graphql/types/input/generic_type_input_type.rb @@ -5,10 +5,12 @@ module Input class GenericTypeInputType < Types::BaseInputObject description 'Input type for generic type operations.' - argument :data_type_id, Types::GlobalIdType[::DataType], - required: true, description: 'The data type associated with this generic type.' + argument :data_type_id, Types::Input::DataTypeInputType, + required: true, + description: 'The data type associated with this generic type.' argument :generic_mappers, [Types::Input::GenericMapperInputType], - required: true, description: 'The mappers associated with this generic type.' + required: true, + description: 'The mappers associated with this generic type.' end end end diff --git a/app/graphql/types/input/translation_input_type.rb b/app/graphql/types/input/translation_input_type.rb new file mode 100644 index 00000000..96d8b2bf --- /dev/null +++ b/app/graphql/types/input/translation_input_type.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Types + module Input + class TranslationInputType < Types::BaseInputObject + description 'Represents a translation' + + argument :code, String, + required: true, + description: 'Code of the translation' + argument :content, String, + required: true, + description: 'Content of the translation' + end + end +end diff --git a/docs/graphql/input_object/datatypeidentifierinput.md b/docs/graphql/input_object/datatypeidentifierinput.md new file mode 100644 index 00000000..ef3e243d --- /dev/null +++ b/docs/graphql/input_object/datatypeidentifierinput.md @@ -0,0 +1,13 @@ +--- +title: DataTypeIdentifierInput +--- + +Input for creation of a new DataTypeIdentifier + +## Fields + +| Name | Type | Description | +|------|------|-------------| +| `dataType` | [`DataTypeInput`](../input_object/datatypeinput.md) | Data type | +| `genericKey` | [`String`](../scalar/string.md) | Generic key value | +| `genericType` | [`GenericTypeInput`](../input_object/generictypeinput.md) | Generic type information | diff --git a/docs/graphql/input_object/datatypeinput.md b/docs/graphql/input_object/datatypeinput.md new file mode 100644 index 00000000..a56bceb4 --- /dev/null +++ b/docs/graphql/input_object/datatypeinput.md @@ -0,0 +1,17 @@ +--- +title: DataTypeInput +--- + +Input for creation of a data type + +## Fields + +| Name | Type | Description | +|------|------|-------------| +| `aliases` | [`[TranslationInput!]`](../input_object/translationinput.md) | Name of the function | +| `displayMessages` | [`[TranslationInput!]`](../input_object/translationinput.md) | Display message of the function | +| `genericKeys` | [`[String!]`](../scalar/string.md) | Generic keys of the datatype | +| `identifier` | [`String!`](../scalar/string.md) | The identifier of the datatype | +| `name` | [`[TranslationInput!]!`](../input_object/translationinput.md) | Names of the flow type setting | +| `rules` | [`[DataTypeRuleInput!]!`](../input_object/datatyperuleinput.md) | Rules of the datatype | +| `variant` | [`DataTypeVariant!`](../enum/datatypevariant.md) | The type of the datatype | diff --git a/docs/graphql/input_object/datatyperuleconfiginput.md b/docs/graphql/input_object/datatyperuleconfiginput.md new file mode 100644 index 00000000..c882e1b5 --- /dev/null +++ b/docs/graphql/input_object/datatyperuleconfiginput.md @@ -0,0 +1,18 @@ +--- +title: DataTypeRuleConfigInput +--- + +Input type for the config of a data type rule + +## Fields + +| Name | Type | Description | +|------|------|-------------| +| `dataTypeIdentifier` | [`DataTypeIdentifierInput`](../input_object/datatypeidentifierinput.md) | Data type identifier | +| `from` | [`Int`](../scalar/int.md) | The minimum value of the range | +| `inputTypes` | [`[DataTypeRuleInputTypeConfigInput!]`](../input_object/datatyperuleinputtypeconfiginput.md) | The input types that can be used in this data type rule | +| `items` | [`[JSON!]`](../scalar/json.md) | The items of the rule | +| `key` | [`String`](../scalar/string.md) | The key of the rule | +| `pattern` | [`String`](../scalar/string.md) | The regex pattern to match against the data type value. | +| `steps` | [`Int`](../scalar/int.md) | The step value for the range, if applicable | +| `to` | [`Int`](../scalar/int.md) | The maximum value of the range | diff --git a/docs/graphql/input_object/datatyperuleinput.md b/docs/graphql/input_object/datatyperuleinput.md new file mode 100644 index 00000000..42ee3707 --- /dev/null +++ b/docs/graphql/input_object/datatyperuleinput.md @@ -0,0 +1,12 @@ +--- +title: DataTypeRuleInput +--- + +Input for creation of a new DataTypeRule + +## Fields + +| Name | Type | Description | +|------|------|-------------| +| `config` | [`DataTypeRuleConfigInput!`](../input_object/datatyperuleconfiginput.md) | The config of the rule | +| `variant` | [`DataTypeRulesVariant!`](../enum/datatyperulesvariant.md) | The type of the rule | diff --git a/docs/graphql/input_object/datatyperuleinputtypeconfiginput.md b/docs/graphql/input_object/datatyperuleinputtypeconfiginput.md new file mode 100644 index 00000000..f47d2e8d --- /dev/null +++ b/docs/graphql/input_object/datatyperuleinputtypeconfiginput.md @@ -0,0 +1,12 @@ +--- +title: DataTypeRuleInputTypeConfigInput +--- + +Input type for the config of a data type rule + +## Fields + +| Name | Type | Description | +|------|------|-------------| +| `dataTypeIdentifier` | [`DataTypeIdentifierInput!`](../input_object/datatypeidentifierinput.md) | Data type identifier | +| `inputIdentifier` | [`String!`](../scalar/string.md) | The input identifier that this configuration applies to | diff --git a/docs/graphql/input_object/flowinput.md b/docs/graphql/input_object/flowinput.md index c1774a17..09575eca 100644 --- a/docs/graphql/input_object/flowinput.md +++ b/docs/graphql/input_object/flowinput.md @@ -8,8 +8,10 @@ Input type for creating or updating a flow | Name | Type | Description | |------|------|-------------| +| `inputType` | [`DataTypeIdentifierInput`](../input_object/datatypeidentifierinput.md) | The input data type | | `name` | [`String!`](../scalar/string.md) | The name of the flow | | `nodes` | [`[NodeFunctionInput!]!`](../input_object/nodefunctioninput.md) | The node functions of the flow | +| `returnType` | [`DataTypeIdentifierInput`](../input_object/datatypeidentifierinput.md) | The return data type | | `settings` | [`[FlowSettingInput!]`](../input_object/flowsettinginput.md) | The settings of the flow | | `startingNodeId` | [`NodeFunctionID`](../scalar/nodefunctionid.md) | The starting node of the flow | | `type` | [`FlowTypeID!`](../scalar/flowtypeid.md) | The identifier of the flow type | diff --git a/docs/graphql/input_object/genericmapperinput.md b/docs/graphql/input_object/genericmapperinput.md new file mode 100644 index 00000000..003518c2 --- /dev/null +++ b/docs/graphql/input_object/genericmapperinput.md @@ -0,0 +1,12 @@ +--- +title: GenericMapperInput +--- + +Input type for generic mappers + +## Fields + +| Name | Type | Description | +|------|------|-------------| +| `sourceDataTypeIdentifiers` | [`[DataTypeIdentifierInput!]!`](../input_object/datatypeidentifierinput.md) | The source data type identifier for the mapper | +| `target` | [`String!`](../scalar/string.md) | The target data type identifier for the mapper | diff --git a/docs/graphql/input_object/generictypeinput.md b/docs/graphql/input_object/generictypeinput.md new file mode 100644 index 00000000..bd56bd3e --- /dev/null +++ b/docs/graphql/input_object/generictypeinput.md @@ -0,0 +1,12 @@ +--- +title: GenericTypeInput +--- + +Input type for generic type operations. + +## Fields + +| Name | Type | Description | +|------|------|-------------| +| `dataTypeId` | [`DataTypeInput!`](../input_object/datatypeinput.md) | The data type associated with this generic type. | +| `genericMappers` | [`[GenericMapperInput!]!`](../input_object/genericmapperinput.md) | The mappers associated with this generic type. | diff --git a/docs/graphql/input_object/translationinput.md b/docs/graphql/input_object/translationinput.md new file mode 100644 index 00000000..d5e567e6 --- /dev/null +++ b/docs/graphql/input_object/translationinput.md @@ -0,0 +1,12 @@ +--- +title: TranslationInput +--- + +Represents a translation + +## Fields + +| Name | Type | Description | +|------|------|-------------| +| `code` | [`String!`](../scalar/string.md) | Code of the translation | +| `content` | [`String!`](../scalar/string.md) | Content of the translation | diff --git a/docs/graphql/object/datatype.md b/docs/graphql/object/datatype.md index 70c0e27f..c5319459 100644 --- a/docs/graphql/object/datatype.md +++ b/docs/graphql/object/datatype.md @@ -14,7 +14,7 @@ Represents a DataType | `displayMessages` | [`[Translation!]`](../object/translation.md) | Display message of the function | | `genericKeys` | [`[String!]`](../scalar/string.md) | Generic keys of the datatype | | `id` | [`DataTypeID!`](../scalar/datatypeid.md) | Global ID of this DataType | -| `identifier` | [`String!`](../scalar/string.md) | The identifier scoped to the namespace | +| `identifier` | [`String!`](../scalar/string.md) | The identifier of the datatype | | `name` | [`[Translation!]!`](../object/translation.md) | Names of the flow type setting | | `rules` | [`DataTypeRuleConnection!`](../object/datatyperuleconnection.md) | Rules of the datatype | | `runtime` | [`Runtime`](../object/runtime.md) | The runtime where this datatype belongs to |