Module: GraphQL::Backtrace::LegacyTracer
- Defined in:
- lib/graphql/backtrace/legacy_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 48 49 50 51 52 53 |
# File 'lib/graphql/backtrace/legacy_tracer.rb', line 8 def trace(key, ) case key when "lex", "parse" # No context here, don't have a query yet nil when "execute_multiplex", "analyze_multiplex" # No query context yet nil when "validate", "analyze_query", "execute_query", "execute_query_lazy" query = [:query] || [:queries].first push_data = query multiplex = query.multiplex when "execute_field", "execute_field_lazy" # The interpreter passes `query:`, legacy passes `context:` context = [:context] || ((q = [:query]) && q.context) push_data = context multiplex = context.query.multiplex else # Custom key, no backtrace data for this nil end if push_data multiplex.context[:last_graphql_backtrace_context] = push_data end if key == "execute_multiplex" begin yield rescue StandardError => err # This is an unhandled error from execution, # Re-raise it with a GraphQL trace. potential_context = [:multiplex].context[:last_graphql_backtrace_context] if potential_context.is_a?(GraphQL::Query::Context) || potential_context.is_a?(GraphQL::Query::Context::FieldResolutionContext) raise TracedError.new(err, potential_context) else raise end ensure [:multiplex].context.delete(:last_graphql_backtrace_context) end else yield end end |