Module: LooksAhead

Instance Method Summary collapse

Instance Method Details

#apply_lookahead(query) ⇒ Object



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

def apply_lookahead(query)
  all_preloads = (unconditional_includes + filtered_preloads).uniq

  return query if all_preloads.empty?

  query.preload(*all_preloads) # rubocop: disable CodeReuse/ActiveRecord
end

#resolve(**args) ⇒ Object



11
12
13
14
15
# File 'app/graphql/resolvers/concerns/looks_ahead.rb', line 11

def resolve(**args)
  self.lookahead = args.delete(:lookahead)

  resolve_with_lookahead(**args)
end