Class: GraphQL::Stitching::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/stitching/executor.rb

Defined Under Namespace

Classes: BoundarySource, RootSource

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request, nonblocking: false) ⇒ Executor

Returns a new instance of Executor.



11
12
13
14
15
16
17
18
19
20
# File 'lib/graphql/stitching/executor.rb', line 11

def initialize(request, nonblocking: false)
  @request = request
  @supergraph = request.supergraph
  @plan = request.plan
  @data = {}
  @errors = []
  @query_count = 0
  @exec_cycles = 0
  @dataloader = GraphQL::Dataloader.new(nonblocking: nonblocking)
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



8
9
10
# File 'lib/graphql/stitching/executor.rb', line 8

def data
  @data
end

#errorsObject (readonly)

Returns the value of attribute errors.



8
9
10
# File 'lib/graphql/stitching/executor.rb', line 8

def errors
  @errors
end

#planObject (readonly)

Returns the value of attribute plan.



8
9
10
# File 'lib/graphql/stitching/executor.rb', line 8

def plan
  @plan
end

#query_countObject

Returns the value of attribute query_count.



9
10
11
# File 'lib/graphql/stitching/executor.rb', line 9

def query_count
  @query_count
end

#requestObject (readonly)

Returns the value of attribute request.



8
9
10
# File 'lib/graphql/stitching/executor.rb', line 8

def request
  @request
end

#supergraphObject (readonly)

Returns the value of attribute supergraph.



8
9
10
# File 'lib/graphql/stitching/executor.rb', line 8

def supergraph
  @supergraph
end

Instance Method Details

#perform(raw: false) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/graphql/stitching/executor.rb', line 22

def perform(raw: false)
  exec!
  result = {}

  if @data && @data.length > 0
    result["data"] = raw ? @data : GraphQL::Stitching::Shaper.new(@request).perform!(@data)
  end

  if @errors.length > 0
    result["errors"] = @errors
  end

  result
end