Class: GraphQL::Schema::MiddlewareChain

Inherits:
Object
  • Object
show all
Extended by:
Delegate
Defined in:
lib/graphql/schema/middleware_chain.rb

Overview

Given #steps and arguments, call steps in order, passing (*arguments, next_step).

Steps should call next_step.call to continue the chain, or not call it to stop the chain.

Defined Under Namespace

Classes: MiddlewareWrapper

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Delegate

def_delegators

Constructor Details

#initialize(steps: [], final_step: nil) ⇒ MiddlewareChain



13
14
15
16
# File 'lib/graphql/schema/middleware_chain.rb', line 13

def initialize(steps: [], final_step: nil)
  @steps = steps
  @final_step = final_step
end

Instance Attribute Details

#final_stepArray<#call(*args)> (readonly)



11
12
13
# File 'lib/graphql/schema/middleware_chain.rb', line 11

def final_step
  @final_step
end

#stepsArray<#call(*args)> (readonly)



11
12
13
# File 'lib/graphql/schema/middleware_chain.rb', line 11

def steps
  @steps
end

Instance Method Details

#<<(callable) ⇒ Object



25
26
27
# File 'lib/graphql/schema/middleware_chain.rb', line 25

def <<(callable)
  add_middleware(callable)
end

#==(other) ⇒ Object



33
34
35
# File 'lib/graphql/schema/middleware_chain.rb', line 33

def ==(other)
  steps == other.steps && final_step == other.final_step
end

#initialize_copy(other) ⇒ Object



18
19
20
21
# File 'lib/graphql/schema/middleware_chain.rb', line 18

def initialize_copy(other)
  super
  @steps = other.steps.dup
end

#invoke(arguments) ⇒ Object



37
38
39
# File 'lib/graphql/schema/middleware_chain.rb', line 37

def invoke(arguments)
  invoke_core(0, arguments)
end

#push(callable) ⇒ Object



29
30
31
# File 'lib/graphql/schema/middleware_chain.rb', line 29

def push(callable)
  add_middleware(callable)
end