Class: Resolvers::UserResolver

Inherits:
BaseResolver
  • Object
show all
Defined in:
app/graphql/resolvers/user_resolver.rb

Instance Method Summary collapse

Methods inherited from BaseResolver

as_single, complexity, complexity_multiplier, #current_user, field_options, last, #object, #offset_pagination, requires_argument!, resolver_complexity, #select_result, single, #single?, single_definition_blocks, singular_type, #synchronized_object, when_single

Methods included from Gitlab::Utils::Override

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

Methods included from Gitlab::Graphql::GlobalIDCompatibility

#coerce_global_id_arguments!

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Instance Method Details

#ready?(id: nil, username: nil) ⇒ Boolean

Returns:

  • (Boolean)

17
18
19
20
21
22
23
# File 'app/graphql/resolvers/user_resolver.rb', line 17

def ready?(id: nil, username: nil)
  unless id.present? ^ username.present?
    raise Gitlab::Graphql::Errors::ArgumentError, 'Provide either a single username or id'
  end

  super
end

#resolve(id: nil, username: nil) ⇒ Object


25
26
27
28
29
30
31
# File 'app/graphql/resolvers/user_resolver.rb', line 25

def resolve(id: nil, username: nil)
  if id
    GitlabSchema.object_from_id(id, expected_type: User)
  else
    batch_load(username)
  end
end