2018-09-11 15:08:34 -04:00
|
|
|
# frozen_string_literal: true
|
2020-11-17 13:09:20 -05:00
|
|
|
# rubocop: disable Graphql/ResolverType
|
2018-09-11 15:08:34 -04:00
|
|
|
|
2018-06-26 12:31:05 -04:00
|
|
|
module Resolvers
|
|
|
|
class MergeRequestPipelinesResolver < BaseResolver
|
2020-11-17 13:09:20 -05:00
|
|
|
# The GraphQL type here gets defined in this include
|
2018-06-26 12:31:05 -04:00
|
|
|
include ::ResolvesPipelines
|
2020-12-09 13:09:48 -05:00
|
|
|
include ::CachingArrayResolver
|
2018-06-26 12:31:05 -04:00
|
|
|
|
|
|
|
alias_method :merge_request, :object
|
|
|
|
|
2020-12-09 13:09:48 -05:00
|
|
|
# Return at most 500 pipelines for each MR.
|
|
|
|
# Merge requests generally have many fewer pipelines than this.
|
|
|
|
def self.field_options
|
|
|
|
super.merge(max_page_size: 500)
|
|
|
|
end
|
|
|
|
|
2018-06-26 12:31:05 -04:00
|
|
|
def resolve(**args)
|
2020-09-11 20:08:44 -04:00
|
|
|
return unless project
|
|
|
|
|
2020-12-09 13:09:48 -05:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def query_for(args)
|
|
|
|
resolve_pipelines(project, args).merge(merge_request.all_pipelines)
|
|
|
|
end
|
|
|
|
|
|
|
|
def model_class
|
|
|
|
::Ci::Pipeline
|
|
|
|
end
|
|
|
|
|
|
|
|
def query_input(**args)
|
|
|
|
args
|
2018-06-26 12:31:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def project
|
|
|
|
merge_request.source_project
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-11-17 13:09:20 -05:00
|
|
|
# rubocop: enable Graphql/ResolverType
|