summaryrefslogtreecommitdiff
path: root/app/graphql/resolvers/concerns/looks_ahead.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/resolvers/concerns/looks_ahead.rb')
-rw-r--r--app/graphql/resolvers/concerns/looks_ahead.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/app/graphql/resolvers/concerns/looks_ahead.rb b/app/graphql/resolvers/concerns/looks_ahead.rb
index 77a85edfba6..644b2a11460 100644
--- a/app/graphql/resolvers/concerns/looks_ahead.rb
+++ b/app/graphql/resolvers/concerns/looks_ahead.rb
@@ -15,12 +15,7 @@ module LooksAhead
end
def apply_lookahead(query)
- selection = node_selection
-
- includes = preloads.each.flat_map do |name, requirements|
- selection&.selects?(name) ? requirements : []
- end
- all_preloads = (unconditional_includes + includes).uniq
+ all_preloads = (unconditional_includes + filtered_preloads).uniq
return query if all_preloads.empty?
@@ -37,6 +32,14 @@ module LooksAhead
{}
end
+ def filtered_preloads
+ selection = node_selection
+
+ preloads.each.flat_map do |name, requirements|
+ selection&.selects?(name) ? requirements : []
+ end
+ end
+
def node_selection
return unless lookahead