Skip to content

Commit 51270c7

Browse files
committed
Fixing new_trace not using parent's trace_options
1 parent 7939e14 commit 51270c7

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lib/graphql/schema.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -988,9 +988,7 @@ def trace_options
988988
end
989989

990990
def new_trace(**options)
991-
if defined?(@trace_options)
992-
options = trace_options.merge(options)
993-
end
991+
options = trace_options.merge(options)
994992
trace_mode = if (target = options[:query] || options[:multiplex]) && target.context[:backtrace]
995993
:default_backtrace
996994
else

spec/graphql/schema_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,20 @@ module NewTrace2
359359
assert_kind_of NewTrace2, child_trace
360360
assert_kind_of GraphQL::Tracing::Trace, child_trace
361361
end
362+
363+
it "returns an instance of the parent configured trace_class with trace_options" do
364+
parent_schema = Class.new(GraphQL::Schema) do
365+
trace_with NewTrace1, a: 1
366+
end
367+
368+
child_schema = Class.new(parent_schema) do
369+
end
370+
371+
child_trace = child_schema.new_trace
372+
assert_equal({a: 1}, child_trace.trace_opts)
373+
assert_kind_of NewTrace1, child_trace
374+
assert_kind_of GraphQL::Tracing::Trace, child_trace
375+
end
362376
end
363377

364378
describe ".possible_types" do

0 commit comments

Comments
 (0)