Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/graphql/tracing/perfetto_trace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ def payload_to_debug(k, v, iid: nil, intern_value: false)
when GraphQL::Schema::InputObject
payload_to_debug(k, v.to_h, iid: iid, intern_value: intern_value)
else
class_name_iid = @interned_da_string_values[v.class.name]
class_name_iid = @interned_da_string_values[(v.class.name || "(anonymous)")]
da = [
debug_annotation(DA_DEBUG_INSPECT_CLASS_IID, :string_value_iid, class_name_iid),
]
Expand Down
9 changes: 9 additions & 0 deletions spec/graphql/tracing/perfetto_trace_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class SecretInput < GraphQL::Schema::InputObject
class SecretThing < GraphQL::Schema::Object
field :greeting, String
end

field :secret_field, SecretThing do
argument :cipher, String, required: false
argument :password, String, required: false
Expand All @@ -128,6 +129,7 @@ def secret_field(cipher: nil, password: nil, input: nil)
{
greeting: "Hello!",
cipher: cipher || "FALLBACK_CIPHER",
anon: Class.new.new,
password: password || (input ? input[0][0][:password] : "FALLBACK_PASSWORD"),
}
end
Expand Down Expand Up @@ -185,6 +187,13 @@ def self.detailed_trace?(q)
check_snapshot(data, "example-rails-#{Rails::VERSION::MAJOR}-#{Rails::VERSION::MINOR}.json")
end

it "replaces nil class name with (anonymous)" do
query_str = 'query getStuff { secretField { greeting } }'
res = PerfettoSchema.execute(query_str)
json = res.context.query.current_trace.write(file: nil, debug_json: true)
assert trace_includes?(json, "(anonymous)")
end

it "filters params with Rails.application.config.filter_parameters" do
query_str = 'query getStuff { secretField(cipher: "abcdef") { greeting } }'
res = PerfettoSchema.execute(query_str)
Expand Down
Loading