debian-mirror-gitlab/app/graphql/mutations/releases/create.rb

68 lines
2 KiB
Ruby
Raw Normal View History

2021-01-29 00:20:46 +05:30
# frozen_string_literal: true
module Mutations
module Releases
class Create < Base
graphql_name 'ReleaseCreate'
field :release,
Types::ReleaseType,
null: true,
2021-10-27 15:23:28 +05:30
description: 'Release after mutation.'
2021-01-29 00:20:46 +05:30
2021-10-27 15:23:28 +05:30
argument :tag_name, GraphQL::Types::String,
2021-01-29 00:20:46 +05:30
required: true, as: :tag,
2021-03-08 18:12:59 +05:30
description: 'Name of the tag to associate with the release.'
2021-01-29 00:20:46 +05:30
2021-10-27 15:23:28 +05:30
argument :ref, GraphQL::Types::String,
2021-01-29 00:20:46 +05:30
required: false,
2021-10-27 15:23:28 +05:30
description: 'Commit SHA or branch name to use if creating a new tag.'
2021-01-29 00:20:46 +05:30
2021-10-27 15:23:28 +05:30
argument :name, GraphQL::Types::String,
2021-01-29 00:20:46 +05:30
required: false,
2021-03-08 18:12:59 +05:30
description: 'Name of the release.'
2021-01-29 00:20:46 +05:30
2021-10-27 15:23:28 +05:30
argument :description, GraphQL::Types::String,
2021-01-29 00:20:46 +05:30
required: false,
2021-03-08 18:12:59 +05:30
description: 'Description (also known as "release notes") of the release.'
2021-01-29 00:20:46 +05:30
argument :released_at, Types::TimeType,
required: false,
2021-10-27 15:23:28 +05:30
description: 'Date and time for the release. Defaults to the current date and time.'
2021-01-29 00:20:46 +05:30
2021-10-27 15:23:28 +05:30
argument :milestones, [GraphQL::Types::String],
2021-01-29 00:20:46 +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-01-29 00:20:46 +05:30
argument :assets, Types::ReleaseAssetsInputType,
required: false,
2021-03-08 18:12:59 +05:30
description: 'Assets associated to the release.'
2021-01-29 00:20:46 +05:30
authorize :create_release
2021-02-22 17:27:13 +05:30
def resolve(project_path:, assets: nil, **scalars)
2021-03-11 19:13:27 +05:30
project = authorized_find!(project_path)
2021-01-29 00:20:46 +05:30
params = {
**scalars,
assets: assets.to_h
}.with_indifferent_access
result = ::Releases::CreateService.new(project, current_user, params).execute
if result[:status] == :success
{
release: result[:release],
errors: []
}
else
{
release: nil,
errors: [result[:message]]
}
end
end
end
end
end