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

pipeline_type.rb « ci « types « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 49be200a788b6b91658159768ae40a8cd5e9314e (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# frozen_string_literal: true

module Types
  module Ci
    class PipelineType < BaseObject
      graphql_name 'Pipeline'

      connection_type_class(Types::CountableConnectionType)

      authorize :read_pipeline
      present_using ::Ci::PipelinePresenter

      expose_permissions Types::PermissionTypes::Ci::Pipeline

      field :id, GraphQL::ID_TYPE, null: false,
            description: 'ID of the pipeline.'

      field :iid, GraphQL::STRING_TYPE, null: false,
            description: 'Internal ID of the pipeline.'

      field :sha, GraphQL::STRING_TYPE, null: false,
            description: "SHA of the pipeline's commit."

      field :before_sha, GraphQL::STRING_TYPE, null: true,
            description: 'Base SHA of the source branch.'

      field :status, PipelineStatusEnum, null: false,
            description: "Status of the pipeline (#{::Ci::Pipeline.all_state_names.compact.join(', ').upcase})"

      field :warnings, GraphQL::BOOLEAN_TYPE, null: false, method: :has_warnings?,
            description: "Indicates if a pipeline has warnings."

      field :detailed_status, Types::Ci::DetailedStatusType, null: false,
            description: 'Detailed status of the pipeline.'

      field :config_source, PipelineConfigSourceEnum, null: true,
            description: "Configuration source of the pipeline (#{::Enums::Ci::Pipeline.config_sources.keys.join(', ').upcase})"

      field :duration, GraphQL::INT_TYPE, null: true,
            description: 'Duration of the pipeline in seconds.'

      field :coverage, GraphQL::FLOAT_TYPE, null: true,
            description: 'Coverage percentage.'

      field :created_at, Types::TimeType, null: false,
            description: "Timestamp of the pipeline's creation."

      field :updated_at, Types::TimeType, null: false,
            description: "Timestamp of the pipeline's last activity."

      field :started_at, Types::TimeType, null: true,
            description: 'Timestamp when the pipeline was started.'

      field :finished_at, Types::TimeType, null: true,
            description: "Timestamp of the pipeline's completion."

      field :committed_at, Types::TimeType, null: true,
            description: "Timestamp of the pipeline's commit."

      field :stages, Types::Ci::StageType.connection_type, null: true,
            description: 'Stages of the pipeline.',
            extras: [:lookahead],
            resolver: Resolvers::Ci::PipelineStagesResolver

      field :user, Types::UserType, null: true,
            description: 'Pipeline user.'

      field :retryable, GraphQL::BOOLEAN_TYPE,
            description: 'Specifies if a pipeline can be retried.',
            method: :retryable?,
            null: false

      field :cancelable, GraphQL::BOOLEAN_TYPE,
            description: 'Specifies if a pipeline can be canceled.',
            method: :cancelable?,
            null: false

      field :jobs,
            ::Types::Ci::JobType.connection_type,
            null: true,
            description: 'Jobs belonging to the pipeline.',
            resolver: ::Resolvers::Ci::JobsResolver

      field :source_job, Types::Ci::JobType, null: true,
            description: 'Job where pipeline was triggered from.'

      field :downstream, Types::Ci::PipelineType.connection_type, null: true,
            description: 'Pipelines this pipeline will trigger.',
            method: :triggered_pipelines_with_preloads

      field :upstream, Types::Ci::PipelineType, null: true,
            description: 'Pipeline that triggered the pipeline.',
            method: :triggered_by_pipeline

      field :path, GraphQL::STRING_TYPE, null: true,
            description: "Relative path to the pipeline's page."

      field :commit_path, GraphQL::STRING_TYPE, null: true,
            description: 'Path to the commit that triggered the pipeline.'

      field :project, Types::ProjectType, null: true,
            description: 'Project the pipeline belongs to.'

      field :active, GraphQL::BOOLEAN_TYPE, null: false, method: :active?,
            description: 'Indicates if the pipeline is active.'

      def detailed_status
        object.detailed_status(context[:current_user])
      end

      def user
        Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.user_id).find
      end

      def commit_path
        ::Gitlab::Routing.url_helpers.project_commit_path(object.project, object.sha)
      end

      def path
        ::Gitlab::Routing.url_helpers.project_pipeline_path(object.project, object)
      end
    end
  end
end

Types::Ci::PipelineType.prepend_if_ee('::EE::Types::Ci::PipelineType')