debian-mirror-gitlab/app/graphql/mutations/snippets/destroy.rb
2021-02-22 17:27:13 +05:30

32 lines
673 B
Ruby

# frozen_string_literal: true
module Mutations
module Snippets
class Destroy < Base
graphql_name 'DestroySnippet'
ERROR_MSG = 'Error deleting the snippet'
argument :id, ::Types::GlobalIDType[::Snippet],
required: true,
description: 'The global ID of the snippet to destroy'
def resolve(id:)
snippet = authorized_find!(id: id)
response = ::Snippets::DestroyService.new(current_user, snippet).execute
errors = response.success? ? [] : [ERROR_MSG]
{
errors: errors
}
end
private
def ability_name
"admin"
end
end
end
end