summaryrefslogtreecommitdiff
path: root/app/graphql/mutations/snippets/destroy.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-13 09:08:01 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-13 09:08:01 +0000
commit17b91a3c6ab73fff087e91665e9afb8046cbf045 (patch)
tree04655a8630478d9846571875f69469f018d4bdcc /app/graphql/mutations/snippets/destroy.rb
parentb3db40398ce9ad335270617e834fde96d46f90ea (diff)
downloadgitlab-ce-17b91a3c6ab73fff087e91665e9afb8046cbf045.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql/mutations/snippets/destroy.rb')
-rw-r--r--app/graphql/mutations/snippets/destroy.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/app/graphql/mutations/snippets/destroy.rb b/app/graphql/mutations/snippets/destroy.rb
new file mode 100644
index 00000000000..115fcfd6488
--- /dev/null
+++ b/app/graphql/mutations/snippets/destroy.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Snippets
+ class Destroy < Base
+ graphql_name 'DestroySnippet'
+
+ ERROR_MSG = 'Error deleting the snippet'
+
+ argument :id,
+ GraphQL::ID_TYPE,
+ required: true,
+ description: 'The global id of the snippet to destroy'
+
+ def resolve(id:)
+ snippet = authorized_find!(id: id)
+
+ result = snippet.destroy
+ errors = result ? [] : [ERROR_MSG]
+
+ {
+ errors: errors
+ }
+ end
+
+ private
+
+ def ability_name
+ "admin"
+ end
+ end
+ end
+end