Class: GraphqlMigrateExecution::DataloaderAll

Inherits:
Strategy
  • Object
show all
Defined in:
lib/graphql_migrate_execution/dataloader_all.rb

Overview

This field calls dataloader with some property of ‘object`. It can be migrated to use `dataload_all(…)` and `objects.map { |object| … }`.

“‘ruby # Previous: def my_field

dataload(Sources::GetThing, object.some_attribute)

end

# New: def self.my_field(objects, context)

context.dataload_all(Sources::GetThing, objects.map { |object| object.some_attribute })

end “‘

Direct Known Subclasses

DataloaderBatch

Constant Summary

Constants inherited from Strategy

Strategy::METHODS_TO_RENAME

Instance Method Summary collapse

Methods inherited from Strategy

#initialize, prefix_if_necessary, #run, strategy_name

Constructor Details

This class inherits a constructor from GraphqlMigrateExecution::Strategy

Instance Method Details

#cleanup(field_definition) ⇒ Object



24
25
26
# File 'lib/graphql_migrate_execution/dataloader_all.rb', line 24

def cleanup(field_definition)
  remove_resolver_method(field_definition)
end

#migrate(field_definition) ⇒ Object



19
20
21
22
# File 'lib/graphql_migrate_execution/dataloader_all.rb', line 19

def migrate(field_definition)
  inject_resolve_keyword(field_definition, :resolve_batch)
  inject_batch_dataloader_method(field_definition, [:request, :load], :dataload, "map")
end