debian-mirror-gitlab/app/graphql/mutations/snippets/destroy.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

33 lines
670 B
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
module Mutations
module Snippets
class Destroy < Base
graphql_name 'DestroySnippet'
ERROR_MSG = 'Error deleting the snippet'
2021-01-29 00:20:46 +05:30
argument :id, ::Types::GlobalIDType[::Snippet],
2020-01-01 13:55:28 +05:30
required: true,
2021-10-27 15:23:28 +05:30
description: 'Global ID of the snippet to destroy.'
2020-01-01 13:55:28 +05:30
def resolve(id:)
snippet = authorized_find!(id: id)
2020-03-13 15:44:24 +05:30
response = ::Snippets::DestroyService.new(current_user, snippet).execute
errors = response.success? ? [] : [ERROR_MSG]
2020-01-01 13:55:28 +05:30
{
errors: errors
}
end
private
def ability_name
"admin"
end
end
end
end