Quantcast
Channel: Active questions tagged redis+ruby-on-rails - Stack Overflow
Viewing all articles
Browse latest Browse all 873

using ShopifyAPI::GraphQL.client in low-level Rails cache results in TypeError 'can't dump anonymous class'

$
0
0

I have a Rails cache set up with Redis running under Heroku. When calling the ShopifyAPI::GraphQL client inside of a Rails.cache.fetch block:

Rails.cache.fetch(product_id, expires_in: 1.hours) do  client = ShopifyAPI::GraphQL.client  client.query(client.parse(get_product_query(product_id)))end

I get the following TypeError:

TypeError (can't dump anonymous class #Class:0x00000220ec9ec618)

This issue likely concerns serialization of ShopifyAPI::GraphQL.client for Rails.cache. I can create the same TypeError with the following Marshal.dump call and no Rails.cache.fetch block:

...result = client.query(client.parse(query))Marshal.load(Marshal.dump(result.data))

I am trying to find a way to cache the ShopifyAPI::GraphQL.client JSON GraphQL response and avoid the TypeError. Please advise how I can use a low-level cache for Shopify GraphQL queries. Thank you.

ruby 2.7.4, rails 6.1.6, redis 4.7.1


Viewing all articles
Browse latest Browse all 873

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>