Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/mutations/environments/delete.rb')
-rw-r--r--app/graphql/mutations/environments/delete.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/graphql/mutations/environments/delete.rb b/app/graphql/mutations/environments/delete.rb
new file mode 100644
index 00000000000..5e3958b7936
--- /dev/null
+++ b/app/graphql/mutations/environments/delete.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Environments
+ class Delete < ::Mutations::BaseMutation
+ graphql_name 'EnvironmentDelete'
+ description 'Delete an environment.'
+
+ authorize :destroy_environment
+
+ argument :id,
+ ::Types::GlobalIDType[::Environment],
+ required: true,
+ description: 'Global ID of the environment to Delete.'
+
+ def resolve(id:, **kwargs)
+ environment = authorized_find!(id: id)
+
+ response = ::Environments::DestroyService.new(environment.project, current_user, kwargs).execute(environment)
+
+ if response.success?
+ { errors: [] }
+ else
+ { errors: response.errors }
+ end
+ end
+ end
+ end
+end