summaryrefslogtreecommitdiff
path: root/app/graphql/types/achievements/achievement_type.rb
blob: e2b9495c83dce52ab5cc1003827d177578a6497e (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
49
50
51
52
53
54
55
# frozen_string_literal: true

module Types
  module Achievements
    class AchievementType < BaseObject
      graphql_name 'Achievement'

      authorize :read_achievement

      field :id,
            ::Types::GlobalIDType[::Achievements::Achievement],
            null: false,
            description: 'ID of the achievement.'

      field :namespace,
            ::Types::NamespaceType,
            null: false,
            description: 'Namespace of the achievement.'

      field :name,
            GraphQL::Types::String,
            null: false,
            description: 'Name of the achievement.'

      field :avatar_url,
            GraphQL::Types::String,
            null: true,
            description: 'URL to avatar of the achievement.'

      field :description,
            GraphQL::Types::String,
            null: true,
            description: 'Description or notes for the achievement.'

      field :revokeable,
            GraphQL::Types::Boolean,
            null: false,
            description: 'Revokeability of the achievement.'

      field :created_at,
            Types::TimeType,
            null: false,
            description: 'Timestamp the achievement was created.'

      field :updated_at,
            Types::TimeType,
            null: false,
            description: 'Timestamp the achievement was last updated.'

      def avatar_url
        object.avatar_url(only_path: false)
      end
    end
  end
end