diff --git a/lib/graphql/tracing/notifications_trace.rb b/lib/graphql/tracing/notifications_trace.rb index 520c3adb507..6c592ba9c8e 100644 --- a/lib/graphql/tracing/notifications_trace.rb +++ b/lib/graphql/tracing/notifications_trace.rb @@ -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 diff --git a/spec/graphql/tracing/active_support_notifications_trace_spec.rb b/spec/graphql/tracing/active_support_notifications_trace_spec.rb index 9d5bd338171..2823d3c249c 100644 --- a/spec/graphql/tracing/active_support_notifications_trace_spec.rb +++ b/spec/graphql/tracing/active_support_notifications_trace_spec.rb @@ -23,10 +23,12 @@ 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 @@ -34,6 +36,14 @@ def nameable 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 @@ -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 = [ @@ -51,7 +61,6 @@ def nameable "validate.graphql", "analyze.graphql", "authorized.graphql", - "execute_field.graphql", "dataloader_source.graphql", "execute_field.graphql", "resolve_type.graphql",