Exception: GraphWeaver::QueryError

Inherits:
Error
  • Object
show all
Extended by:
T::Sig
Includes:
ErrorFiltering
Defined in:
lib/graph_weaver/errors.rb

Overview

Raised when a GraphQL response carried top-level errors and the caller demanded data (Response#data!, or the one-shot GraphWeaver.execute). Carries the structured errors, any partial data, and top-level extensions (cost/throttle metadata).

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ErrorFiltering

#each_error, #entity_id, #errors_at, #errors_by_field, #report, #schema_stale?

Constructor Details

#initialize(errors, data: nil, extensions: {}) ⇒ QueryError

Returns a new instance of QueryError.



338
339
340
341
342
343
# File 'lib/graph_weaver/errors.rb', line 338

def initialize(errors, data: nil, extensions: {})
  @errors = errors
  @data = data
  @extensions = extensions
  super(summary)
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



326
327
328
# File 'lib/graph_weaver/errors.rb', line 326

def data
  @data
end

#errorsObject (readonly)

Returns the value of attribute errors.



323
324
325
# File 'lib/graph_weaver/errors.rb', line 323

def errors
  @errors
end

#extensionsObject (readonly)

Returns the value of attribute extensions.



329
330
331
# File 'lib/graph_weaver/errors.rb', line 329

def extensions
  @extensions
end

Instance Method Details

#codesObject



347
348
349
# File 'lib/graph_weaver/errors.rb', line 347

def codes
  errors.filter_map(&:code)
end

#to_hObject



354
355
356
357
358
359
360
361
# File 'lib/graph_weaver/errors.rb', line 354

def to_h
  super.merge(
    "schema_stale" => schema_stale?,
    "codes" => codes,
    "errors" => errors.map(&:to_h),
    "extensions" => extensions,
  )
end