Module: Datadog::AppSec::Contrib::GraphQL::AppSecTrace

Defined in:
lib/datadog/appsec/contrib/graphql/appsec_trace.rb

Overview

These methods will be called by the GraphQL runtime to send the variables to the WAF. We actually don’t need to create any span/trace.

Instance Method Summary collapse

Instance Method Details

#execute_multiplex(multiplex:) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/datadog/appsec/contrib/graphql/appsec_trace.rb', line 14

def execute_multiplex(multiplex:)
  return super unless Datadog::AppSec.enabled?

  gateway_multiplex = Gateway::Multiplex.new(multiplex)

  multiplex_return, multiplex_response = Instrumentation.gateway.push('graphql.multiplex', gateway_multiplex) do
    super
  end

  # Returns an error * the number of queries so that the entire multiplex is blocked
  if multiplex_response
    blocked_event = multiplex_response.find { |action, _options| action == :block }
    multiplex_return = AppSec::Response.graphql_response(gateway_multiplex) if blocked_event
  end

  multiplex_return
end