2021-11-11 11:23:49 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Resolvers
|
|
|
|
module Users
|
|
|
|
class GroupsResolver < BaseResolver
|
2021-12-11 22:18:48 +05:30
|
|
|
include ResolvesGroups
|
2021-11-11 11:23:49 +05:30
|
|
|
include Gitlab::Graphql::Authorize::AuthorizeResource
|
|
|
|
|
|
|
|
type Types::GroupType.connection_type, null: true
|
|
|
|
|
|
|
|
authorize :read_user_groups
|
|
|
|
authorizes_object!
|
|
|
|
|
|
|
|
argument :permission_scope,
|
|
|
|
::Types::PermissionTypes::GroupEnum,
|
|
|
|
required: false,
|
|
|
|
description: 'Filter by permissions the user has on groups.'
|
2022-04-04 11:22:00 +05:30
|
|
|
argument :search, GraphQL::Types::String,
|
|
|
|
required: false,
|
|
|
|
description: 'Search by group name or path.'
|
2021-11-11 11:23:49 +05:30
|
|
|
|
|
|
|
before_connection_authorization do |nodes, current_user|
|
2021-12-11 22:18:48 +05:30
|
|
|
Preloaders::GroupPolicyPreloader.new(nodes, current_user).execute
|
2021-11-11 11:23:49 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
def resolve_groups(**args)
|
|
|
|
Groups::UserGroupsFinder.new(current_user, object, args).execute
|
2021-11-11 11:23:49 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Resolvers::Users::GroupsResolver.prepend_mod_with('Resolvers::Users::GroupsResolver')
|