Class: GraphQL::Backtrace

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/graphql/backtrace.rb,
lib/graphql/backtrace/table.rb,
lib/graphql/backtrace/traced_error.rb

Overview

Wrap unhandled errors with TracedError.

TracedError provides a GraphQL backtrace with arguments and return values. The underlying error is available as TracedError#cause.

Examples:

toggling backtrace annotation

class MySchema < GraphQL::Schema
  if Rails.env.development? || Rails.env.test?
    use GraphQL::Backtrace
  end
end

Defined Under Namespace

Classes: Table, TracedError

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, value: nil) ⇒ Backtrace

Returns a new instance of Backtrace.



27
28
29
# File 'lib/graphql/backtrace.rb', line 27

def initialize(context, value: nil)
  @table = Table.new(context, value: value)
end

Class Method Details

.use(schema_defn) ⇒ Object



23
24
25
# File 'lib/graphql/backtrace.rb', line 23

def self.use(schema_defn)
  schema_defn.using_backtrace = true
end

Instance Method Details

#inspectObject Also known as: to_s



31
32
33
# File 'lib/graphql/backtrace.rb', line 31

def inspect
  @table.to_table
end

#to_aObject



37
38
39
# File 'lib/graphql/backtrace.rb', line 37

def to_a
  @table.to_backtrace
end