Module: GraphQL::Compatibility::LazyExecutionSpecification::LazySchema::LazyInstrumentation

Defined in:
lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb

Class Method Summary collapse

Class Method Details

.instrument(type, field) ⇒ Object


56
57
58
59
60
61
62
63
64
65
# File 'lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb', line 56

def self.instrument(type, field)
  prev_lazy_resolve = field.lazy_resolve_proc
  field.redefine {
    lazy_resolve ->(o, a, c) {
      result = prev_lazy_resolve.call(o, a, c)
      c[:lazy_instrumentation] && c[:lazy_instrumentation].push("#{type.name}.#{field.name}: #{o.value}")
      result
    }
  }
end