Class: SolidusGraphqlApi::BatchLoader::HasMany
- Inherits:
-
SolidusGraphqlApi::BatchLoader
- Object
- SolidusGraphqlApi::BatchLoader
- SolidusGraphqlApi::BatchLoader::HasMany
- Defined in:
- lib/solidus_graphql_api/batch_loader/has_many.rb
Overview
A batch loader for has_many
associations.
Constant Summary
Constants inherited from SolidusGraphqlApi::BatchLoader
Instance Attribute Summary
Attributes inherited from SolidusGraphqlApi::BatchLoader
#object, #options, #reflection
Instance Method Summary collapse
Methods inherited from SolidusGraphqlApi::BatchLoader
Constructor Details
This class inherits a constructor from SolidusGraphqlApi::BatchLoader
Instance Method Details
#load ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/solidus_graphql_api/batch_loader/has_many.rb', line 7 def load graphql_loader_for(object.id, default_value: []) do |object_ids, loader| retrieve_records_for(object_ids).each do |associated_record| loader.call(associated_record.send(reflection.foreign_key)) do |memo| memo << associated_record end end end end |