Module: GraphQL::Models::HashCombiner

Defined in:
lib/graphql/models/hash_combiner.rb

Class Method Summary collapse

Class Method Details

.combine(hashes) ⇒ Object

Takes a set of hashes that represent conditions, and combines them into the smallest number of hashes



5
6
7
8
9
# File 'lib/graphql/models/hash_combiner.rb', line 5

def combine(hashes)
  # Group the hashes by keys. If they are querying different columns, they can't be combined
  by_keys = hashes.group_by { |h| h.keys.sort }
  by_keys.map { |keys, values| combine_core(values, keys) }.flatten
end