I use a ruby app with the shopify gem (version 9.0.2)
Everything worked well, until recently, when suddenly it can't parse my GraphQL call on Heroku
But when I am doing the same process locally, it works
For example, on both : -I am initializing the ShopifyAPI with the credentials, the api_version
-I do the following request
query_variables = {'gid' => gid}
query_str = <<-'GRAPHQL'
query($gid: ID!) {
product(id: $gid) {
id
}
}
GRAPHQL
-After that I initialize the client :
client = ShopifyAPI::GraphQL.client
query_graph_ql = client.parse(query_str)
Locally it works well, but on Heroku I have the following error
"NoMethodError (undefined method `fields' for nil:NilClass)"
and before a couple of months, it worked well on Heroku as well
It seems to come from GraphQL itself, but i don't understand why this error appeared As if it wasn't correctly initialize on Heroku
It seems it's not link to my shop, since I tried on other where i didn't make any changes and it still does not work
Any idea from where the error come from ?
I tried : Making a Shopify GraphQL call on Heroku Expected : receiving my data Resulted : GraphQL Error : NoMethodError (undefined method `fields' for nil:NilClass)
Edit: I have no problem with the REST API
Edit2 : The Backtrace in rails console (with heroku run rails c) :
app/vendor/bundle/ruby/2.6.0/gems/graphql-client-0.19.0/lib/graphql/client/document_types.rb:62:in `rescue in analyze_types'
/app/vendor/bundle/ruby/2.6.0/gems/graphql-client-0.19.0/lib/graphql/client/document_types.rb:45:in `analyze_types'
/app/vendor/bundle/ruby/2.6.0/gems/graphql-client-0.19.0/lib/graphql/client.rb:189:in `parse'
/app/lib/utilities/graphql.rb:29:in `query_shopify'
/app/lib/utilities/graphql.rb:368:in `get_product_by_id'
(irb):4:in `irb_binding'
/app/vendor/ruby-2.6.6/lib/ruby/2.6.0/irb/workspace.rb:85:in `eval'
/app/vendor/ruby-2.6.6/lib/ruby/2.6.0/irb/workspace.rb:85:in `evaluate'
/app/vendor/ruby-2.6.6/lib/ruby/2.6.0/irb/context.rb:385:in `evaluate'
/app/vendor/ruby-2.6.6/lib/ruby/2.6.0/irb.rb:493:in `block (2 levels) in eval_input'
/app/vendor/ruby-2.6.6/lib/ruby/2.6.0/irb.rb:647:in `signal_status'
/app/vendor/ruby-2.6.6/lib/ruby/2.6.0/irb.rb:490:in `block in eval_input'
/app/vendor/ruby-2.6.6/lib/ruby/2.6.0/irb/ruby-lex.rb:246:in `block (2 levels) in each_top_level_statement'
/app/vendor/ruby-2.6.6/lib/ruby/2.6.0/irb/ruby-lex.rb:232:in `loop'
/app/vendor/ruby-2.6.6/lib/ruby/2.6.0/irb/ruby-lex.rb:232:in `block in each_top_level_statement'
/app/vendor/ruby-2.6.6/lib/ruby/2.6.0/irb/ruby-lex.rb:231:in `catch'
/app/vendor/ruby-2.6.6/lib/ruby/2.6.0/irb/ruby-lex.rb:231:in `each_top_level_statement'
/app/vendor/ruby-2.6.6/lib/ruby/2.6.0/irb.rb:489:in `eval_input'
/app/vendor/ruby-2.6.6/lib/ruby/2.6.0/irb.rb:428:in `block in run'
/app/vendor/ruby-2.6.6/lib/ruby/2.6.0/irb.rb:427:in `catch'
/app/vendor/ruby-2.6.6/lib/ruby/2.6.0/irb.rb:427:in `run'
/app/vendor/ruby-2.6.6/lib/ruby/2.6.0/irb.rb:383:in `start'
/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.8.1/lib/rails/commands/console/console_command.rb:64:in `start'
/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.8.1/lib/rails/commands/console/console_command.rb:19:in `start'
/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.8.1/lib/rails/commands/console/console_command.rb:96:in `perform'
/app/vendor/bundle/ruby/2.6.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
/app/vendor/bundle/ruby/2.6.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
/app/vendor/bundle/ruby/2.6.0/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.8.1/lib/rails/command/base.rb:69:in `perform'
/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.8.1/lib/rails/command.rb:46:in `invoke'
/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.8.1/lib/rails/commands.rb:18:in `<top (required)>'
/app/bin/rails:4:in `require'
/app/bin/rails:4:in `<main>'
The error was due to an update of the graphql-client gem
This gem has been updated this year, the version before was from 2022
The shopify gem version I use (9.0.2), use the last version of graphql-client and it's incompatible with this version of the shopify gem
I forced the previous version in my Gemfile and now it is working again
Thanks engineersmnky for the help