Module: GraphQL::Backtrace::Trace

Defined in:
lib/graphql/backtrace/trace.rb

Instance Method Summary collapse

Instance Method Details

#analyze_query(query:) ⇒ Object



12
13
14
15
16
17
# File 'lib/graphql/backtrace/trace.rb', line 12

def analyze_query(query:)
  if query.multiplex # missing for stand-alone static validation
    push_query_backtrace_context(query)
  end
  super
end

#execute_field(field:, query:, ast_node:, arguments:, object:) ⇒ Object



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

def execute_field(field:, query:, ast_node:, arguments:, object:)
  push_field_backtrace_context(field, query, ast_node, arguments, object)
  super
end

#execute_field_lazy(field:, query:, ast_node:, arguments:, object:) ⇒ Object



35
36
37
38
# File 'lib/graphql/backtrace/trace.rb', line 35

def execute_field_lazy(field:, query:, ast_node:, arguments:, object:)
  push_field_backtrace_context(field, query, ast_node, arguments, object)
  super
end

#execute_multiplex(multiplex:) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/graphql/backtrace/trace.rb', line 40

def execute_multiplex(multiplex:)
  super
rescue StandardError => err
  # This is an unhandled error from execution,
  # Re-raise it with a GraphQL trace.
  multiplex_context = multiplex.context
  potential_context = multiplex_context[:last_graphql_backtrace_context]

  if potential_context.is_a?(GraphQL::Query::Context) ||
      potential_context.is_a?(Backtrace::Frame)
    raise TracedError.new(err, potential_context)
  else
    raise
  end
ensure
  multiplex_context = multiplex.context
  multiplex_context.delete(:graphql_backtrace_contexts)
  multiplex_context.delete(:last_graphql_backtrace_context)
end

#execute_query(query:) ⇒ Object



19
20
21
22
# File 'lib/graphql/backtrace/trace.rb', line 19

def execute_query(query:)
  push_query_backtrace_context(query)
  super
end

#execute_query_lazy(query:, multiplex:) ⇒ Object



24
25
26
27
28
# File 'lib/graphql/backtrace/trace.rb', line 24

def execute_query_lazy(query:, multiplex:)
  query ||= multiplex.queries.first
  push_query_backtrace_context(query)
  super
end

#validate(query:, validate:) ⇒ Object



5
6
7
8
9
10
# File 'lib/graphql/backtrace/trace.rb', line 5

def validate(query:, validate:)
  if query.multiplex
    push_query_backtrace_context(query)
  end
  super
end