2018-09-11 15:08:34 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-23 03:55:14 -04:00
|
|
|
module Resolvers
|
2019-01-30 14:00:30 -05:00
|
|
|
class MergeRequestsResolver < BaseResolver
|
2020-05-21 20:08:07 -04:00
|
|
|
include ResolvesMergeRequests
|
|
|
|
|
|
|
|
alias_method :project, :synchronized_object
|
2018-05-23 03:55:14 -04:00
|
|
|
|
2020-03-16 11:09:27 -04:00
|
|
|
argument :iids, [GraphQL::STRING_TYPE],
|
2019-01-30 14:00:30 -05:00
|
|
|
required: false,
|
2020-04-07 17:09:46 -04:00
|
|
|
description: 'Array of IIDs of merge requests, for example `[1, 2]`'
|
2019-01-30 14:00:30 -05:00
|
|
|
|
2020-05-21 20:08:07 -04:00
|
|
|
argument :source_branches, [GraphQL::STRING_TYPE],
|
|
|
|
required: false,
|
|
|
|
as: :source_branch,
|
|
|
|
description: 'Array of source branch names. All resolved merge requests will have one of these branches as their source.'
|
2018-06-14 09:06:53 -04:00
|
|
|
|
2020-05-21 20:08:07 -04:00
|
|
|
argument :target_branches, [GraphQL::STRING_TYPE],
|
|
|
|
required: false,
|
|
|
|
as: :target_branch,
|
|
|
|
description: 'Array of target branch names. All resolved merge requests will have one of these branches as their target.'
|
2018-05-23 03:55:14 -04:00
|
|
|
|
2020-05-21 20:08:07 -04:00
|
|
|
argument :state, ::Types::MergeRequestStateEnum,
|
|
|
|
required: false,
|
|
|
|
description: 'A merge request state. If provided, all resolved merge requests will have this state.'
|
2019-01-30 14:00:30 -05:00
|
|
|
|
2020-05-21 20:08:07 -04:00
|
|
|
argument :labels, [GraphQL::STRING_TYPE],
|
|
|
|
required: false,
|
|
|
|
as: :label_name,
|
|
|
|
description: 'Array of label names. All resolved merge requests will have all of these labels.'
|
2020-08-06 14:09:41 -04:00
|
|
|
argument :merged_after, Types::TimeType,
|
2020-08-28 02:10:45 -04:00
|
|
|
required: false,
|
|
|
|
description: 'Merge requests merged after this date'
|
2020-08-06 14:09:41 -04:00
|
|
|
argument :merged_before, Types::TimeType,
|
2020-08-28 02:10:45 -04:00
|
|
|
required: false,
|
|
|
|
description: 'Merge requests merged before this date'
|
|
|
|
argument :milestone_title, GraphQL::STRING_TYPE,
|
|
|
|
required: false,
|
|
|
|
description: 'Title of the milestone'
|
2020-09-02 05:10:23 -04:00
|
|
|
argument :sort, Types::MergeRequestSortEnum,
|
|
|
|
description: 'Sort merge requests by this criteria',
|
|
|
|
required: false,
|
|
|
|
default_value: 'created_desc'
|
2020-04-14 05:09:34 -04:00
|
|
|
|
2020-05-21 20:08:07 -04:00
|
|
|
def self.single
|
|
|
|
::Resolvers::MergeRequestResolver
|
2020-04-14 05:09:34 -04:00
|
|
|
end
|
|
|
|
|
2020-05-21 20:08:07 -04:00
|
|
|
def no_results_possible?(args)
|
2020-06-02 11:08:24 -04:00
|
|
|
project.nil? || some_argument_is_empty?(args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def some_argument_is_empty?(args)
|
|
|
|
args.values.any? { |v| v.is_a?(Array) && v.empty? }
|
2018-05-23 03:55:14 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|