summaryrefslogtreecommitdiff
path: root/app/graphql
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql')
-rw-r--r--app/graphql/resolvers/full_path_resolver.rb7
-rw-r--r--app/graphql/resolvers/merge_request_resolver.rb7
2 files changed, 8 insertions, 6 deletions
diff --git a/app/graphql/resolvers/full_path_resolver.rb b/app/graphql/resolvers/full_path_resolver.rb
index 8d3da33e8d2..0f1a64b6c58 100644
--- a/app/graphql/resolvers/full_path_resolver.rb
+++ b/app/graphql/resolvers/full_path_resolver.rb
@@ -11,10 +11,11 @@ module Resolvers
end
def model_by_full_path(model, full_path)
- BatchLoader.for(full_path).batch(key: "#{model.model_name.param_key}:full_path") do |full_paths, loader|
+ BatchLoader.for(full_path).batch(key: model) do |full_paths, loader, args|
# `with_route` avoids an N+1 calculating full_path
- results = model.where_full_path_in(full_paths).with_route
- results.each { |project| loader.call(project.full_path, project) }
+ args[:key].where_full_path_in(full_paths).with_route.each do |project|
+ loader.call(project.full_path, project)
+ end
end
end
end
diff --git a/app/graphql/resolvers/merge_request_resolver.rb b/app/graphql/resolvers/merge_request_resolver.rb
index b87c95217f7..d047ce9e3a1 100644
--- a/app/graphql/resolvers/merge_request_resolver.rb
+++ b/app/graphql/resolvers/merge_request_resolver.rb
@@ -14,9 +14,10 @@ module Resolvers
def resolve(iid:)
return unless project.present?
- BatchLoader.for(iid.to_s).batch(key: project.id) do |iids, loader|
- results = project.merge_requests.where(iid: iids)
- results.each { |mr| loader.call(mr.iid.to_s, mr) }
+ BatchLoader.for(iid.to_s).batch(key: project) do |iids, loader, args|
+ args[:key].merge_requests.where(iid: iids).each do |mr|
+ loader.call(mr.iid.to_s, mr)
+ end
end
end
# rubocop: enable CodeReuse/ActiveRecord