summaryrefslogtreecommitdiff
path: root/app/graphql/types/work_items/widgets/description_type.rb
blob: 4861f7f46d869a19d487a9b47f02b3337f752c71 (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 Types
  module WorkItems
    module Widgets
      # Disabling widget level authorization as it might be too granular
      # and we already authorize the parent work item
      # rubocop:disable Graphql/AuthorizeTypes
      class DescriptionType < BaseObject
        graphql_name 'WorkItemWidgetDescription'
        description 'Represents a description widget'

        implements Types::WorkItems::WidgetInterface

        field :description, GraphQL::Types::String,
              null: true,
              description: 'Description of the work item.'
        field :edited, GraphQL::Types::Boolean,
              null: false,
              description: 'Whether the description has been edited since the work item was created.',
              method: :edited?
        field :last_edited_at, Types::TimeType,
              null: true,
              description: 'Timestamp of when the work item\'s description was last edited.'
        field :last_edited_by, Types::UserType,
              null: true,
              description: 'User that made the last edit to the work item\'s description.'

        markdown_field :description_html, null: true do |resolved_object|
          resolved_object.work_item
        end
      end
      # rubocop:enable Graphql/AuthorizeTypes
    end
  end
end