Class: Resolvers::NamespaceProjectsResolver

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseResolver

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

Class Method Details

.resolver_complexity(args, child_complexity:) ⇒ Object


39
40
41
42
# File 'app/graphql/resolvers/namespace_projects_resolver.rb', line 39

def self.resolver_complexity(args, child_complexity:)
  complexity = super
  complexity + 10
end

Instance Method Details

#resolve(include_subgroups:, sort:, search:) ⇒ Object


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/graphql/resolvers/namespace_projects_resolver.rb', line 22

def resolve(include_subgroups:, sort:, search:)
  # The namespace could have been loaded in batch by `BatchLoader`.
  # At this point we need the `id` or the `full_path` of the namespace
  # to query for projects, so make sure it's loaded and not `nil` before continuing.
  return Project.none if namespace.nil?

  query = include_subgroups ? namespace.all_projects.with_route : namespace.projects.with_route

  return query unless search.present?

  if sort == :similarity
    query.sorted_by_similarity_desc(search, include_in_select: true).merge(Project.search(search))
  else
    query.merge(Project.search(search))
  end
end