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, calls_gitaly!, complexity, complexity_multiplier, #current_user, field_options, last, #object, #offset_pagination, 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!

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Instance Method Details

#authorize!(usernames) ⇒ Object


49
50
51
# File 'app/graphql/resolvers/users_resolver.rb', line 49

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

#ready?(**args) ⇒ Boolean

Returns:

  • (Boolean)

37
38
39
40
41
42
43
44
45
46
47
# File 'app/graphql/resolvers/users_resolver.rb', line 37

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) ⇒ Object


31
32
33
34
35
# File 'app/graphql/resolvers/users_resolver.rb', line 31

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

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