summaryrefslogtreecommitdiff
path: root/app/graphql/mutations
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/mutations')
-rw-r--r--app/graphql/mutations/award_emojis/base.rb6
-rw-r--r--app/graphql/mutations/base_mutation.rb1
-rw-r--r--app/graphql/mutations/boards/update.rb3
-rw-r--r--app/graphql/mutations/ci/ci_cd_settings_update.rb37
-rw-r--r--app/graphql/mutations/ci/job/base.rb3
-rw-r--r--app/graphql/mutations/ci/pipeline/base.rb3
-rw-r--r--app/graphql/mutations/ci/project_ci_cd_settings_update.rb43
-rw-r--r--app/graphql/mutations/ci/runner/delete.rb4
-rw-r--r--app/graphql/mutations/ci/runner/update.rb4
-rw-r--r--app/graphql/mutations/ci/runners_registration_token/reset.rb32
-rw-r--r--app/graphql/mutations/clusters/agent_tokens/create.rb3
-rw-r--r--app/graphql/mutations/clusters/agent_tokens/delete.rb35
-rw-r--r--app/graphql/mutations/clusters/agent_tokens/revoke.rb3
-rw-r--r--app/graphql/mutations/clusters/agents/delete.rb3
-rw-r--r--app/graphql/mutations/container_expiration_policies/update.rb2
-rw-r--r--app/graphql/mutations/container_repositories/destroy_base.rb3
-rw-r--r--app/graphql/mutations/customer_relations/contacts/base.rb25
-rw-r--r--app/graphql/mutations/customer_relations/contacts/create.rb16
-rw-r--r--app/graphql/mutations/customer_relations/contacts/update.rb16
-rw-r--r--app/graphql/mutations/customer_relations/organizations/update.rb4
-rw-r--r--app/graphql/mutations/design_management/move.rb3
-rw-r--r--app/graphql/mutations/discussions/toggle_resolve.rb3
-rw-r--r--app/graphql/mutations/environments/canary_ingress/update.rb9
-rw-r--r--app/graphql/mutations/incident_management/timeline_event/base.rb29
-rw-r--r--app/graphql/mutations/incident_management/timeline_event/create.rb37
-rw-r--r--app/graphql/mutations/incident_management/timeline_event/destroy.rb24
-rw-r--r--app/graphql/mutations/incident_management/timeline_event/promote_from_note.rb46
-rw-r--r--app/graphql/mutations/incident_management/timeline_event/update.rb33
-rw-r--r--app/graphql/mutations/issues/set_crm_contacts.rb2
-rw-r--r--app/graphql/mutations/merge_requests/remove_attention_request.rb40
-rw-r--r--app/graphql/mutations/merge_requests/request_attention.rb40
-rw-r--r--app/graphql/mutations/merge_requests/set_labels.rb3
-rw-r--r--app/graphql/mutations/merge_requests/toggle_attention_requested.rb2
-rw-r--r--app/graphql/mutations/metrics/dashboard/annotations/create.rb11
-rw-r--r--app/graphql/mutations/namespace/package_settings/update.rb2
-rw-r--r--app/graphql/mutations/notes/base.rb3
-rw-r--r--app/graphql/mutations/notes/create/base.rb3
-rw-r--r--app/graphql/mutations/notes/create/note.rb7
-rw-r--r--app/graphql/mutations/notes/reposition_image_diff_note.rb3
-rw-r--r--app/graphql/mutations/notes/update/image_diff_note.rb2
-rw-r--r--app/graphql/mutations/packages/destroy.rb3
-rw-r--r--app/graphql/mutations/packages/destroy_file.rb3
-rw-r--r--app/graphql/mutations/release_asset_links/delete.rb4
-rw-r--r--app/graphql/mutations/release_asset_links/update.rb4
-rw-r--r--app/graphql/mutations/saved_replies/base.rb6
-rw-r--r--app/graphql/mutations/timelogs/delete.rb33
-rw-r--r--app/graphql/mutations/todos/base.rb3
-rw-r--r--app/graphql/mutations/todos/create.rb3
-rw-r--r--app/graphql/mutations/todos/mark_all_done.rb2
-rw-r--r--app/graphql/mutations/todos/restore_many.rb3
-rw-r--r--app/graphql/mutations/user_preferences/update.rb2
-rw-r--r--app/graphql/mutations/work_items/create.rb3
-rw-r--r--app/graphql/mutations/work_items/create_from_task.rb2
-rw-r--r--app/graphql/mutations/work_items/delete.rb2
-rw-r--r--app/graphql/mutations/work_items/delete_task.rb69
-rw-r--r--app/graphql/mutations/work_items/update.rb2
56 files changed, 463 insertions, 229 deletions
diff --git a/app/graphql/mutations/award_emojis/base.rb b/app/graphql/mutations/award_emojis/base.rb
index ce73f2083f2..dc2d46269e6 100644
--- a/app/graphql/mutations/award_emojis/base.rb
+++ b/app/graphql/mutations/award_emojis/base.rb
@@ -26,12 +26,6 @@ module Mutations
private
- # TODO: remove this method when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- def find_object(id:)
- super(id: ::Types::GlobalIDType[::Awardable].coerce_isolated_input(id))
- end
-
def authorize!(object)
super
raise_resource_not_available_error!(NOT_EMOJI_AWARDABLE) unless object.emoji_awardable?
diff --git a/app/graphql/mutations/base_mutation.rb b/app/graphql/mutations/base_mutation.rb
index 5de042f78d6..d57a097a9e2 100644
--- a/app/graphql/mutations/base_mutation.rb
+++ b/app/graphql/mutations/base_mutation.rb
@@ -4,7 +4,6 @@ module Mutations
class BaseMutation < GraphQL::Schema::RelayClassicMutation
include Gitlab::Graphql::Authorize::AuthorizeResource
prepend Gitlab::Graphql::CopyFieldDescription
- prepend ::Gitlab::Graphql::GlobalIDCompatibility
ERROR_MESSAGE = 'You cannot perform write operations on a read-only instance'
diff --git a/app/graphql/mutations/boards/update.rb b/app/graphql/mutations/boards/update.rb
index 40ab5a5ba7d..7cfce9d2d91 100644
--- a/app/graphql/mutations/boards/update.rb
+++ b/app/graphql/mutations/boards/update.rb
@@ -33,9 +33,6 @@ module Mutations
private
def find_object(id:)
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = ::Types::GlobalIDType[::Board].coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
end
diff --git a/app/graphql/mutations/ci/ci_cd_settings_update.rb b/app/graphql/mutations/ci/ci_cd_settings_update.rb
index dec90ced962..98b8e9567e7 100644
--- a/app/graphql/mutations/ci/ci_cd_settings_update.rb
+++ b/app/graphql/mutations/ci/ci_cd_settings_update.rb
@@ -2,42 +2,9 @@
module Mutations
module Ci
- class CiCdSettingsUpdate < BaseMutation
+ # TODO: Remove in 16.0, see https://gitlab.com/gitlab-org/gitlab/-/merge_requests/87002
+ class CiCdSettingsUpdate < ProjectCiCdSettingsUpdate
graphql_name 'CiCdSettingsUpdate'
-
- include FindsProject
-
- authorize :admin_project
-
- argument :full_path, GraphQL::Types::ID,
- required: true,
- description: 'Full Path of the project the settings belong to.'
-
- argument :keep_latest_artifact, GraphQL::Types::Boolean,
- required: false,
- description: 'Indicates if the latest artifact should be kept for this project.'
-
- argument :job_token_scope_enabled, GraphQL::Types::Boolean,
- required: false,
- description: 'Indicates CI job tokens generated in this project have restricted access to resources.'
-
- field :ci_cd_settings,
- Types::Ci::CiCdSettingType,
- null: false,
- description: 'CI/CD settings after mutation.'
-
- def resolve(full_path:, **args)
- project = authorized_find!(full_path)
- settings = project.ci_cd_settings
- settings.update(args)
-
- {
- ci_cd_settings: settings,
- errors: errors_on_object(settings)
- }
- end
end
end
end
-
-Mutations::Ci::CiCdSettingsUpdate.prepend_mod_with('Mutations::Ci::CiCdSettingsUpdate')
diff --git a/app/graphql/mutations/ci/job/base.rb b/app/graphql/mutations/ci/job/base.rb
index a9fe26226d9..6ea8e25a58d 100644
--- a/app/graphql/mutations/ci/job/base.rb
+++ b/app/graphql/mutations/ci/job/base.rb
@@ -11,9 +11,6 @@ module Mutations
description: 'ID of the job to mutate.'
def find_object(id: )
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = JobID.coerce_isolated_input(id)
GlobalID::Locator.locate(id)
end
end
diff --git a/app/graphql/mutations/ci/pipeline/base.rb b/app/graphql/mutations/ci/pipeline/base.rb
index aed8035a52a..503cf6c005f 100644
--- a/app/graphql/mutations/ci/pipeline/base.rb
+++ b/app/graphql/mutations/ci/pipeline/base.rb
@@ -13,9 +13,6 @@ module Mutations
private
def find_object(id:)
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = PipelineID.coerce_isolated_input(id)
GlobalID::Locator.locate(id)
end
end
diff --git a/app/graphql/mutations/ci/project_ci_cd_settings_update.rb b/app/graphql/mutations/ci/project_ci_cd_settings_update.rb
new file mode 100644
index 00000000000..b0cffa2c088
--- /dev/null
+++ b/app/graphql/mutations/ci/project_ci_cd_settings_update.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Ci
+ class ProjectCiCdSettingsUpdate < BaseMutation
+ graphql_name 'ProjectCiCdSettingsUpdate'
+
+ include FindsProject
+
+ authorize :admin_project
+
+ argument :full_path, GraphQL::Types::ID,
+ required: true,
+ description: 'Full Path of the project the settings belong to.'
+
+ argument :keep_latest_artifact, GraphQL::Types::Boolean,
+ required: false,
+ description: 'Indicates if the latest artifact should be kept for this project.'
+
+ argument :job_token_scope_enabled, GraphQL::Types::Boolean,
+ required: false,
+ description: 'Indicates CI job tokens generated in this project have restricted access to resources.'
+
+ field :ci_cd_settings,
+ Types::Ci::CiCdSettingType,
+ null: false,
+ description: 'CI/CD settings after mutation.'
+
+ def resolve(full_path:, **args)
+ project = authorized_find!(full_path)
+ settings = project.ci_cd_settings
+ settings.update(args)
+
+ {
+ ci_cd_settings: settings,
+ errors: errors_on_object(settings)
+ }
+ end
+ end
+ end
+end
+
+Mutations::Ci::ProjectCiCdSettingsUpdate.prepend_mod_with('Mutations::Ci::ProjectCiCdSettingsUpdate')
diff --git a/app/graphql/mutations/ci/runner/delete.rb b/app/graphql/mutations/ci/runner/delete.rb
index 1713ec0bf6d..db68914a4eb 100644
--- a/app/graphql/mutations/ci/runner/delete.rb
+++ b/app/graphql/mutations/ci/runner/delete.rb
@@ -23,10 +23,6 @@ module Mutations
end
def find_object(id)
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = RunnerID.coerce_isolated_input(id)
-
GitlabSchema.find_by_gid(id)
end
end
diff --git a/app/graphql/mutations/ci/runner/update.rb b/app/graphql/mutations/ci/runner/update.rb
index 3432840f60f..faccd1273e5 100644
--- a/app/graphql/mutations/ci/runner/update.rb
+++ b/app/graphql/mutations/ci/runner/update.rb
@@ -61,10 +61,6 @@ module Mutations
end
def find_object(id)
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = RunnerID.coerce_isolated_input(id)
-
GitlabSchema.find_by_gid(id)
end
end
diff --git a/app/graphql/mutations/ci/runners_registration_token/reset.rb b/app/graphql/mutations/ci/runners_registration_token/reset.rb
index 29ef7aa2e81..8c49b682ab0 100644
--- a/app/graphql/mutations/ci/runners_registration_token/reset.rb
+++ b/app/graphql/mutations/ci/runners_registration_token/reset.rb
@@ -23,19 +23,24 @@ module Mutations
null: true,
description: 'Runner token after mutation.'
- def resolve(**args)
+ def resolve(type:, id: nil)
+ scope = authorized_find!(type: type, id: id)
+ new_token = reset_token(scope)
+
{
- token: reset_token(**args),
- errors: []
+ token: new_token,
+ errors: errors_on_object(scope)
}
end
private
- def find_object(type:, **args)
- id = args[:id]
-
+ def find_object(type:, id: nil)
case type
+ when 'instance_type'
+ raise Gitlab::Graphql::Errors::ArgumentError, "id must not be specified for '#{type}' scope" if id.present?
+
+ ApplicationSetting.current
when 'group_type'
GitlabSchema.object_from_id(id, expected_type: ::Group)
when 'project_type'
@@ -43,20 +48,7 @@ module Mutations
end
end
- def reset_token(type:, **args)
- id = args[:id]
- scope = nil
-
- case type
- when 'instance_type'
- raise Gitlab::Graphql::Errors::ArgumentError, "id must not be specified for '#{type}' scope" if id.present?
-
- scope = ApplicationSetting.current
- authorize!(scope)
- when 'group_type', 'project_type'
- scope = authorized_find!(type: type, id: id)
- end
-
+ def reset_token(scope)
::Ci::Runners::ResetRegistrationTokenService.new(scope, current_user).execute if scope
end
end
diff --git a/app/graphql/mutations/clusters/agent_tokens/create.rb b/app/graphql/mutations/clusters/agent_tokens/create.rb
index 07bf2536065..a99a54fa5ed 100644
--- a/app/graphql/mutations/clusters/agent_tokens/create.rb
+++ b/app/graphql/mutations/clusters/agent_tokens/create.rb
@@ -58,9 +58,6 @@ module Mutations
private
def find_object(id:)
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = ClusterAgentID.coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
end
diff --git a/app/graphql/mutations/clusters/agent_tokens/delete.rb b/app/graphql/mutations/clusters/agent_tokens/delete.rb
deleted file mode 100644
index 603b6b30910..00000000000
--- a/app/graphql/mutations/clusters/agent_tokens/delete.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-# frozen_string_literal: true
-
-module Mutations
- module Clusters
- module AgentTokens
- class Delete < BaseMutation
- graphql_name 'ClusterAgentTokenDelete'
-
- authorize :admin_cluster
-
- TokenID = ::Types::GlobalIDType[::Clusters::AgentToken]
-
- argument :id, TokenID,
- required: true,
- description: 'Global ID of the cluster agent token that will be deleted.'
-
- def resolve(id:)
- token = authorized_find!(id: id)
- token.destroy
-
- { errors: errors_on_object(token) }
- end
-
- private
-
- def find_object(id:)
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = TokenID.coerce_isolated_input(id)
- GitlabSchema.find_by_gid(id)
- end
- end
- end
- end
-end
diff --git a/app/graphql/mutations/clusters/agent_tokens/revoke.rb b/app/graphql/mutations/clusters/agent_tokens/revoke.rb
index ca570792296..974db976f1d 100644
--- a/app/graphql/mutations/clusters/agent_tokens/revoke.rb
+++ b/app/graphql/mutations/clusters/agent_tokens/revoke.rb
@@ -24,9 +24,6 @@ module Mutations
private
def find_object(id:)
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = TokenID.coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
end
diff --git a/app/graphql/mutations/clusters/agents/delete.rb b/app/graphql/mutations/clusters/agents/delete.rb
index 9ada1f31f60..fb482e02794 100644
--- a/app/graphql/mutations/clusters/agents/delete.rb
+++ b/app/graphql/mutations/clusters/agents/delete.rb
@@ -28,9 +28,6 @@ module Mutations
private
def find_object(id:)
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = AgentID.coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
end
diff --git a/app/graphql/mutations/container_expiration_policies/update.rb b/app/graphql/mutations/container_expiration_policies/update.rb
index 762058acf3d..c2208e469c5 100644
--- a/app/graphql/mutations/container_expiration_policies/update.rb
+++ b/app/graphql/mutations/container_expiration_policies/update.rb
@@ -7,7 +7,7 @@ module Mutations
include FindsProject
- authorize :destroy_container_image
+ authorize :admin_container_image
argument :project_path,
GraphQL::Types::ID,
diff --git a/app/graphql/mutations/container_repositories/destroy_base.rb b/app/graphql/mutations/container_repositories/destroy_base.rb
index ddaa6c52121..1c2c4d87a5f 100644
--- a/app/graphql/mutations/container_repositories/destroy_base.rb
+++ b/app/graphql/mutations/container_repositories/destroy_base.rb
@@ -8,9 +8,6 @@ module Mutations
private
def find_object(id:)
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = ::Types::GlobalIDType[::ContainerRepository].coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
end
diff --git a/app/graphql/mutations/customer_relations/contacts/base.rb b/app/graphql/mutations/customer_relations/contacts/base.rb
new file mode 100644
index 00000000000..5d49d48ebe2
--- /dev/null
+++ b/app/graphql/mutations/customer_relations/contacts/base.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+module Mutations
+ module CustomerRelations
+ module Contacts
+ class Base < BaseMutation
+ include ResolvesIds
+ include Gitlab::Graphql::Authorize::AuthorizeResource
+
+ field :contact,
+ Types::CustomerRelations::ContactType,
+ null: true,
+ description: 'Contact after the mutation.'
+
+ authorize :admin_crm_contact
+
+ def set_organization!(args)
+ return unless args[:organization_id]
+
+ args[:organization_id] = args[:organization_id].model_id
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/customer_relations/contacts/create.rb b/app/graphql/mutations/customer_relations/contacts/create.rb
index 96dc047c3db..5b4063fb89a 100644
--- a/app/graphql/mutations/customer_relations/contacts/create.rb
+++ b/app/graphql/mutations/customer_relations/contacts/create.rb
@@ -3,17 +3,11 @@
module Mutations
module CustomerRelations
module Contacts
- class Create < BaseMutation
+ class Create < Base
graphql_name 'CustomerRelationsContactCreate'
- include ResolvesIds
include Gitlab::Graphql::Authorize::AuthorizeResource
- field :contact,
- Types::CustomerRelations::ContactType,
- null: true,
- description: 'Contact after the mutation.'
-
argument :group_id, ::Types::GlobalIDType[::Group],
required: true,
description: 'Group for the contact.'
@@ -42,8 +36,6 @@ module Mutations
required: false,
description: 'Description of or notes for the contact.'
- authorize :admin_crm_contact
-
def resolve(args)
group = authorized_find!(id: args[:group_id])
@@ -55,12 +47,6 @@ module Mutations
def find_object(id:)
GitlabSchema.object_from_id(id, expected_type: ::Group)
end
-
- def set_organization!(args)
- return unless args[:organization_id]
-
- args[:organization_id] = resolve_ids(args[:organization_id], ::Types::GlobalIDType[::CustomerRelations::Organization])[0]
- end
end
end
end
diff --git a/app/graphql/mutations/customer_relations/contacts/update.rb b/app/graphql/mutations/customer_relations/contacts/update.rb
index a3abf37f21f..1fc4f655464 100644
--- a/app/graphql/mutations/customer_relations/contacts/update.rb
+++ b/app/graphql/mutations/customer_relations/contacts/update.rb
@@ -3,18 +3,9 @@
module Mutations
module CustomerRelations
module Contacts
- class Update < Mutations::BaseMutation
+ class Update < Base
graphql_name 'CustomerRelationsContactUpdate'
- include ResolvesIds
-
- authorize :admin_crm_contact
-
- field :contact,
- Types::CustomerRelations::ContactType,
- null: true,
- description: 'Contact after the mutation.'
-
argument :id, ::Types::GlobalIDType[::CustomerRelations::Contact],
required: true,
description: 'Global ID of the contact.'
@@ -43,6 +34,10 @@ module Mutations
required: false,
description: 'Description of or notes for the contact.'
+ argument :active, GraphQL::Types::Boolean,
+ required: false,
+ description: 'State of the contact.'
+
def resolve(args)
contact = ::Gitlab::Graphql::Lazy.force(GitlabSchema.object_from_id(args.delete(:id), expected_type: ::CustomerRelations::Contact))
raise_resource_not_available_error! unless contact
@@ -50,6 +45,7 @@ module Mutations
group = contact.group
authorize!(group)
+ set_organization!(args)
result = ::CustomerRelations::Contacts::UpdateService.new(group: group, current_user: current_user, params: args).execute(contact)
{ contact: result.payload, errors: result.errors }
end
diff --git a/app/graphql/mutations/customer_relations/organizations/update.rb b/app/graphql/mutations/customer_relations/organizations/update.rb
index 0c05541dbd7..b2153b0b102 100644
--- a/app/graphql/mutations/customer_relations/organizations/update.rb
+++ b/app/graphql/mutations/customer_relations/organizations/update.rb
@@ -34,6 +34,10 @@ module Mutations
required: false,
description: 'Description of or notes for the organization.'
+ argument :active, GraphQL::Types::Boolean,
+ required: false,
+ description: 'State of the organization.'
+
def resolve(args)
organization = ::Gitlab::Graphql::Lazy.force(GitlabSchema.object_from_id(args.delete(:id), expected_type: ::CustomerRelations::Organization))
raise_resource_not_available_error! unless organization
diff --git a/app/graphql/mutations/design_management/move.rb b/app/graphql/mutations/design_management/move.rb
index 1ca03f22880..b19d9b4ce61 100644
--- a/app/graphql/mutations/design_management/move.rb
+++ b/app/graphql/mutations/design_management/move.rb
@@ -35,9 +35,6 @@ module Mutations
end
def find_design(id)
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = DesignID.coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
diff --git a/app/graphql/mutations/discussions/toggle_resolve.rb b/app/graphql/mutations/discussions/toggle_resolve.rb
index 2005c9e54e0..fce6e4f416f 100644
--- a/app/graphql/mutations/discussions/toggle_resolve.rb
+++ b/app/graphql/mutations/discussions/toggle_resolve.rb
@@ -54,9 +54,6 @@ module Mutations
end
def find_object(id:)
- # TODO: remove explicit coercion once compatibility layer has been removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = Types::GlobalIDType[Discussion].coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
diff --git a/app/graphql/mutations/environments/canary_ingress/update.rb b/app/graphql/mutations/environments/canary_ingress/update.rb
index ce24b8842c6..1cddfdd815b 100644
--- a/app/graphql/mutations/environments/canary_ingress/update.rb
+++ b/app/graphql/mutations/environments/canary_ingress/update.rb
@@ -24,7 +24,7 @@ module Mutations
'https://gitlab.com/groups/gitlab-org/configure/-/epics/8'
def resolve(id:, **kwargs)
- return { errors: [REMOVAL_ERR_MSG] } if cert_based_clusters_ff_disabled?
+ return { errors: [REMOVAL_ERR_MSG] } unless certificate_based_clusters_enabled?
environment = authorized_find!(id: id)
@@ -36,15 +36,14 @@ module Mutations
end
def find_object(id:)
- # TODO: remove as part of https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = ::Types::GlobalIDType[::Environment].coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
private
- def cert_based_clusters_ff_disabled?
- Feature.disabled?(:certificate_based_clusters, default_enabled: :yaml, type: :ops)
+ def certificate_based_clusters_enabled?
+ instance_cluster = ::Clusters::Instance.new
+ instance_cluster.certificate_based_clusters_enabled?
end
end
end
diff --git a/app/graphql/mutations/incident_management/timeline_event/base.rb b/app/graphql/mutations/incident_management/timeline_event/base.rb
new file mode 100644
index 00000000000..742470b4831
--- /dev/null
+++ b/app/graphql/mutations/incident_management/timeline_event/base.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+module Mutations
+ module IncidentManagement
+ module TimelineEvent
+ class Base < BaseMutation
+ field :timeline_event,
+ ::Types::IncidentManagement::TimelineEventType,
+ null: true,
+ description: 'Timeline event.'
+
+ authorize :admin_incident_management_timeline_event
+
+ private
+
+ def response(result)
+ {
+ timeline_event: result.payload[:timeline_event],
+ errors: result.errors
+ }
+ end
+
+ def find_object(id:)
+ GitlabSchema.object_from_id(id, expected_type: ::IncidentManagement::TimelineEvent).sync
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/incident_management/timeline_event/create.rb b/app/graphql/mutations/incident_management/timeline_event/create.rb
new file mode 100644
index 00000000000..cbc708a2530
--- /dev/null
+++ b/app/graphql/mutations/incident_management/timeline_event/create.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+module Mutations
+ module IncidentManagement
+ module TimelineEvent
+ class Create < Base
+ graphql_name 'TimelineEventCreate'
+
+ argument :incident_id, Types::GlobalIDType[::Issue],
+ required: true,
+ description: 'Incident ID of the timeline event.'
+
+ argument :note, GraphQL::Types::String,
+ required: true,
+ description: 'Text note of the timeline event.'
+
+ argument :occurred_at, Types::TimeType,
+ required: true,
+ description: 'Timestamp of when the event occurred.'
+
+ def resolve(incident_id:, **args)
+ incident = authorized_find!(id: incident_id)
+
+ authorize!(incident)
+
+ response ::IncidentManagement::TimelineEvents::CreateService.new(incident, current_user, args).execute
+ end
+
+ private
+
+ def find_object(id:)
+ GitlabSchema.object_from_id(id, expected_type: ::Issue).sync
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/incident_management/timeline_event/destroy.rb b/app/graphql/mutations/incident_management/timeline_event/destroy.rb
new file mode 100644
index 00000000000..728a2e7c0d6
--- /dev/null
+++ b/app/graphql/mutations/incident_management/timeline_event/destroy.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+module Mutations
+ module IncidentManagement
+ module TimelineEvent
+ class Destroy < Base
+ graphql_name 'TimelineEventDestroy'
+
+ argument :id, Types::GlobalIDType[::IncidentManagement::TimelineEvent],
+ required: true,
+ description: 'Timeline event ID to remove.'
+
+ def resolve(id:)
+ timeline_event = authorized_find!(id: id)
+
+ response ::IncidentManagement::TimelineEvents::DestroyService.new(
+ timeline_event,
+ current_user
+ ).execute
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/incident_management/timeline_event/promote_from_note.rb b/app/graphql/mutations/incident_management/timeline_event/promote_from_note.rb
new file mode 100644
index 00000000000..73a20b8a380
--- /dev/null
+++ b/app/graphql/mutations/incident_management/timeline_event/promote_from_note.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+module Mutations
+ module IncidentManagement
+ module TimelineEvent
+ class PromoteFromNote < Base
+ graphql_name 'TimelineEventPromoteFromNote'
+
+ argument :note_id, Types::GlobalIDType[::Note],
+ required: true,
+ description: 'Note ID from which the timeline event promoted.'
+
+ def resolve(note_id:)
+ note = find_object(id: note_id)
+ incident = note&.noteable
+
+ authorize!(incident)
+
+ response ::IncidentManagement::TimelineEvents::CreateService.new(
+ incident,
+ current_user,
+ promoted_from_note: note,
+ note: note.note,
+ occurred_at: note.created_at
+ ).execute
+ end
+
+ private
+
+ def find_object(id:)
+ GitlabSchema.object_from_id(id, expected_type: ::Note).sync
+ end
+
+ def authorize!(object)
+ raise_noteable_not_incident! if object && !object.try(:incident?)
+
+ super
+ end
+
+ def raise_noteable_not_incident!
+ raise_resource_not_available_error! 'Note does not belong to an incident'
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/incident_management/timeline_event/update.rb b/app/graphql/mutations/incident_management/timeline_event/update.rb
new file mode 100644
index 00000000000..1f53bdc19cb
--- /dev/null
+++ b/app/graphql/mutations/incident_management/timeline_event/update.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+module Mutations
+ module IncidentManagement
+ module TimelineEvent
+ class Update < Base
+ graphql_name 'TimelineEventUpdate'
+
+ argument :id, ::Types::GlobalIDType[::IncidentManagement::TimelineEvent],
+ required: true,
+ description: 'ID of the timeline event to update.'
+
+ argument :note, GraphQL::Types::String,
+ required: false,
+ description: 'Text note of the timeline event.'
+
+ argument :occurred_at, Types::TimeType,
+ required: false,
+ description: 'Timestamp when the event occurred.'
+
+ def resolve(id:, **args)
+ timeline_event = authorized_find!(id: id)
+
+ response ::IncidentManagement::TimelineEvents::UpdateService.new(
+ timeline_event,
+ current_user,
+ args
+ ).execute
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/issues/set_crm_contacts.rb b/app/graphql/mutations/issues/set_crm_contacts.rb
index 62990fc67f1..4df65e4769c 100644
--- a/app/graphql/mutations/issues/set_crm_contacts.rb
+++ b/app/graphql/mutations/issues/set_crm_contacts.rb
@@ -48,7 +48,7 @@ module Mutations
private
def feature_enabled?(project)
- Feature.enabled?(:customer_relations, project.group, default_enabled: :yaml) && project.group&.crm_enabled?
+ Feature.enabled?(:customer_relations, project.group) && project.group&.crm_enabled?
end
end
end
diff --git a/app/graphql/mutations/merge_requests/remove_attention_request.rb b/app/graphql/mutations/merge_requests/remove_attention_request.rb
new file mode 100644
index 00000000000..3b12b09528b
--- /dev/null
+++ b/app/graphql/mutations/merge_requests/remove_attention_request.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+module Mutations
+ module MergeRequests
+ class RemoveAttentionRequest < Base
+ graphql_name 'MergeRequestRemoveAttentionRequest'
+
+ argument :user_id, ::Types::GlobalIDType[::User],
+ loads: Types::UserType,
+ required: true,
+ description: <<~DESC
+ User ID of the user for attention request removal.
+ DESC
+
+ def resolve(project_path:, iid:, user:)
+ raise Gitlab::Graphql::Errors::ResourceNotAvailable, 'Feature disabled' unless feature_enabled?
+
+ merge_request = authorized_find!(project_path: project_path, iid: iid)
+
+ result = ::MergeRequests::RemoveAttentionRequestedService.new(
+ project: merge_request.project,
+ current_user: current_user,
+ merge_request: merge_request,
+ user: user
+ ).execute
+
+ {
+ merge_request: merge_request,
+ errors: Array(result[:message])
+ }
+ end
+
+ private
+
+ def feature_enabled?
+ current_user&.mr_attention_requests_enabled?
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/merge_requests/request_attention.rb b/app/graphql/mutations/merge_requests/request_attention.rb
new file mode 100644
index 00000000000..5f5565285f6
--- /dev/null
+++ b/app/graphql/mutations/merge_requests/request_attention.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+module Mutations
+ module MergeRequests
+ class RequestAttention < Base
+ graphql_name 'MergeRequestRequestAttention'
+
+ argument :user_id, ::Types::GlobalIDType[::User],
+ loads: Types::UserType,
+ required: true,
+ description: <<~DESC
+ User ID of the user to request attention.
+ DESC
+
+ def resolve(project_path:, iid:, user:)
+ raise Gitlab::Graphql::Errors::ResourceNotAvailable, 'Feature disabled' unless feature_enabled?
+
+ merge_request = authorized_find!(project_path: project_path, iid: iid)
+
+ result = ::MergeRequests::RequestAttentionService.new(
+ project: merge_request.project,
+ current_user: current_user,
+ merge_request: merge_request,
+ user: user
+ ).execute
+
+ {
+ merge_request: merge_request,
+ errors: Array(result[:message])
+ }
+ end
+
+ private
+
+ def feature_enabled?
+ current_user&.mr_attention_requests_enabled?
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/merge_requests/set_labels.rb b/app/graphql/mutations/merge_requests/set_labels.rb
index 0b40d6c5c5e..f80fcd0f1ac 100644
--- a/app/graphql/mutations/merge_requests/set_labels.rb
+++ b/app/graphql/mutations/merge_requests/set_labels.rb
@@ -23,9 +23,6 @@ module Mutations
merge_request = authorized_find!(project_path: project_path, iid: iid)
project = merge_request.project
- # TODO: remove this line when the compatibility layer is removed:
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- label_ids = label_ids.map { |id| ::Types::GlobalIDType[::Label].coerce_isolated_input(id) }
# MergeRequests::UpdateService expects integers
label_ids = label_ids.compact.map(&:model_id)
diff --git a/app/graphql/mutations/merge_requests/toggle_attention_requested.rb b/app/graphql/mutations/merge_requests/toggle_attention_requested.rb
index f316f23fb85..8913ca48531 100644
--- a/app/graphql/mutations/merge_requests/toggle_attention_requested.rb
+++ b/app/graphql/mutations/merge_requests/toggle_attention_requested.rb
@@ -13,6 +13,8 @@ module Mutations
DESC
def resolve(project_path:, iid:, user:)
+ raise Gitlab::Graphql::Errors::ResourceNotAvailable, 'Feature disabled' unless current_user&.mr_attention_requests_enabled?
+
merge_request = authorized_find!(project_path: project_path, iid: iid)
result = ::MergeRequests::ToggleAttentionRequestedService.new(project: merge_request.project, current_user: current_user, merge_request: merge_request, user: user).execute
diff --git a/app/graphql/mutations/metrics/dashboard/annotations/create.rb b/app/graphql/mutations/metrics/dashboard/annotations/create.rb
index 2eb48c9029d..2e7c0c5a2f9 100644
--- a/app/graphql/mutations/metrics/dashboard/annotations/create.rb
+++ b/app/graphql/mutations/metrics/dashboard/annotations/create.rb
@@ -96,16 +96,7 @@ module Mutations
end
def annotation_source(args)
- # TODO: remove these lines when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- annotation_source_id = if args[:cluster_id]
- ::Types::GlobalIDType[::Clusters::Cluster].coerce_isolated_input(args[:cluster_id])
- else
- ::Types::GlobalIDType[::Environment].coerce_isolated_input(args[:environment_id])
- end
-
- # TODO: uncomment following line once lines above are removed
- # annotation_source_id = args[:cluster_id] || args[:environment_id]
+ annotation_source_id = args[:cluster_id] || args[:environment_id]
authorized_find!(id: annotation_source_id)
end
end
diff --git a/app/graphql/mutations/namespace/package_settings/update.rb b/app/graphql/mutations/namespace/package_settings/update.rb
index 934b75193d7..e499e646781 100644
--- a/app/graphql/mutations/namespace/package_settings/update.rb
+++ b/app/graphql/mutations/namespace/package_settings/update.rb
@@ -8,7 +8,7 @@ module Mutations
include Mutations::ResolvesNamespace
- authorize :create_package_settings
+ authorize :admin_package
argument :namespace_path,
GraphQL::Types::ID,
diff --git a/app/graphql/mutations/notes/base.rb b/app/graphql/mutations/notes/base.rb
index 65bb9e4644c..fb74805db17 100644
--- a/app/graphql/mutations/notes/base.rb
+++ b/app/graphql/mutations/notes/base.rb
@@ -17,9 +17,6 @@ module Mutations
private
def find_object(id:)
- # TODO: remove explicit coercion once compatibility layer has been removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = ::Types::GlobalIDType[::Note].coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
end
diff --git a/app/graphql/mutations/notes/create/base.rb b/app/graphql/mutations/notes/create/base.rb
index e13a51c6862..1b673204213 100644
--- a/app/graphql/mutations/notes/create/base.rb
+++ b/app/graphql/mutations/notes/create/base.rb
@@ -42,9 +42,6 @@ module Mutations
private
def find_object(id:)
- # TODO: remove explicit coercion once compatibility layer has been removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = ::Types::GlobalIDType[::Noteable].coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
diff --git a/app/graphql/mutations/notes/create/note.rb b/app/graphql/mutations/notes/create/note.rb
index 1cfc11c6b11..4d6f056de09 100644
--- a/app/graphql/mutations/notes/create/note.rb
+++ b/app/graphql/mutations/notes/create/note.rb
@@ -22,11 +22,8 @@ module Mutations
def create_note_params(noteable, args)
discussion_id = nil
- if args[:discussion_id]
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- discussion_gid = ::Types::GlobalIDType[::Discussion].coerce_isolated_input(args[:discussion_id])
- discussion = GitlabSchema.find_by_gid(discussion_gid)
+ if gid = args[:discussion_id]
+ discussion = GitlabSchema.find_by_gid(gid)
authorize_discussion!(discussion)
diff --git a/app/graphql/mutations/notes/reposition_image_diff_note.rb b/app/graphql/mutations/notes/reposition_image_diff_note.rb
index ec68f077c84..9c3377b1f96 100644
--- a/app/graphql/mutations/notes/reposition_image_diff_note.rb
+++ b/app/graphql/mutations/notes/reposition_image_diff_note.rb
@@ -26,6 +26,7 @@ module Mutations
def resolve(note:, position:)
authorize!(note)
+ position = position.to_h.compact
pre_update_checks!(note, position)
updated_note = ::Notes::UpdateService.new(
@@ -46,7 +47,7 @@ module Mutations
# just a `DiffNote` with a particular kind of `Gitlab::Diff::Position`.
# In addition to accepting a `DiffNote` Global ID we also need to
# perform this check.
- def pre_update_checks!(note, position)
+ def pre_update_checks!(note, _position)
unless note.position&.on_image?
raise Gitlab::Graphql::Errors::ResourceNotAvailable,
'Resource is not an ImageDiffNote'
diff --git a/app/graphql/mutations/notes/update/image_diff_note.rb b/app/graphql/mutations/notes/update/image_diff_note.rb
index 284c0f1bb20..8e4dbb06d46 100644
--- a/app/graphql/mutations/notes/update/image_diff_note.rb
+++ b/app/graphql/mutations/notes/update/image_diff_note.rb
@@ -54,7 +54,7 @@ module Mutations
original_position = note.position.to_h
- Gitlab::Diff::Position.new(original_position.merge(args[:position]))
+ Gitlab::Diff::Position.new(original_position.merge(args[:position].to_h))
end
end
end
diff --git a/app/graphql/mutations/packages/destroy.rb b/app/graphql/mutations/packages/destroy.rb
index 81fa53fc116..a398b1ff9dc 100644
--- a/app/graphql/mutations/packages/destroy.rb
+++ b/app/graphql/mutations/packages/destroy.rb
@@ -27,9 +27,6 @@ module Mutations
private
def find_object(id:)
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = ::Types::GlobalIDType[::Packages::Package].coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
end
diff --git a/app/graphql/mutations/packages/destroy_file.rb b/app/graphql/mutations/packages/destroy_file.rb
index 4aa33b3504c..f2a8f2b853a 100644
--- a/app/graphql/mutations/packages/destroy_file.rb
+++ b/app/graphql/mutations/packages/destroy_file.rb
@@ -25,9 +25,6 @@ module Mutations
private
def find_object(id:)
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = ::Types::GlobalIDType[::Packages::PackageFile].coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
end
diff --git a/app/graphql/mutations/release_asset_links/delete.rb b/app/graphql/mutations/release_asset_links/delete.rb
index d8f0946670b..91fa74859f6 100644
--- a/app/graphql/mutations/release_asset_links/delete.rb
+++ b/app/graphql/mutations/release_asset_links/delete.rb
@@ -29,10 +29,6 @@ module Mutations
end
def find_object(id)
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = ReleaseAssetLinkID.coerce_isolated_input(id)
-
GitlabSchema.find_by_gid(id)
end
end
diff --git a/app/graphql/mutations/release_asset_links/update.rb b/app/graphql/mutations/release_asset_links/update.rb
index 18d92cd82ae..f9368927371 100644
--- a/app/graphql/mutations/release_asset_links/update.rb
+++ b/app/graphql/mutations/release_asset_links/update.rb
@@ -54,10 +54,6 @@ module Mutations
end
def find_object(id)
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = ReleaseAssetLinkID.coerce_isolated_input(id)
-
GitlabSchema.find_by_gid(id)
end
end
diff --git a/app/graphql/mutations/saved_replies/base.rb b/app/graphql/mutations/saved_replies/base.rb
index 59871df687f..4923fcb7851 100644
--- a/app/graphql/mutations/saved_replies/base.rb
+++ b/app/graphql/mutations/saved_replies/base.rb
@@ -24,14 +24,10 @@ module Mutations
end
def feature_enabled?
- Feature.enabled?(:saved_replies, current_user, default_enabled: :yaml)
+ Feature.enabled?(:saved_replies, current_user)
end
def find_object(id)
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = ::Types::GlobalIDType[::Users::SavedReply].coerce_isolated_input(id)
-
GitlabSchema.find_by_gid(id)
end
end
diff --git a/app/graphql/mutations/timelogs/delete.rb b/app/graphql/mutations/timelogs/delete.rb
new file mode 100644
index 00000000000..8fd41c27b88
--- /dev/null
+++ b/app/graphql/mutations/timelogs/delete.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Timelogs
+ class Delete < Mutations::BaseMutation
+ graphql_name 'TimelogDelete'
+
+ field :timelog,
+ Types::TimelogType,
+ null: true,
+ description: 'Deleted timelog.'
+
+ argument :id,
+ ::Types::GlobalIDType[::Timelog],
+ required: true,
+ description: 'Global ID of the timelog.'
+
+ authorize :admin_timelog
+
+ def resolve(id:)
+ timelog = authorized_find!(id: id)
+ result = ::Timelogs::DeleteService.new(timelog, current_user).execute
+
+ # Return the result payload, not the loaded timelog, so that it returns null in case of unauthorized access
+ { timelog: result.payload, errors: result.errors }
+ end
+
+ def find_object(id:)
+ GitlabSchema.find_by_gid(id)
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/todos/base.rb b/app/graphql/mutations/todos/base.rb
index 4dab3bbc3f4..9a94c5d1e6d 100644
--- a/app/graphql/mutations/todos/base.rb
+++ b/app/graphql/mutations/todos/base.rb
@@ -6,9 +6,6 @@ module Mutations
private
def find_object(id:)
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = ::Types::GlobalIDType[::Todo].coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
end
diff --git a/app/graphql/mutations/todos/create.rb b/app/graphql/mutations/todos/create.rb
index ccc3d0b61e4..489d2f490ff 100644
--- a/app/graphql/mutations/todos/create.rb
+++ b/app/graphql/mutations/todos/create.rb
@@ -17,8 +17,7 @@ module Mutations
description: 'To-do item created.'
def resolve(target_id:)
- id = ::Types::GlobalIDType[Todoable].coerce_isolated_input(target_id)
- target = authorized_find!(id)
+ target = authorized_find!(target_id)
todo = TodoService.new.mark_todo(target, current_user)&.first
errors = errors_on_object(todo) if todo
diff --git a/app/graphql/mutations/todos/mark_all_done.rb b/app/graphql/mutations/todos/mark_all_done.rb
index 67a822c1067..fe4023515a4 100644
--- a/app/graphql/mutations/todos/mark_all_done.rb
+++ b/app/graphql/mutations/todos/mark_all_done.rb
@@ -39,7 +39,7 @@ module Mutations
if args[:target_id].present?
target = Gitlab::Graphql::Lazy.force(
- GitlabSchema.find_by_gid(TodoableID.coerce_isolated_input(args[:target_id]))
+ GitlabSchema.find_by_gid(args[:target_id])
)
raise Gitlab::Graphql::Errors::ResourceNotAvailable, "Resource not available: #{args[:target_id]}" if target.nil?
diff --git a/app/graphql/mutations/todos/restore_many.rb b/app/graphql/mutations/todos/restore_many.rb
index 3453645000b..fe0ad6df65b 100644
--- a/app/graphql/mutations/todos/restore_many.rb
+++ b/app/graphql/mutations/todos/restore_many.rb
@@ -33,9 +33,6 @@ module Mutations
def model_ids_of(ids)
ids.map do |gid|
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- gid = ::Types::GlobalIDType[::Todo].coerce_isolated_input(gid)
gid.model_id.to_i
end.compact
end
diff --git a/app/graphql/mutations/user_preferences/update.rb b/app/graphql/mutations/user_preferences/update.rb
index eface536a87..b71c952b0f2 100644
--- a/app/graphql/mutations/user_preferences/update.rb
+++ b/app/graphql/mutations/user_preferences/update.rb
@@ -38,7 +38,7 @@ module Mutations
def disabled_sort_value?(args)
return false unless [:escalation_status_asc, :escalation_status_desc].include?(args[:issues_sort])
- Feature.disabled?(:incident_escalations, default_enabled: :yaml)
+ Feature.disabled?(:incident_escalations)
end
end
end
diff --git a/app/graphql/mutations/work_items/create.rb b/app/graphql/mutations/work_items/create.rb
index c29dbb899b5..2e136d409ab 100644
--- a/app/graphql/mutations/work_items/create.rb
+++ b/app/graphql/mutations/work_items/create.rb
@@ -53,9 +53,6 @@ module Mutations
private
def global_id_compatibility_params(params)
- # TODO: remove this line when the compatibility layer is removed
- # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- params[:work_item_type_id] = ::Types::GlobalIDType[::WorkItems::Type].coerce_isolated_input(params[:work_item_type_id]) if params[:work_item_type_id]
params[:work_item_type_id] = params[:work_item_type_id]&.model_id
params
diff --git a/app/graphql/mutations/work_items/create_from_task.rb b/app/graphql/mutations/work_items/create_from_task.rb
index 278c1bc65a9..4da709401a6 100644
--- a/app/graphql/mutations/work_items/create_from_task.rb
+++ b/app/graphql/mutations/work_items/create_from_task.rb
@@ -55,8 +55,6 @@ module Mutations
private
def find_object(id:)
- # TODO: Remove coercion when working on https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = ::Types::GlobalIDType[::WorkItem].coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
end
diff --git a/app/graphql/mutations/work_items/delete.rb b/app/graphql/mutations/work_items/delete.rb
index 3d72ebbd95d..1830ab5443c 100644
--- a/app/graphql/mutations/work_items/delete.rb
+++ b/app/graphql/mutations/work_items/delete.rb
@@ -38,8 +38,6 @@ module Mutations
private
def find_object(id:)
- # TODO: Remove coercion when working on https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = ::Types::GlobalIDType[::WorkItem].coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
end
diff --git a/app/graphql/mutations/work_items/delete_task.rb b/app/graphql/mutations/work_items/delete_task.rb
new file mode 100644
index 00000000000..87620a28fa1
--- /dev/null
+++ b/app/graphql/mutations/work_items/delete_task.rb
@@ -0,0 +1,69 @@
+# frozen_string_literal: true
+
+module Mutations
+ module WorkItems
+ class DeleteTask < BaseMutation
+ graphql_name 'WorkItemDeleteTask'
+
+ description "Deletes a task in a work item's description." \
+ ' Available only when feature flag `work_items` is enabled. This feature is experimental and' \
+ ' is subject to change without notice.'
+
+ authorize :update_work_item
+
+ argument :id, ::Types::GlobalIDType[::WorkItem],
+ required: true,
+ description: 'Global ID of the work item.'
+ argument :lock_version, GraphQL::Types::Int,
+ required: true,
+ description: 'Current lock version of the work item containing the task in the description.'
+ argument :task_data, ::Types::WorkItems::DeletedTaskInputType,
+ required: true,
+ description: 'Arguments necessary to delete a task from a work item\'s description.',
+ prepare: ->(attributes, _ctx) { attributes.to_h }
+
+ field :work_item, Types::WorkItemType,
+ null: true,
+ description: 'Updated work item.'
+
+ def resolve(id:, lock_version:, task_data:)
+ work_item = authorized_find!(id: id)
+ task_data[:task] = authorized_find_task!(task_data[:id])
+
+ unless work_item.project.work_items_feature_flag_enabled?
+ return { errors: ['`work_items` feature flag disabled for this project'] }
+ end
+
+ result = ::WorkItems::DeleteTaskService.new(
+ work_item: work_item,
+ current_user: current_user,
+ lock_version: lock_version,
+ task_params: task_data
+ ).execute
+
+ response = { errors: result.errors }
+ response[:work_item] = work_item if result.success?
+
+ response
+ end
+
+ private
+
+ def authorized_find_task!(task_id)
+ task = ::Gitlab::Graphql::Lazy.force(GitlabSchema.find_by_gid(task_id))
+
+ if current_user.can?(:delete_work_item, task)
+ task
+ else
+ # Fail early if user cannot delete task
+ raise_resource_not_available_error!
+ end
+ end
+
+ # method used by `authorized_find!(id: id)`
+ def find_object(id:)
+ GitlabSchema.find_by_gid(id)
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/work_items/update.rb b/app/graphql/mutations/work_items/update.rb
index 091237d6fa0..20319301482 100644
--- a/app/graphql/mutations/work_items/update.rb
+++ b/app/graphql/mutations/work_items/update.rb
@@ -52,8 +52,6 @@ module Mutations
private
def find_object(id:)
- # TODO: Remove coercion when working on https://gitlab.com/gitlab-org/gitlab/-/issues/257883
- id = ::Types::GlobalIDType[::WorkItem].coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
end