Sha256: 769a2d480e6a9b15a64df62c30e84ef385aa2105068e32ab45d0c313664350b8
Contents?: true
Size: 495 Bytes
Versions: 37
Compression:
Stored size: 495 Bytes
Contents
class Graphiti::Sideload::HasMany < Graphiti::Sideload def type :has_many end def load_params(parents, query) query.hash.tap do |hash| hash[:filter] ||= {} hash[:filter].merge!(base_filter(parents)) end end def base_filter(parents) { foreign_key => ids_for_parents(parents).join(',') } end private def child_map(children) children.group_by(&foreign_key) end def children_for(parent, map) map[parent.send(primary_key)] || [] end end
Version data entries
37 entries across 37 versions & 1 rubygems