Class: Mutations::WorkItems::BulkUpdate

Inherits:
BaseMutation
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/graphql/mutations/work_items/bulk_update.rb

Constant Summary collapse

MAX_WORK_ITEMS =
100

Constants inherited from BaseMutation

BaseMutation::ERROR_MESSAGE

Constants included from Gitlab::Graphql::Authorize::AuthorizeResource

Gitlab::Graphql::Authorize::AuthorizeResource::ConfigurationError, Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR

Instance Method Summary collapse

Methods inherited from BaseMutation

#api_user?, authorization, authorization_scopes, authorized?, authorizes_object?, #current_user, #errors_on_object, #load_application_object, #read_only?, #unauthorized_object

Methods included from Gitlab::Graphql::Authorize::AuthorizeResource

#authorize!, #authorized_find!, #authorized_resource?, #find_object, #raise_resource_not_available_error!

Instance Method Details

#ready?(**args) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/graphql/mutations/work_items/bulk_update.rb', line 35

def ready?(**args)
  if Feature.disabled?(:bulk_update_work_items_mutation, parent_for!(args[:parent_id]))
    raise_resource_not_available_error!('`bulk_update_work_items_mutation` feature flag is disabled.')
  end

  if args[:ids].size > MAX_WORK_ITEMS
    raise Gitlab::Graphql::Errors::ArgumentError,
      format(
        _('No more than %{max_work_items} work items can be updated at the same time'),
        max_work_items: MAX_WORK_ITEMS
      )
  end

  super
end

#resolve(ids:, parent_id:, **attributes) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/graphql/mutations/work_items/bulk_update.rb', line 51

def resolve(ids:, parent_id:, **attributes)
  parent = parent_for!(parent_id)

  result = ::WorkItems::BulkUpdateService.new(
    parent: parent,
    current_user: current_user,
    work_item_ids: ids.map(&:model_id),
    widget_params: attributes
  ).execute

  if result.success?
    { updated_work_item_count: result[:updated_work_item_count], errors: result.errors }
  else
    { errors: result.errors }
  end
end