From a95ebed114f9647909780ac5e06fda734b2320a2 Mon Sep 17 00:00:00 2001 From: Marc Saleiko Date: Tue, 2 Sep 2025 17:25:33 +0200 Subject: [PATCH] Adds status mapping to update lifecycle mutation Changelog: added --- doc/api/graphql/reference/_index.md | 12 ++++++++++++ .../mutations/work_items/lifecycles/update.rb | 4 ++++ .../work_items/status_mapping_input_type.rb | 19 +++++++++++++++++++ .../status_mapping_input_type_spec.rb | 13 +++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 ee/app/graphql/types/work_items/status_mapping_input_type.rb create mode 100644 ee/spec/graphql/types/work_items/status_mapping_input_type_spec.rb diff --git a/doc/api/graphql/reference/_index.md b/doc/api/graphql/reference/_index.md index 68328ff3ef89f8..6592c05b70b1ef 100644 --- a/doc/api/graphql/reference/_index.md +++ b/doc/api/graphql/reference/_index.md @@ -8517,6 +8517,7 @@ Input type: `LifecycleUpdateInput` | `id` | [`WorkItemsStatusesLifecycleID!`](#workitemsstatuseslifecycleid) | Global ID of the lifecycle to be updated. | | `name` | [`String`](#string) | Name of the lifecycle. | | `namespacePath` | [`ID!`](#id) | Namespace path where the lifecycle exists. | +| `statusMappings` | [`[StatusMappingInput!]`](#statusmappinginput) | Mappings for statuses being removed from the lifecycle. Maps old status to replacement status. | | `statuses` | [`[WorkItemStatusInput!]`](#workitemstatusinput) | Statuses of the lifecycle. Can be existing (with id) or new (without id). | #### Fields @@ -54124,6 +54125,17 @@ Represents an action to perform over a snippet file. | `filePath` | [`String!`](#string) | Path of the snippet file. | | `previousPath` | [`String`](#string) | Previous path of the snippet file. | +### `StatusMappingInput` + +Input for mapping a removed status to a replacement status. + +#### Arguments + +| Name | Type | Description | +| ---- | ---- | ----------- | +| `newStatusId` | [`GlobalID!`](#globalid) | Global ID of the replacement status. | +| `oldStatusId` | [`GlobalID!`](#globalid) | Global ID of the status being removed/replaced. | + ### `Timeframe` A time-frame defined as a closed inclusive range of two dates. diff --git a/ee/app/graphql/mutations/work_items/lifecycles/update.rb b/ee/app/graphql/mutations/work_items/lifecycles/update.rb index f5d0fc1f2e3109..e08a138f26d56e 100644 --- a/ee/app/graphql/mutations/work_items/lifecycles/update.rb +++ b/ee/app/graphql/mutations/work_items/lifecycles/update.rb @@ -42,6 +42,10 @@ class Update < BaseMutation required: false, description: 'Index of the default duplicated status in the statuses array.' + argument :status_mappings, [Types::WorkItems::StatusMappingInputType], + required: false, + description: 'Mappings for statuses being removed from the lifecycle. Maps old status to replacement status.' + def resolve(namespace_path:, **args) group = authorized_find!(namespace_path: namespace_path) diff --git a/ee/app/graphql/types/work_items/status_mapping_input_type.rb b/ee/app/graphql/types/work_items/status_mapping_input_type.rb new file mode 100644 index 00000000000000..5d649ff53786e0 --- /dev/null +++ b/ee/app/graphql/types/work_items/status_mapping_input_type.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Types + module WorkItems + class StatusMappingInputType < BaseInputObject + graphql_name 'StatusMappingInput' + + description 'Input for mapping a removed status to a replacement status' + + argument :old_status_id, ::Types::GlobalIDType, + required: true, + description: 'Global ID of the status being removed/replaced.' + + argument :new_status_id, ::Types::GlobalIDType, + required: true, + description: 'Global ID of the replacement status.' + end + end +end diff --git a/ee/spec/graphql/types/work_items/status_mapping_input_type_spec.rb b/ee/spec/graphql/types/work_items/status_mapping_input_type_spec.rb new file mode 100644 index 00000000000000..29f8b51bcdba2c --- /dev/null +++ b/ee/spec/graphql/types/work_items/status_mapping_input_type_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ::Types::WorkItems::StatusMappingInputType, feature_category: :team_planning do + let(:fields) do + %i[oldStatusId newStatusId] + end + + specify { expect(described_class).to have_graphql_fields(fields) } + + specify { expect(described_class.graphql_name).to eq('StatusMappingInput') } +end -- GitLab