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.



212
213
214
215
216
217
218
219
220
221
# File 'lib/graphql/stitching/executor.rb', line 212

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.



209
210
211
# File 'lib/graphql/stitching/executor.rb', line 209

def data
  @data
end

#errorsObject (readonly)

Returns the value of attribute errors.



209
210
211
# File 'lib/graphql/stitching/executor.rb', line 209

def errors
  @errors
end

#query_countObject

Returns the value of attribute query_count.



210
211
212
# File 'lib/graphql/stitching/executor.rb', line 210

def query_count
  @query_count
end

#requestObject (readonly)

Returns the value of attribute request.



209
210
211
# File 'lib/graphql/stitching/executor.rb', line 209

def request
  @request
end

#supergraphObject (readonly)

Returns the value of attribute supergraph.



209
210
211
# File 'lib/graphql/stitching/executor.rb', line 209

def supergraph
  @supergraph
end

Instance Method Details

#perform(raw: false) ⇒ Object



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/graphql/stitching/executor.rb', line 223

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