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(supergraph:, request:, plan:, nonblocking: false) ⇒ Executor

Returns a new instance of Executor.



239
240
241
242
243
244
245
246
247
248
# File 'lib/graphql/stitching/executor.rb', line 239

def initialize(supergraph:, request:, plan:, nonblocking: false)
  @supergraph = supergraph
  @request = request
  @queue = plan["ops"]
  @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.



236
237
238
# File 'lib/graphql/stitching/executor.rb', line 236

def data
  @data
end

#errorsObject (readonly)

Returns the value of attribute errors.



236
237
238
# File 'lib/graphql/stitching/executor.rb', line 236

def errors
  @errors
end

#query_countObject

Returns the value of attribute query_count.



237
238
239
# File 'lib/graphql/stitching/executor.rb', line 237

def query_count
  @query_count
end

#requestObject (readonly)

Returns the value of attribute request.



236
237
238
# File 'lib/graphql/stitching/executor.rb', line 236

def request
  @request
end

#supergraphObject (readonly)

Returns the value of attribute supergraph.



236
237
238
# File 'lib/graphql/stitching/executor.rb', line 236

def supergraph
  @supergraph
end

Instance Method Details

#perform(raw: false) ⇒ Object



250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/graphql/stitching/executor.rb', line 250

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

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

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

  result
end