Class: Resolvers::UsersResolver

Inherits:
BaseResolver
  • Object
show all
Includes:
Gitlab::Graphql::Authorize::AuthorizeResource
Defined in:
app/graphql/resolvers/users_resolver.rb

Constant Summary

Constants included from Gitlab::Graphql::Authorize::AuthorizeResource

Gitlab::Graphql::Authorize::AuthorizeResource::ConfigurationError, Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR

Instance Method Summary collapse

Methods included from Gitlab::Graphql::Authorize::AuthorizeResource

#authorized_find!, #authorized_resource?, #find_object, #raise_resource_not_available_error!

Methods inherited from BaseResolver

as_single, authorization, authorized?, before_connection_authorization, before_connection_authorization_block, calculate_ext_conn_complexity, calls_gitaly!, calls_gitaly?, complexity, complexity_multiplier, #current_user, last, #object, #offset_pagination, requires_argument!, requires_argument?, resolver_complexity, #select_result, single, #single?, single_definition_blocks, singular_type, when_single

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Instance Method Details

#authorize!(usernames) ⇒ Object



67
68
69
# File 'app/graphql/resolvers/users_resolver.rb', line 67

def authorize!(usernames)
  raise_resource_not_available_error! unless context[:current_user].present?
end

#ready?(**args) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
58
59
60
61
62
63
64
65
# File 'app/graphql/resolvers/users_resolver.rb', line 55

def ready?(**args)
  args = { ids: nil, usernames: nil }.merge!(args)

  return super if args.values.compact.blank?

  if args[:usernames].present? && args[:ids].present?
    raise Gitlab::Graphql::Errors::ArgumentError, 'Provide either a list of usernames or ids'
  end

  super
end

#resolve(ids: nil, usernames: nil, sort: nil, search: nil, admins: nil, humans: nil, active: nil, group_id: nil) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'app/graphql/resolvers/users_resolver.rb', line 44

def resolve(ids: nil, usernames: nil, sort: nil, search: nil, admins: nil, humans: nil, active: nil, group_id: nil)
  authorize!(usernames)

  group = group_id ? find_authorized_group!(group_id) : nil

  ::UsersFinder.new(
    context[:current_user],
    finder_params(ids, usernames, sort, search, admins, group, humans, active)
  ).execute
end