2021-07-21 08:09:35 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Resolvers
|
|
|
|
class GroupsResolver < BaseResolver
|
2021-11-11 07:10:41 -05:00
|
|
|
include ResolvesGroups
|
|
|
|
|
2021-07-21 08:09:35 -04:00
|
|
|
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
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2021-11-11 07:10:41 -05:00
|
|
|
def resolve_groups(args)
|
|
|
|
return Group.none unless parent.present?
|
|
|
|
|
2021-07-21 08:09:35 -04:00
|
|
|
GroupsFinder
|
|
|
|
.new(context[:current_user], args.merge(parent: parent))
|
|
|
|
.execute
|
2022-04-05 20:08:33 -04:00
|
|
|
.reorder(name: :asc)
|
2021-07-21 08:09:35 -04:00
|
|
|
end
|
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
|
|
|
end
|
|
|
|
end
|