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:, plan:, variables: {}, nonblocking: false) ⇒ Executor

Returns a new instance of Executor.



205
206
207
208
209
210
211
212
213
# File 'lib/graphql/stitching/executor.rb', line 205

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

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



202
203
204
# File 'lib/graphql/stitching/executor.rb', line 202

def data
  @data
end

#errorsObject (readonly)

Returns the value of attribute errors.



202
203
204
# File 'lib/graphql/stitching/executor.rb', line 202

def errors
  @errors
end

#query_countObject

Returns the value of attribute query_count.



203
204
205
# File 'lib/graphql/stitching/executor.rb', line 203

def query_count
  @query_count
end

#supergraphObject (readonly)

Returns the value of attribute supergraph.



202
203
204
# File 'lib/graphql/stitching/executor.rb', line 202

def supergraph
  @supergraph
end

#variablesObject (readonly)

Returns the value of attribute variables.



202
203
204
# File 'lib/graphql/stitching/executor.rb', line 202

def variables
  @variables
end

Instance Method Details

#perform(document = nil) ⇒ Object



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/graphql/stitching/executor.rb', line 215

def perform(document=nil)
  exec!

  result = {}
  result["data"] = @data if @data && @data.length > 0
  result["errors"] = @errors if @errors.length > 0

  if document && result["data"]
    GraphQL::Stitching::Shaper.new(
      schema: @supergraph.schema,
      document: document,
    ).perform!(result)
  else
    result
  end
end