blob: dcd2f2655730b980932ba7daa4af47a72e03aab5 (
plain)
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
|
# frozen_string_literal: true
module BoardItemFilterable
extend ActiveSupport::Concern
private
def item_filters(args, resource_parent)
filters = args.to_h
set_filter_values(filters)
if filters[:not]
set_filter_values(filters[:not])
end
if filters[:or]
if ::Feature.disabled?(:or_issuable_queries, resource_parent)
raise ::Gitlab::Graphql::Errors::ArgumentError,
"'or' arguments are only allowed when the `or_issuable_queries` feature flag is enabled."
end
rewrite_param_name(filters[:or], :author_usernames, :author_username)
rewrite_param_name(filters[:or], :assignee_usernames, :assignee_username)
rewrite_param_name(filters[:or], :label_names, :label_name)
end
filters
end
def set_filter_values(filters)
filter_by_assignee(filters)
end
def filter_by_assignee(filters)
if filters[:assignee_username] && filters[:assignee_wildcard_id]
raise ::Gitlab::Graphql::Errors::ArgumentError, 'Incompatible arguments: assigneeUsername, assigneeWildcardId.'
end
if filters[:assignee_wildcard_id]
filters[:assignee_id] = filters.delete(:assignee_wildcard_id)
end
end
def rewrite_param_name(filters, old_name, new_name)
filters[new_name] = filters.delete(old_name) if filters[old_name].present?
end
end
::BoardItemFilterable.prepend_mod_with('Resolvers::BoardItemFilterable')
|