Class: BatchLoader::GraphQL
- Inherits:
-
Object
- Object
- BatchLoader::GraphQL
- Defined in:
- lib/batch_loader/graphql.rb
Defined Under Namespace
Classes: Wrapper
Class Method Summary collapse
Class Method Details
.instrument(type, field) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/batch_loader/graphql.rb', line 20 def self.instrument(type, field) old_resolve_proc = field.resolve_proc new_resolve_proc = ->(object, arguments, context) do result = old_resolve_proc.call(object, arguments, context) result.respond_to?(:__sync) ? BatchLoader::GraphQL::Wrapper.new(result) : result end field.redefine { resolve(new_resolve_proc) } end |
.use(schema_definition) ⇒ Object
15 16 17 18 |
# File 'lib/batch_loader/graphql.rb', line 15 def self.use(schema_definition) schema_definition.lazy_resolve(BatchLoader::GraphQL::Wrapper, :sync) schema_definition.instrument(:field, self) end |