Class: GraphQL::Compatibility::LazyExecutionSpecification::LazySchema::LazyPush

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ctx, value) ⇒ LazyPush

Returns a new instance of LazyPush.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb', line 8

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



7
8
9
# File 'lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb', line 7

def value
  @value
end

Instance Method Details

#pushObject



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb', line 26

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
    self
  end
end