0

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

  • And then I try to parse 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>'
8
  • The gem version you are using is more than 4 years old. Several newer major versions have been released since then. Did you consider updating the shopify gem to a more recent version? Commented Apr 2, 2024 at 6:04
  • @spickermann Yes, I wanted to update to the new version, but my app is pretty big and there are a lot of changes to do for it to simply work again. I started doing it but I don't have the time for now (I will resume my work on it when I can) From the error it really looks like it's more on the GraphQL side/initialization, If it was the gem itself, I would assume the REST API wouldn't work either (and it wouldn't work locally ?) Commented Apr 2, 2024 at 7:43
  • Can you provide the full stacktrace for the error? Commented Apr 2, 2024 at 19:02
  • @engineersmnky i edited my post by adding the backtrace from rails console When i look into my gems location locally, i don't see the "graphql-client-0.19.0" folder, only the "graphql-client-0.18.0" Commented Apr 3, 2024 at 0:28
  • Sounds like you may have discovered your issue, you are using different versions (released almost 2 years apart). Commented Apr 3, 2024 at 3:04

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.