Welcome to mirror list, hosted at ThFree Co, Russian Federation.

create.rb « releases « mutations « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 57c1541c368dab191320832faac6b394f4994a91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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