diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /app/graphql/mutations/releases | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) | |
download | gitlab-ce-7e9c479f7de77702622631cff2628a9c8dcbc627.tar.gz |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/graphql/mutations/releases')
-rw-r--r-- | app/graphql/mutations/releases/base.rb | 19 | ||||
-rw-r--r-- | app/graphql/mutations/releases/create.rb | 68 |
2 files changed, 87 insertions, 0 deletions
diff --git a/app/graphql/mutations/releases/base.rb b/app/graphql/mutations/releases/base.rb new file mode 100644 index 00000000000..d53cfbe6a11 --- /dev/null +++ b/app/graphql/mutations/releases/base.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Mutations + module Releases + class Base < BaseMutation + include ResolvesProject + + argument :project_path, GraphQL::ID_TYPE, + required: true, + description: 'Full path of the project the release is associated with' + + private + + def find_object(full_path:) + resolve_project(full_path: full_path) + end + end + end +end diff --git a/app/graphql/mutations/releases/create.rb b/app/graphql/mutations/releases/create.rb new file mode 100644 index 00000000000..57c1541c368 --- /dev/null +++ b/app/graphql/mutations/releases/create.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true + +module Mutations + module Releases + class Create < Base + graphql_name 'ReleaseCreate' + + field :release, + Types::ReleaseType, + null: true, + description: 'The release after mutation' + + argument :tag_name, GraphQL::STRING_TYPE, + required: true, as: :tag, + description: 'Name of the tag to associate with the release' + + argument :ref, GraphQL::STRING_TYPE, + required: false, + description: 'The commit SHA or branch name to use if creating a new tag' + + argument :name, GraphQL::STRING_TYPE, + required: false, + description: 'Name of the release' + + argument :description, GraphQL::STRING_TYPE, + required: false, + description: 'Description (also known as "release notes") of the release' + + argument :released_at, Types::TimeType, + required: false, + description: 'The date when the release will be/was ready. Defaults to the current time.' + + argument :milestones, [GraphQL::STRING_TYPE], + required: false, + description: 'The title of each milestone the release is associated with. GitLab Premium customers can specify group milestones.' + + argument :assets, Types::ReleaseAssetsInputType, + required: false, + description: 'Assets associated to the release' + + authorize :create_release + + def resolve(project_path:, milestones: nil, assets: nil, **scalars) + project = authorized_find!(full_path: project_path) + + params = { + **scalars, + milestones: milestones.presence || [], + 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 |