summaryrefslogtreecommitdiff
path: root/app/graphql/types/award_emojis/award_emoji_type.rb
blob: cd7a2f34ba67d80c499a4880bd6270edddf93157 (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
37
38
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true

module Types
  module AwardEmojis
    class AwardEmojiType < BaseObject
      graphql_name 'AwardEmoji'
      description 'An emoji awarded by a user'

      authorize :read_emoji

      present_using AwardEmojiPresenter

      field :name,
            GraphQL::STRING_TYPE,
            null: false,
            description: 'The emoji name'

      field :description,
            GraphQL::STRING_TYPE,
            null: false,
            description: 'The emoji description'

      field :unicode,
            GraphQL::STRING_TYPE,
            null: false,
            description: 'The emoji in unicode'

      field :emoji,
            GraphQL::STRING_TYPE,
            null: false,
            description: 'The emoji as an icon'

      field :unicode_version,
            GraphQL::STRING_TYPE,
            null: false,
            description: 'The unicode version for this emoji'

      field :user,
            Types::UserType,
            null: false,
            description: 'The user who awarded the emoji'

      def user
        Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.user_id).find
      end
    end
  end
end