Exception: GraphWeaver::QueryError
- 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
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#extensions ⇒ Object
readonly
Returns the value of attribute extensions.
Instance Method Summary collapse
-
#codes ⇒ Object
All non-nil error codes — handy for
codes.include?("THROTTLED"). -
#initialize(errors, data: nil, extensions: {}) ⇒ QueryError
constructor
A new instance of QueryError.
-
#to_h ⇒ Object
The machine side: every error with its path/code/extensions, plus the drift verdict — nest this straight into a JSON response.
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.
254 255 256 257 258 259 |
# File 'lib/graph_weaver/errors.rb', line 254 def initialize(errors, data: nil, extensions: {}) @errors = errors @data = data @extensions = extensions super(summary) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
252 253 254 |
# File 'lib/graph_weaver/errors.rb', line 252 def data @data end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
252 253 254 |
# File 'lib/graph_weaver/errors.rb', line 252 def errors @errors end |
#extensions ⇒ Object (readonly)
Returns the value of attribute extensions.
252 253 254 |
# File 'lib/graph_weaver/errors.rb', line 252 def extensions @extensions end |
Instance Method Details
#codes ⇒ Object
All non-nil error codes — handy for codes.include?("THROTTLED").
262 263 264 |
# File 'lib/graph_weaver/errors.rb', line 262 def codes errors.map(&:code).compact end |
#to_h ⇒ Object
The machine side: every error with its path/code/extensions, plus the drift verdict — nest this straight into a JSON response.
268 269 270 271 272 273 274 275 |
# File 'lib/graph_weaver/errors.rb', line 268 def to_h super.merge( "schema_stale" => schema_stale?, "codes" => codes, "errors" => errors.map(&:to_h), "extensions" => extensions, ) end |