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
4 changes: 3 additions & 1 deletion lib/graphql/tracing/notifications_trace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ def dataloader_fiber_yield(source)

def dataloader_fiber_resume(source)
prev_ev = Fiber[PREVIOUS_EV_KEY]
begin_notifications_event(prev_ev.name, prev_ev.payload)
if prev_ev
begin_notifications_event(prev_ev.name, prev_ev.payload)
end
super
end

Expand Down
19 changes: 14 additions & 5 deletions spec/graphql/tracing/active_support_notifications_trace_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,27 @@ class Thing < GraphQL::Schema::Object
end

class Query < GraphQL::Schema::Object
field :nameable, Nameable
field :nameable, Nameable do
argument :id, ID, loads: Thing, as: :thing
end

def nameable
dataload(ThingSource, 1)
def nameable(thing:)
thing
end
end

query(Query)
trace_with GraphQL::Tracing::ActiveSupportNotificationsTrace
use GraphQL::Dataloader
orphan_types(Thing)

def self.object_from_id(id, ctx)
ctx.dataloader.with(ThingSource).load(id)
end

def self.resolve_type(_abs, _obj, _ctx)
Thing
end
end

it "emits tracing info" do
Expand All @@ -42,7 +52,7 @@ def nameable
events << [name, payload]
}
ActiveSupport::Notifications.subscribed(callback) do
AsnSchema.execute("{ nameable { name } }")
AsnSchema.execute("{ nameable(id: 1) { name } }")
end

expected_names = [
Expand All @@ -51,7 +61,6 @@ def nameable
"validate.graphql",
"analyze.graphql",
"authorized.graphql",
"execute_field.graphql",
"dataloader_source.graphql",
"execute_field.graphql",
"resolve_type.graphql",
Expand Down