debian-mirror-gitlab/app/graphql/resolvers/project_pipeline_resolver.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
1.6 KiB
Ruby
Raw Normal View History

2020-06-23 00:09:42 +05:30
# frozen_string_literal: true
module Resolvers
class ProjectPipelineResolver < BaseResolver
2021-11-18 22:05:49 +05:30
include LooksAhead
2021-01-29 00:20:46 +05:30
type ::Types::Ci::PipelineType, null: true
2020-06-23 00:09:42 +05:30
alias_method :project, :object
2021-10-27 15:23:28 +05:30
argument :iid, GraphQL::Types::ID,
2021-04-17 20:07:23 +05:30
required: false,
description: 'IID of the Pipeline. For example, "1".'
2020-06-23 00:09:42 +05:30
2021-10-27 15:23:28 +05:30
argument :sha, GraphQL::Types::String,
2021-04-17 20:07:23 +05:30
required: false,
description: 'SHA of the Pipeline. For example, "dyd0f15ay83993f5ab66k927w28673882x99100b".'
2021-02-22 17:27:13 +05:30
2021-11-18 22:05:49 +05:30
def ready?(iid: nil, sha: nil, **args)
2021-04-17 20:07:23 +05:30
unless iid.present? ^ sha.present?
raise Gitlab::Graphql::Errors::ArgumentError, 'Provide one of an IID or SHA'
end
super
end
2021-11-18 22:05:49 +05:30
def resolve(iid: nil, sha: nil, **args)
self.lookahead = args.delete(:lookahead)
2021-04-17 20:07:23 +05:30
if iid
2021-11-18 22:05:49 +05:30
BatchLoader::GraphQL.for(iid).batch(key: project) do |iids, loader|
2021-04-17 20:07:23 +05:30
finder = ::Ci::PipelinesFinder.new(project, current_user, iids: iids)
2021-11-18 22:05:49 +05:30
apply_lookahead(finder.execute).each { |pipeline| loader.call(pipeline.iid.to_s, pipeline) }
2021-04-17 20:07:23 +05:30
end
else
2021-11-18 22:05:49 +05:30
BatchLoader::GraphQL.for(sha).batch(key: project) do |shas, loader|
2021-04-29 21:17:54 +05:30
finder = ::Ci::PipelinesFinder.new(project, current_user, sha: shas)
2021-04-17 20:07:23 +05:30
2021-11-18 22:05:49 +05:30
apply_lookahead(finder.execute).each { |pipeline| loader.call(pipeline.sha.to_s, pipeline) }
2021-04-17 20:07:23 +05:30
end
2020-06-23 00:09:42 +05:30
end
end
2022-01-26 12:08:38 +05:30
def unconditional_includes
[
{ statuses: [:needs] }
]
end
2022-07-16 23:28:13 +05:30
def self.resolver_complexity(args, child_complexity:)
complexity = super
complexity - 10
end
2020-06-23 00:09:42 +05:30
end
end