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

45 lines
1.5 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2018-11-08 19:23:39 +05:30
module Resolvers
2019-07-07 11:18:12 +05:30
class MergeRequestsResolver < BaseResolver
2020-06-23 00:09:42 +05:30
include ResolvesMergeRequests
alias_method :project, :synchronized_object
2019-07-07 11:18:12 +05:30
2019-09-04 21:01:54 +05:30
argument :iids, [GraphQL::STRING_TYPE],
2019-07-07 11:18:12 +05:30
required: false,
2020-04-22 19:07:51 +05:30
description: 'Array of IIDs of merge requests, for example `[1, 2]`'
2018-11-08 19:23:39 +05:30
2020-06-23 00:09:42 +05:30
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-11-08 19:23:39 +05:30
2020-06-23 00:09:42 +05:30
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-11-08 19:23:39 +05:30
2020-06-23 00:09:42 +05:30
argument :state, ::Types::MergeRequestStateEnum,
required: false,
description: 'A merge request state. If provided, all resolved merge requests will have this state.'
2018-11-08 19:23:39 +05:30
2020-06-23 00:09:42 +05:30
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.'
2019-07-07 11:18:12 +05:30
2020-06-23 00:09:42 +05:30
def self.single
::Resolvers::MergeRequestResolver
2020-04-22 19:07:51 +05:30
end
2020-06-23 00:09:42 +05:30
def no_results_possible?(args)
project.nil? || some_argument_is_empty?(args)
2019-07-07 11:18:12 +05:30
end
2020-06-23 00:09:42 +05:30
def some_argument_is_empty?(args)
args.values.any? { |v| v.is_a?(Array) && v.empty? }
2018-11-08 19:23:39 +05:30
end
end
end