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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# frozen_string_literal: true
module IssueResolverArguments
extend ActiveSupport::Concern
prepended do
include SearchArguments
include LooksAhead
argument :iid, GraphQL::Types::String,
required: false,
description: 'IID of the issue. For example, "1".'
argument :iids, [GraphQL::Types::String],
required: false,
description: 'List of IIDs of issues. For example, `["1", "2"]`.'
argument :label_name, [GraphQL::Types::String, null: true],
required: false,
description: 'Labels applied to this issue.'
argument :milestone_title, [GraphQL::Types::String, null: true],
required: false,
description: 'Milestone applied to this issue.'
argument :author_username, GraphQL::Types::String,
required: false,
description: 'Username of the author of the issue.'
argument :assignee_username, GraphQL::Types::String,
required: false,
description: 'Username of a user assigned to the issue.',
deprecated: { reason: 'Use `assigneeUsernames`', milestone: '13.11' }
argument :assignee_usernames, [GraphQL::Types::String],
required: false,
description: 'Usernames of users assigned to the issue.'
argument :assignee_id, GraphQL::Types::String,
required: false,
description: 'ID of a user assigned to the issues. Wildcard values "NONE" and "ANY" are supported.'
argument :created_before, Types::TimeType,
required: false,
description: 'Issues created before this date.'
argument :created_after, Types::TimeType,
required: false,
description: 'Issues created after this date.'
argument :updated_before, Types::TimeType,
required: false,
description: 'Issues updated before this date.'
argument :updated_after, Types::TimeType,
required: false,
description: 'Issues updated after this date.'
argument :closed_before, Types::TimeType,
required: false,
description: 'Issues closed before this date.'
argument :closed_after, Types::TimeType,
required: false,
description: 'Issues closed after this date.'
argument :types, [Types::IssueTypeEnum],
as: :issue_types,
description: 'Filter issues by the given issue types.',
required: false
argument :milestone_wildcard_id, ::Types::MilestoneWildcardIdEnum,
required: false,
description: 'Filter issues by milestone ID wildcard.'
argument :my_reaction_emoji, GraphQL::Types::String,
required: false,
description: 'Filter by reaction emoji applied by the current user. Wildcard values "NONE" and "ANY" are supported.'
argument :confidential,
GraphQL::Types::Boolean,
required: false,
description: 'Filter for confidential issues. If "false", excludes confidential issues. If "true", returns only confidential issues.'
argument :not, Types::Issues::NegatedIssueFilterInputType,
description: 'Negated arguments.',
required: false
argument :crm_contact_id, GraphQL::Types::String,
required: false,
description: 'ID of a contact assigned to the issues.'
argument :crm_organization_id, GraphQL::Types::String,
required: false,
description: 'ID of an organization assigned to the issues.'
end
def resolve_with_lookahead(**args)
return Issue.none if resource_parent.nil?
finder = IssuesFinder.new(current_user, prepare_finder_params(args))
continue_issue_resolve(resource_parent, finder, **args)
end
def ready?(**args)
args[:not] = args[:not].to_h if args[:not].present?
params_not_mutually_exclusive(args, mutually_exclusive_assignee_username_args)
params_not_mutually_exclusive(args, mutually_exclusive_milestone_args)
params_not_mutually_exclusive(args.fetch(:not, {}), mutually_exclusive_milestone_args)
params_not_mutually_exclusive(args, mutually_exclusive_release_tag_args)
super
end
class_methods do
def resolver_complexity(args, child_complexity:)
complexity = super
complexity += 2 if args[:labelName]
complexity
end
def accept_release_tag
argument :release_tag, [GraphQL::Types::String],
required: false,
description: "Release tag associated with the issue's milestone."
argument :release_tag_wildcard_id, Types::ReleaseTagWildcardIdEnum,
required: false,
description: 'Filter issues by release tag ID wildcard.'
end
end
private
def prepare_finder_params(args)
params = super(args)
params[:iids] ||= [params.delete(:iid)].compact if params[:iid]
params[:attempt_project_search_optimizations] = true if params[:search].present?
prepare_assignee_username_params(params)
prepare_release_tag_params(params)
params
end
def prepare_release_tag_params(args)
release_tag_wildcard = args.delete(:release_tag_wildcard_id)
return if release_tag_wildcard.blank?
args[:release_tag] ||= release_tag_wildcard
end
def prepare_assignee_username_params(args)
args[:assignee_username] = args.delete(:assignee_usernames) if args[:assignee_usernames].present?
args[:not][:assignee_username] = args[:not].delete(:assignee_usernames) if args.dig(:not, :assignee_usernames).present?
end
def mutually_exclusive_release_tag_args
[:release_tag, :release_tag_wildcard_id]
end
def mutually_exclusive_milestone_args
[:milestone_title, :milestone_wildcard_id]
end
def mutually_exclusive_assignee_username_args
[:assignee_usernames, :assignee_username]
end
def params_not_mutually_exclusive(args, mutually_exclusive_args)
if args.slice(*mutually_exclusive_args).compact.size > 1
arg_str = mutually_exclusive_args.map { |x| x.to_s.camelize(:lower) }.join(', ')
raise ::Gitlab::Graphql::Errors::ArgumentError, "only one of [#{arg_str}] arguments is allowed at the same time."
end
end
def resource_parent
# The project could have been loaded in batch by `BatchLoader`.
# At this point we need the `id` of the project to query for issues, so
# make sure it's loaded and not `nil` before continuing.
strong_memoize(:resource_parent) do
object.respond_to?(:sync) ? object.sync : object
end
end
end
|