blob: b090fdc49d4bfffb2e7d7a7027485ffd2cedcdf0 (
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
|
# frozen_string_literal: true
module Resolvers
class GroupsResolver < BaseResolver
type Types::GroupType, null: true
argument :include_parent_descendants, GraphQL::Types::Boolean,
required: false,
description: 'List of descendant groups of the parent group.',
default_value: true
argument :owned, GraphQL::Types::Boolean,
required: false,
description: 'Limit result to groups owned by authenticated user.'
argument :search, GraphQL::Types::String,
required: false,
description: 'Search query for group name or group full path.'
alias_method :parent, :object
def resolve(**args)
return [] unless parent.present?
find_groups(args)
end
private
# rubocop: disable CodeReuse/ActiveRecord
def find_groups(args)
GroupsFinder
.new(context[:current_user], args.merge(parent: parent))
.execute
.reorder('name ASC')
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
|