NoMethodError/nil-ref when using persisted queries
ktalley opened this issue · 2 comments
We recently switched to using persisted queries using this Rails gem.
We now get a nil-ref error on this line:
https://github.com/jetruby/graphql-rails_logger/blob/master/lib/graphql/rails_logger/subscriber.rb#L42
Could not log "start_processing.action_controller" event. NoMethodError: undefined method 'lines' for nil:NilClass
This is most likely caused by the fact the persisted query doesn't send along a query
param, just a hash that the backend maps to the query. I think adding a check to this method to make sure data['query'].present?
before trying to format should fix it.
Here's an example request:
https://localhost:3000/api/graphql?operationName=appBootstrap&variables={"userId":"abcd1234"}&extensions={"persistedQuery":{"version":1,"sha256Hash":"832db74c644f9a1e8123be4a6f7e19ade39fc9c590c4a75c7a7ffb2f2ab55948"}}
Thanks in advance!
Hey @ktalley
I do not work with ruby and rails for a long time, but I'd happy to apply the fix if you prepare a PR :)
pushed to rubygems 🎉