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

destroy.rb « custom_emoji « mutations « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 863b8152cc7f35055aff3f10ea6dc0e6e9d01244 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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:)
        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