Class: Mutations::Packages::BulkDestroy
- Inherits:
-
BaseMutation
- Object
- GraphQL::Schema::RelayClassicMutation
- BaseMutation
- Mutations::Packages::BulkDestroy
- Defined in:
- app/graphql/mutations/packages/bulk_destroy.rb
Constant Summary collapse
- MAX_PACKAGES =
20
- TOO_MANY_IDS_ERROR =
"Cannot delete more than #{MAX_PACKAGES} packages"
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 inherited from BaseMutation
#api_user?, authorization, 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(ids:) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/graphql/mutations/packages/bulk_destroy.rb', line 16 def resolve(ids:) raise_resource_not_available_error!(TOO_MANY_IDS_ERROR) if ids.size > MAX_PACKAGES model_ids = ids.map(&:model_id) service = ::Packages::MarkPackagesForDestructionService.new( packages: packages_from(model_ids), current_user: current_user ) result = service.execute raise_resource_not_available_error! if result.reason == :unauthorized errors = result.error? ? Array.wrap(result[:message]) : [] { errors: errors } end |