Skip to content

Commit

Permalink
fix: properly display .find vs .all in debugger statements
Browse files Browse the repository at this point in the history
  • Loading branch information
jkeen committed Apr 17, 2024
1 parent 661e3b5 commit d2a7a03
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/graphiti/debugger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions lib/graphiti/scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
}
Expand Down
2 changes: 1 addition & 1 deletion lib/graphiti/util/cache_debug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d2a7a03

Please sign in to comment.