Class: Mutations::Packages::DestroyFiles
- Inherits:
-
BaseMutation
- Object
- GraphQL::Schema::RelayClassicMutation
- BaseMutation
- Mutations::Packages::DestroyFiles
- Includes:
- FindsProject, DeleteProtection
- Defined in:
- app/graphql/mutations/packages/destroy_files.rb
Constant Summary collapse
- MAXIMUM_FILES =
100
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, 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(project_path:, ids:) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/graphql/mutations/packages/destroy_files.rb', line 25 def resolve(project_path:, ids:) project = (project_path) raise_resource_not_available_error! "Cannot delete more than #{MAXIMUM_FILES} files" if ids.size > MAXIMUM_FILES package_files = ::Packages::PackageFile.id_in(parse_gids(ids)) ensure_file_access!(project, package_files) files_to_destroy, protection_errors = filter_protected_files(project, package_files) # Create relation from filtered IDs files_to_destroy_relation = package_files.id_in(files_to_destroy.map(&:id)) result = ::Packages::MarkPackageFilesForDestructionService.new(files_to_destroy_relation).execute (package_files) unless result.error? service_errors = result.error? ? Array.wrap(result[:message]) : [] all_errors = protection_errors + service_errors { errors: all_errors } end |