Class: Desiru::GraphQL::BatchLoader
- Inherits:
-
GraphQL::Dataloader::Source
- Object
- GraphQL::Dataloader::Source
- Desiru::GraphQL::BatchLoader
- Defined in:
- lib/desiru/graphql/batch_loader.rb
Overview
GraphQL-compatible batch loader that integrates with GraphQL’s lazy execution
Instance Method Summary collapse
-
#fetch(inputs_array) ⇒ Object
Fetch implementation for GraphQL::Dataloader.
-
#initialize(module_instance) ⇒ BatchLoader
constructor
A new instance of BatchLoader.
Constructor Details
#initialize(module_instance) ⇒ BatchLoader
Returns a new instance of BatchLoader.
9 10 11 12 |
# File 'lib/desiru/graphql/batch_loader.rb', line 9 def initialize(module_instance) super() @module_instance = module_instance end |
Instance Method Details
#fetch(inputs_array) ⇒ Object
Fetch implementation for GraphQL::Dataloader
15 16 17 18 19 20 21 22 23 |
# File 'lib/desiru/graphql/batch_loader.rb', line 15 def fetch(inputs_array) if @module_instance.respond_to?(:batch_forward) # Use batch processing if available @module_instance.batch_forward(inputs_array) else # Fall back to individual processing inputs_array.map { |inputs| @module_instance.call(inputs) } end end |