Module: GraphQL::Backtrace::Trace

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

Instance Method Summary collapse

Instance Method Details

#analyze_query(query:) ⇒ Object



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

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



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

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



41
42
43
44
# File 'lib/graphql/backtrace/trace.rb', line 41

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



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

def execute_multiplex(multiplex:)
  super
rescue StandardError => err
  # This is an unhandled error from execution,
  # Re-raise it with a GraphQL trace.
  potential_context = @__backtrace_last_context
  if potential_context.is_a?(GraphQL::Query::Context) ||
      potential_context.is_a?(Backtrace::Frame)
    raise TracedError.new(err, potential_context)
  else
    raise
  end
end

#execute_query(query:) ⇒ Object



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

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

#execute_query_lazy(query:, multiplex:) ⇒ Object



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

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

#initialize(*args, **kwargs, &block) ⇒ Object



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

def initialize(*args, **kwargs, &block)
  @__backtrace_contexts = {}
  @__backtrace_last_context = nil
  super
end

#validate(query:, validate:) ⇒ Object



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

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