summaryrefslogtreecommitdiff
path: root/lib/gitlab/graphql/loaders/full_path_model_loader.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/graphql/loaders/full_path_model_loader.rb')
-rw-r--r--lib/gitlab/graphql/loaders/full_path_model_loader.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/gitlab/graphql/loaders/full_path_model_loader.rb b/lib/gitlab/graphql/loaders/full_path_model_loader.rb
index 7f9013c6e4c..2ea3fa71d5e 100644
--- a/lib/gitlab/graphql/loaders/full_path_model_loader.rb
+++ b/lib/gitlab/graphql/loaders/full_path_model_loader.rb
@@ -16,8 +16,11 @@ module Gitlab
def find
BatchLoader::GraphQL.for(full_path).batch(key: model_class) do |full_paths, loader, args|
+ scope = args[:key]
+ # this logic cannot be placed in the NamespaceResolver due to N+1
+ scope = scope.without_project_namespaces if scope == Namespace
# `with_route` avoids an N+1 calculating full_path
- args[:key].where_full_path_in(full_paths).with_route.each do |model_instance|
+ scope.where_full_path_in(full_paths).with_route.each do |model_instance|
loader.call(model_instance.full_path.downcase, model_instance)
end
end