NameError: uninitialized constant ShopifyAPI::Session shopify_app gem -v 19, rails 7

Viewed 179

I am using background jobs to get orders via webhook and perform some other processing. I get the webhook it on my background jobs but when When I try to initiate a session it gives me the following error.

NameError: uninitialized constant ShopifyAPI::Session I am using the following versions: rails:- 7.0.3, ruby:- 3.1.2, shopify_app:- 19.0.2

can anyone explain it to me that what I am doing wrong here? Did the gem update/latest version has a different approach to activate or create a session in background job.

I really appreciate your suggestions.

1 Answers

In the new version of the shopify gems, ShopifyAPI::Session doesn't exist anymore:

https://www.rubydoc.info/gems/shopify_api/#breaking-change-notice-for-version-10-0-0

now you can create a method:

 # Public. Activate the Shopify API session for the currently authenticated shop.
 def invoke_shopify_api
    ShopifyAPI::Auth::Session.temp(shop: shopify_domain, access_token: shopify_token) do |session|
     # make invocations to the API
     yield
   end
 end
Related