Method: Graphiti::Query#sideloads

Defined in:
lib/graphiti/query.rb

#sideloadsObject



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/graphiti/query.rb', line 85

def sideloads
  @sideloads ||= begin
    {}.tap do |hash|
      include_hash.each_pair do |key, sub_hash|
        sideload = @resource.class.sideload(key)

        if sideload || @resource.remote?
          sl_resource = resource_for_sideload(sideload)
          query_parents = parents + [self]
          sub_hash = sub_hash[:include] if sub_hash.key?(:include)
          hash[key] = Query.new(sl_resource, @params, key, sub_hash, query_parents)
        else
          handle_missing_sideload(key)
        end
      end
    end
  end
end