Class: Types::WorkItems::Widgets::HierarchyType
- Inherits:
-
BaseObject
- Object
- GraphQL::Schema::Object
- BaseObject
- Types::WorkItems::Widgets::HierarchyType
- Defined in:
- app/graphql/types/work_items/widgets/hierarchy_type.rb
Overview
Disabling widget level authorization as it might be too granular and we already authorize the parent work item rubocop:disable Graphql/AuthorizeTypes
Instance Method Summary collapse
- #children ⇒ Object
-
#has_children? ⇒ Boolean
(also: #has_children)
rubocop: disable CodeReuse/ActiveRecord.
Methods inherited from BaseObject
accepts, assignable?, authorization, authorize, authorized?, #current_user, #id
Methods included from Gitlab::Graphql::Present
Instance Method Details
#children ⇒ Object
41 42 43 44 45 46 |
# File 'app/graphql/types/work_items/widgets/hierarchy_type.rb', line 41 def children relation = object.children relation = relation. unless object.children.loaded? relation end |
#has_children? ⇒ Boolean Also known as: has_children
rubocop: disable CodeReuse/ActiveRecord
27 28 29 30 31 32 33 34 35 36 |
# File 'app/graphql/types/work_items/widgets/hierarchy_type.rb', line 27 def has_children? BatchLoader::GraphQL.for(object.work_item.id).batch(default_value: false) do |ids, loader| links_for_parents = ::WorkItems::ParentLink.for_parents(ids) .select(:work_item_parent_id) .group(:work_item_parent_id) .reorder(nil) links_for_parents.each { |link| loader.call(link.work_item_parent_id, true) } end end |