Method: GraphQL::Tracing::PlatformTracing.use

Defined in:
lib/graphql/tracing/platform_tracing.rb

.use(schema_defn, options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/graphql/tracing/platform_tracing.rb', line 75

def self.use(schema_defn, options = {})
  if options[:legacy_tracing]
    tracer = self.new(**options)
    schema_defn.tracer(tracer)
  else
    tracing_name = self.name.split("::").last
    trace_name = tracing_name.sub("Tracing", "Trace")
    if GraphQL::Tracing.const_defined?(trace_name, false)
      trace_module = GraphQL::Tracing.const_get(trace_name)
      warn("`use(#{self.name})` is deprecated, use the equivalent `trace_with(#{trace_module.name})` instead. More info: https://graphql-ruby.org/queries/tracing.html")
      schema_defn.trace_with(trace_module, **options)
    else
      warn("`use(#{self.name})` and `Tracing::PlatformTracing` are deprecated. Use a `trace_with(...)` module instead. More info: https://graphql-ruby.org/queries/tracing.html. Please open an issue on the GraphQL-Ruby repo if you want to discuss further!")
      tracer = self.new(**options)
    schema_defn.tracer(tracer, silence_deprecation_warning: true)
    end
  end
end