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, authorization_scopes, authorize, authorized?, #current_user, #id
Methods included from Gitlab::Graphql::Present
Instance Method Details
#children ⇒ Object
58 59 60 61 62 63 |
# File 'app/graphql/types/work_items/widgets/hierarchy_type.rb', line 58 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
44 45 46 47 48 49 50 51 52 53 |
# File 'app/graphql/types/work_items/widgets/hierarchy_type.rb', line 44 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 |