Class: Mutations::WorkItems::Hierarchy::AddChildrenItems
- Inherits:
-
BaseMutation
- Object
- GraphQL::Schema::RelayClassicMutation
- BaseMutation
- Mutations::WorkItems::Hierarchy::AddChildrenItems
- Includes:
- Widgetable
- Defined in:
- app/graphql/mutations/work_items/hierarchy/add_children_items.rb
Constant Summary
Constants inherited from BaseMutation
Constants included from Gitlab::Graphql::Authorize::AuthorizeResource
Gitlab::Graphql::Authorize::AuthorizeResource::ConfigurationError, Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR
Instance Method Summary collapse
Methods included from Widgetable
Methods inherited from BaseMutation
#api_user?, authorization, authorization_scopes, authorized?, authorizes_object?, #current_user, #errors_on_object, #load_application_object, #read_only?, #ready?, #unauthorized_object
Methods included from Gitlab::Graphql::Authorize::AuthorizeResource
#authorize!, #authorized_find!, #authorized_resource?, #find_object, #raise_resource_not_available_error!
Instance Method Details
#resolve(id:, **attributes) ⇒ Object
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 56 57 |
# File 'app/graphql/mutations/work_items/hierarchy/add_children_items.rb', line 28 def resolve(id:, **attributes) Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/408575') work_item = (id: id) children = attributes[:children] = { hierarchy_widget: { children: children } } = (work_item.work_item_type, , work_item.resource_parent) update_result = ::WorkItems::UpdateService.new( container: work_item.resource_parent, current_user: current_user, params: {}, widget_params: ).execute(work_item) # Find newly added children using the provided children_ids if update_result[:status] == :success updated_work_item = update_result[:work_item] children_ids = children.map(&:id) added_children = updated_work_item.work_item_children.select { |child| children_ids.include?(child.id) } else added_children = [] end { added_children: added_children, errors: Array.wrap(update_result[:message]) } end |