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
|
# frozen_string_literal: true
module Resolvers
module Ci
class RunnersResolver < BaseResolver
include LooksAhead
include Gitlab::Graphql::Authorize::AuthorizeResource
type Types::Ci::RunnerType.connection_type, null: true
argument :active, ::GraphQL::Types::Boolean,
required: false,
description: 'Filter runners by `active` (true) or `paused` (false) status.',
deprecated: { reason: :renamed, replacement: 'paused', milestone: '14.8' }
argument :paused, ::GraphQL::Types::Boolean,
required: false,
description: 'Filter runners by `paused` (true) or `active` (false) status.'
argument :status, ::Types::Ci::RunnerStatusEnum,
required: false,
description: 'Filter runners by status.'
argument :type, ::Types::Ci::RunnerTypeEnum,
required: false,
description: 'Filter runners by type.'
argument :tag_list, [GraphQL::Types::String],
required: false,
description: 'Filter by tags associated with the runner (comma-separated or array).'
argument :search, GraphQL::Types::String,
required: false,
description: 'Filter by full token or partial text in description field.'
argument :sort, ::Types::Ci::RunnerSortEnum,
required: false,
description: 'Sort order of results.'
argument :upgrade_status, ::Types::Ci::RunnerUpgradeStatusEnum,
required: false,
description: 'Filter by upgrade status.'
def resolve_with_lookahead(**args)
apply_lookahead(
::Ci::RunnersFinder
.new(current_user: current_user, params: runners_finder_params(args))
.execute)
rescue Gitlab::Access::AccessDeniedError
handle_access_denied_error!
end
protected
def handle_access_denied_error!
raise_resource_not_available_error!
end
def runners_finder_params(params)
# Give preference to paused argument over the deprecated 'active' argument
paused = params.fetch(:paused, params[:active] ? !params[:active] : nil)
{
active: paused.nil? ? nil : !paused,
status_status: params[:status]&.to_s,
type_type: params[:type],
tag_name: params[:tag_list],
upgrade_status: params[:upgrade_status],
search: params[:search],
sort: params[:sort]&.to_s,
preload: false # we'll handle preloading ourselves
}.compact
.merge(parent_param)
end
def parent_param
return {} unless parent
raise "Unexpected parent type: #{parent.class}"
end
private
def parent
object.respond_to?(:sync) ? object.sync : object
end
def preloads
super.merge({
created_by: [:creator],
tag_list: [:tags]
})
end
end
end
end
Resolvers::Ci::RunnersResolver.prepend_mod
|