class GraphQL::Compatibility::LazyExecutionSpecification::LazySchema::LazyPush

Attributes

value[R]

Public Class Methods

new(ctx, value) click to toggle source
# File lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb, line 7
def initialize(ctx, value)
  if value == 13
    @value = nil
  elsif value == 14
    @value = GraphQL::ExecutionError.new("oops!")
  elsif value == 15
    @skipped = true
    @value = ctx.skip
  else
    @value = value
  end
  @context = ctx
  pushes = @context[:lazy_pushes] ||= []
  if !@skipped
    pushes << @value
  end
end

Public Instance Methods

push() click to toggle source
# File lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb, line 25
def push
  if @skipped
    @value
  else
    if @context[:lazy_pushes].include?(@value)
      @context[:lazy_instrumentation] && @context[:lazy_instrumentation] << "PUSH"
      @context[:pushes] << @context[:lazy_pushes]
      @context[:lazy_pushes] = []
    end
    # Something that _behaves_ like this object, but isn't registered lazy
    OpenStruct.new(value: @value)
  end
end