diff --git a/lib/graphiti/debugger.rb b/lib/graphiti/debugger.rb index 92165d35..8b81f8f7 100644 --- a/lib/graphiti/debugger.rb +++ b/lib/graphiti/debugger.rb @@ -36,7 +36,7 @@ def on_data(name, start, stop, id, payload) json[:sideload] = sideload.name end if params - query = "#{payload[:resource].class.name}.all(#{JSON.pretty_generate(params)}).data" + query = "#{payload[:resource].class.name}.#{payload[:action]}(#{JSON.pretty_generate(params)}).data" logs << [query, :cyan, true] logs << ["The error occurred when running the above query. Copy/paste it into a rake task or Rails console session to reproduce. Keep in mind you may have to set context.", :yellow, true] else @@ -64,7 +64,7 @@ def on_data(name, start, stop, id, payload) query = if sideload.class.scope_proc "#{payload[:resource].class.name}: Manual sideload via .scope" else - "#{payload[:resource].class.name}.all(#{params.inspect})" + "#{payload[:resource].class.name}.#{payload[:action]}(#{params.inspect})" end logs << [" #{query}", :cyan, true] json[:query] = query @@ -82,7 +82,7 @@ def on_data(name, start, stop, id, payload) title = "Top Level Data Retrieval (+ sideloads):" logs << [title, :green, true] json[:title] = title - query = "#{payload[:resource].class.name}.all(#{params.inspect})" + query = "#{payload[:resource].class.name}.#{payload[:action]}(#{params.inspect})" logs << [query, :cyan, true] json[:query] = query logs << ["Returned Models: #{results}"] if debug_models diff --git a/lib/graphiti/scope.rb b/lib/graphiti/scope.rb index a759a715..ae106bf1 100644 --- a/lib/graphiti/scope.rb +++ b/lib/graphiti/scope.rb @@ -129,9 +129,10 @@ def sideload_resource_proxies def broadcast_data opts = { resource: @resource, - params: @opts[:params], + params: @opts[:params] || @query.params, sideload: @opts[:sideload], - parent: @opts[:parent] + parent: @opts[:parent], + action: @query.action # Set once data is resolved within block # results: ... } diff --git a/lib/graphiti/util/cache_debug.rb b/lib/graphiti/util/cache_debug.rb index de42cf77..cc7c3783 100644 --- a/lib/graphiti/util/cache_debug.rb +++ b/lib/graphiti/util/cache_debug.rb @@ -12,7 +12,7 @@ def last_version end def name - "#{Graphiti.context[:object].request.method} #{Graphiti.context[:object].request.url}" + "#{Graphiti.context[:object]&.request&.method} #{Graphiti.context[:object]&.request&.url}" end def key