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

release_type.rb « types « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a20e53ad1bd77195af2fe598087b5c293c7e29f7 (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
# frozen_string_literal: true

module Types
  class ReleaseType < BaseObject
    graphql_name 'Release'
    description 'Represents a release'

    connection_type_class(Types::CountableConnectionType)

    authorize :read_release

    alias_method :release, :object

    present_using ReleasePresenter

    field :id, ::Types::GlobalIDType[Release],
          null: false,
          description: 'Global ID of the release.'
    field :assets, Types::ReleaseAssetsType, null: true, method: :itself,
                                             description: 'Assets of the release.'
    field :created_at, Types::TimeType, null: true,
                                        description: 'Timestamp of when the release was created.'
    field :description,
          GraphQL::Types::String,
          null: true,
          description: 'Description (also known as "release notes") of the release.'
    field :evidences, Types::EvidenceType.connection_type, null: true,
                                                           description: 'Evidence for the release.'
    field :links, Types::ReleaseLinksType, null: true, method: :itself,
                                           description: 'Links of the release.'
    field :milestones, Types::MilestoneType.connection_type, null: true,
                                                             description: 'Milestones associated to the release.',
                                                             resolver: ::Resolvers::ReleaseMilestonesResolver
    field :name, GraphQL::Types::String, null: true,
                                         description: 'Name of the release.'
    field :released_at, Types::TimeType, null: true,
                                         description: 'Timestamp of when the release was released.'
    field :tag_name, GraphQL::Types::String, null: true, method: :tag,
                                             description: 'Name of the tag associated with the release.'
    field :tag_path, GraphQL::Types::String, null: true,
                                             description: 'Relative web path to the tag associated with the release.',
                                             authorize: :read_code
    field :upcoming_release, GraphQL::Types::Boolean, null: true, method: :upcoming_release?,
                                                      description: 'Indicates the release is an upcoming release.'
    field :historical_release, GraphQL::Types::Boolean, null: true, method: :historical_release?,
                                                        description: 'Indicates the release is an historical release.'

    field :author, Types::UserType, null: true,
                                    description: 'User that created the release.'

    field :commit, Types::CommitType, null: true,
                                      complexity: 10, calls_gitaly: true,
                                      description: 'Commit associated with the release.'

    markdown_field :description_html, null: true

    def author
      Gitlab::Graphql::Loaders::BatchModelLoader.new(User, release.author_id).find
    end

    def commit
      return if release.sha.nil?

      release.project.commit_by(oid: release.sha)
    end
  end
end