2021-02-22 17:27:13 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Mutations
|
|
|
|
module Releases
|
|
|
|
class Update < Base
|
|
|
|
graphql_name 'ReleaseUpdate'
|
|
|
|
|
|
|
|
field :release,
|
|
|
|
Types::ReleaseType,
|
|
|
|
null: true,
|
2021-10-27 15:23:28 +05:30
|
|
|
description: 'Release after mutation.'
|
2021-02-22 17:27:13 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
argument :tag_name, GraphQL::Types::String,
|
2021-02-22 17:27:13 +05:30
|
|
|
required: true, as: :tag,
|
2021-03-08 18:12:59 +05:30
|
|
|
description: 'Name of the tag associated with the release.'
|
2021-02-22 17:27:13 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
argument :name, GraphQL::Types::String,
|
2021-02-22 17:27:13 +05:30
|
|
|
required: false,
|
2021-03-08 18:12:59 +05:30
|
|
|
description: 'Name of the release.'
|
2021-02-22 17:27:13 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
argument :description, GraphQL::Types::String,
|
2021-02-22 17:27:13 +05:30
|
|
|
required: false,
|
2021-03-08 18:12:59 +05:30
|
|
|
description: 'Description (release notes) of the release.'
|
2021-02-22 17:27:13 +05:30
|
|
|
|
|
|
|
argument :released_at, Types::TimeType,
|
|
|
|
required: false,
|
2021-10-27 15:23:28 +05:30
|
|
|
description: 'Release date.'
|
2021-02-22 17:27:13 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
argument :milestones, [GraphQL::Types::String],
|
2021-02-22 17:27:13 +05:30
|
|
|
required: false,
|
2021-10-27 15:23:28 +05:30
|
|
|
description: 'Title of each milestone the release is associated with. GitLab Premium customers can specify group milestones.'
|
2021-02-22 17:27:13 +05:30
|
|
|
|
|
|
|
authorize :update_release
|
|
|
|
|
|
|
|
def ready?(**args)
|
|
|
|
if args.key?(:released_at) && args[:released_at].nil?
|
|
|
|
raise Gitlab::Graphql::Errors::ArgumentError,
|
|
|
|
'if the releasedAt argument is provided, it cannot be null'
|
|
|
|
end
|
|
|
|
|
|
|
|
if args.key?(:milestones) && args[:milestones].nil?
|
|
|
|
raise Gitlab::Graphql::Errors::ArgumentError,
|
|
|
|
'if the milestones argument is provided, it cannot be null'
|
|
|
|
end
|
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def resolve(project_path:, **scalars)
|
2021-03-11 19:13:27 +05:30
|
|
|
project = authorized_find!(project_path)
|
2021-02-22 17:27:13 +05:30
|
|
|
|
|
|
|
params = scalars.with_indifferent_access
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
result = ::Releases::UpdateService.new(project, current_user, params).execute
|
2021-02-22 17:27:13 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
if result[:status] == :success
|
2021-02-22 17:27:13 +05:30
|
|
|
{
|
2021-03-08 18:12:59 +05:30
|
|
|
release: result[:release],
|
2021-02-22 17:27:13 +05:30
|
|
|
errors: []
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
release: nil,
|
2021-03-08 18:12:59 +05:30
|
|
|
errors: [result[:message]]
|
2021-02-22 17:27:13 +05:30
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|