2021-11-11 11:23:49 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Mutations
|
|
|
|
module CustomEmoji
|
|
|
|
class Destroy < BaseMutation
|
|
|
|
graphql_name 'DestroyCustomEmoji'
|
|
|
|
|
|
|
|
authorize :delete_custom_emoji
|
|
|
|
|
|
|
|
field :custom_emoji,
|
|
|
|
Types::CustomEmojiType,
|
|
|
|
null: true,
|
|
|
|
description: 'Deleted custom emoji.'
|
|
|
|
|
|
|
|
argument :id, ::Types::GlobalIDType[::CustomEmoji],
|
|
|
|
required: true,
|
|
|
|
description: 'Global ID of the custom emoji to destroy.'
|
|
|
|
|
|
|
|
def resolve(id:)
|
2022-10-11 01:57:18 +05:30
|
|
|
if Feature.disabled?(:custom_emoji)
|
|
|
|
raise Gitlab::Graphql::Errors::ResourceNotAvailable, 'Custom emoji feature is disabled'
|
|
|
|
end
|
|
|
|
|
2021-11-11 11:23:49 +05:30
|
|
|
custom_emoji = authorized_find!(id: id)
|
|
|
|
|
|
|
|
custom_emoji.destroy!
|
|
|
|
|
|
|
|
{
|
|
|
|
custom_emoji: custom_emoji
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def find_object(id:)
|
|
|
|
GitlabSchema.object_from_id(id, expected_type: ::CustomEmoji)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|