summaryrefslogtreecommitdiff
path: root/app/graphql/types/work_items/widgets/hierarchy_type.rb
blob: 057d5fbf05635d426de1540fd5b43a82c3fb3424 (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
# 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 HierarchyType < BaseObject
        graphql_name 'WorkItemWidgetHierarchy'
        description 'Represents a hierarchy widget'

        implements Types::WorkItems::WidgetInterface

        field :parent, ::Types::WorkItemType, null: true,
              description: 'Parent work item.',
              complexity: 5

        field :children, ::Types::WorkItemType.connection_type, null: true,
              description: 'Child work items.',
              complexity: 5

        def children
          object.children.inc_relations_for_permission_check
        end
      end
      # rubocop:enable Graphql/AuthorizeTypes
    end
  end
end