Shopify / shopify-api-ruby

ShopifyAPI is a lightweight gem for accessing the Shopify admin REST and GraphQL web services.
MIT License
1.06k stars 473 forks source link

Problem ShopifyAPI::GraphQL.client.parse - undefined method `fields' for nil:NilClass #1278

Closed bseido closed 9 months ago

bseido commented 9 months ago

Issue summary

Hi,

We use a local ruby app with the shopify gem (version 9.0.2) Evrything worked well, until recently (around Monday-Tuesday), when suddenly it can't parse all my GraphQL call on Heroku

But when I am doing the same process locally, it works

For example, on both (local and with "heroku run rails c") :  -I am initializing the ShopifyAPI with the credentials, the api_version

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, and now on Heroku I have this error

NoMethodError (undefined methodfields' for nil:NilClass)`

and before a few days ago, it worked well on Heroku as well

I have push other things (like credentials, or code on other files), but these has no links with the GraphQL And if those changes were the cause, i don't think it would work locally Does someone has an idea where does this error comes from ?

Thanks

// Paste any relevant logs here

Expected behavior

The query is parsed correctly

Actual behavior

NoMethodError (undefined method `fields' for nil:NilClass) when trying to parse the GraphQL query, but only on Heroku Locally it works correctly

Steps to reproduce the problem

I don't really know how to reproduce it

lizkenyon commented 9 months ago

Hi there 👋

If you would like us to look into this issue could you provide us with a minimal repository we can deploy to Heroku that reproduce the issue?

bseido commented 9 months ago

Hi ! Thanks for your answer

My app is pretty big and I don't know how I could really do a minimal version without spending a huge amount of time on it (and sadly, I don't have the time to do it) I can try to create one but I don't know when it will be ready

I want to point out that I have some problems with Heroku (no possibilities to push, clone, etc, it always return a 504 error, and some memory problem i didn't have before either), so I am wondering it the problem could come from Heroku itself, since the gem is working correctly locally

I have submitted a ticket to them, but I have no answers at this time

lizkenyon commented 9 months ago

Thanks for the context!

I will close this issue for now. But please re-open it if you are able to create a reproducible repo that you would like us to look into, or have more information that the bug is on our end!

bseido commented 7 months ago

Update to give the solution to my problem (in case someone got the same) The shopify gem automatically use a more recent version of the "graphql-client" gem This gem wasn't updated since 2022, but since the last update end of january 2024 (0.19 version), the GraphQL does not work

So i had to force in my Gemfile the 0.18 version, and now it is working again