debian-mirror-gitlab/app/graphql/mutations/design_management/upload.rb

39 lines
1.2 KiB
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
module Mutations
module DesignManagement
class Upload < Base
graphql_name "DesignManagementUpload"
argument :files, [ApolloUploadServer::Upload],
required: true,
2021-03-08 18:12:59 +05:30
description: "The files to upload."
2020-05-24 23:13:21 +05:30
authorize :create_design
field :designs, [Types::DesignManagement::DesignType],
null: false,
2021-03-08 18:12:59 +05:30
description: "The designs that were uploaded by the mutation."
2020-05-24 23:13:21 +05:30
field :skipped_designs, [Types::DesignManagement::DesignType],
null: false,
description: "Any designs that were skipped from the upload due to there " \
"being no change to their content since their last version"
def resolve(project_path:, iid:, files:)
issue = authorized_find!(project_path: project_path, iid: iid)
project = issue.project
result = ::DesignManagement::SaveDesignsService.new(project, current_user, issue: issue, files: files)
.execute
{
designs: Array.wrap(result[:designs]),
skipped_designs: Array.wrap(result[:skipped_designs]),
errors: Array.wrap(result[:message])
}
end
end
end
end