Module: GraphQL::Backtrace::Tracer
- Defined in:
- lib/graphql/backtrace/tracer.rb
Class Method Summary collapse
-
.trace(key, metadata) ⇒ Object
Implement the Tracing API.
Class Method Details
.trace(key, metadata) ⇒ Object
Implement the Tracing API.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/graphql/backtrace/tracer.rb', line 8 def trace(key, ) push_data = case key when "lex", "parse" # No context here, don't have a query yet nil when "execute_multiplex", "analyze_multiplex" [:multiplex].queries when "validate", "analyze_query", "execute_query", "execute_query_lazy" [:query] || [:queries] when "execute_field", "execute_field_lazy" [:context] else # Custom key, no backtrace data for this nil end if push_data execution_context = Thread.current[:graphql_execution_context] ||= [] if key == "execute_multiplex" execution_context.clear execution_context.push(push_data) begin yield rescue StandardError => err # This is an unhandled error from execution, # Re-raise it with a GraphQL trace. raise TracedError.new(err, execution_context.last) ensure execution_context.clear end else execution_context.push(push_data) res = yield execution_context.pop res end else yield end end |