如何通过ids& amp;获得产品使用ShopifyAPI :: GraphQL

时间:2018-05-21 00:19:28

标签: ruby-on-rails shopify graphql

在我拥有这些之前:

按product_ids获取产品

shopify_client #shopify_session
ShopifyAPI::Product.all(:params => 
{:page => 1, :limit => 250, :ids => product_ids})

获取收藏品,按产品ID和广告进行过滤具体领域

ShopifyAPI::Collect.find(:all, 
params:{product_id: product_id, fields: 'collection_id'})

现在我正在迁移到GraphQL,我怎样才能获得与REST相同的结果?

以下是GraphQL查询示例:

# Once your session is activated, simply construct a new graphql client and use `parse` and `query`


client = ShopifyAPI::GraphQL.new

SHOP_NAME_QUERY = client.parse <<-'GRAPHQL'
  {
    shop {
      name
    }
  }
GRAPHQL

result = client.query(SHOP_NAME_QUERY)
result.data.shop.name

参考宝石: https://github.com/Shopify/shopify_api/pull/431

感谢您的帮助。

0 个答案:

没有答案