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
|
# frozen_string_literal: true
module Resolvers
class MergeRequestsResolver < BaseResolver
include ResolvesMergeRequests
extend ::Gitlab::Graphql::NegatableArguments
type ::Types::MergeRequestType.connection_type, null: true
alias_method :project, :object
def self.accept_assignee
argument :assignee_username, GraphQL::Types::String,
required: false,
description: 'Username of the assignee.'
end
def self.accept_author
argument :author_username, GraphQL::Types::String,
required: false,
description: 'Username of the author.'
end
def self.accept_reviewer
argument :reviewer_username, GraphQL::Types::String,
required: false,
description: 'Username of the reviewer.'
end
argument :iids, [GraphQL::Types::String],
required: false,
description: 'Array of IIDs of merge requests, for example `[1, 2]`.'
argument :source_branches, [GraphQL::Types::String],
required: false,
as: :source_branch,
description: <<~DESC
Array of source branch names.
All resolved merge requests will have one of these branches as their source.
DESC
argument :target_branches, [GraphQL::Types::String],
required: false,
as: :target_branch,
description: <<~DESC
Array of target branch names.
All resolved merge requests will have one of these branches as their target.
DESC
argument :state, ::Types::MergeRequestStateEnum,
required: false,
description: 'Merge request state. If provided, all resolved merge requests will have this state.'
argument :draft, GraphQL::Types::Boolean,
required: false,
description: 'Limit result to draft merge requests.'
argument :created_after, Types::TimeType,
required: false,
description: 'Merge requests created after this timestamp.'
argument :created_before, Types::TimeType,
required: false,
description: 'Merge requests created before this timestamp.'
argument :updated_after, Types::TimeType,
required: false,
description: 'Merge requests updated after this timestamp.'
argument :updated_before, Types::TimeType,
required: false,
description: 'Merge requests updated before this timestamp.'
argument :labels, [GraphQL::Types::String],
required: false,
as: :label_name,
description: 'Array of label names. All resolved merge requests will have all of these labels.'
argument :merged_after, Types::TimeType,
required: false,
description: 'Merge requests merged after this date.'
argument :merged_before, Types::TimeType,
required: false,
description: 'Merge requests merged before this date.'
argument :milestone_title, GraphQL::Types::String,
required: false,
description: 'Title of the milestone.'
argument :sort, Types::MergeRequestSortEnum,
description: 'Sort merge requests by this criteria.',
required: false,
default_value: :created_desc
negated do
argument :labels, [GraphQL::Types::String],
required: false,
as: :label_name,
description: 'Array of label names. All resolved merge requests will not have these labels.'
argument :milestone_title, GraphQL::Types::String,
required: false,
description: 'Title of the milestone.'
end
def self.single
::Resolvers::MergeRequestResolver
end
def no_results_possible?(args)
project.nil? || some_argument_is_empty?(args)
end
def some_argument_is_empty?(args)
args.values.any? { |v| v.is_a?(Array) && v.empty? }
end
end
end
|