Shopify GraphQL响应不准确

Shopify GraphQL响应不准确,graphql,shopify,liquid,Graphql,Shopify,Liquid,我正在使用Shopify的GraphQL工具来验证我的查询是否正确,并且它的响应与我期望看到的完全一致 这是我在店面上使用的代码 const query = `{ products(first: 1, query: "sku:[DUMMY_SKU_HERE]") { edges { node { id handle onlineStoreUrl title images(f

我正在使用Shopify的GraphQL工具来验证我的查询是否正确,并且它的响应与我期望看到的完全一致

这是我在店面上使用的代码

const query = `{
  products(first: 1, query: "sku:[DUMMY_SKU_HERE]") {
    edges {
      node {
        id
        handle
        onlineStoreUrl
        title
        images(first: 1) {
          edges {
            node {
              transformedSrc(maxWidth: 100, maxHeight: 100)
            }
          }
        }
      }
    }
  }
}`;

fetch("https://dummystore.myshopify.com/api/2020-07/graphql", {
  method: "POST",
  headers: {
    Accept: "application/json",
    "Content-Type": "application/graphql",
    "X-Shopify-Storefront-Access-Token": access_token,
  },
  body: query,
})
.then((response) => response.json())
.then((response) => {
  console.log(response);
})
.catch((error) => console.error(error));
这是我从Shopify得到的非常不正确的回答。它不仅不正确,而且无论我为查询传递什么SKU,它都会返回完全相同的产品数据


您混淆了管理图和店面图

产品的可用店面图ql
query
参数为:

available_for_sale
created_at
product_type
tag
title
updated_at
variants.price
vendor
那里没有SKU

您的屏幕截图似乎显示了与管理员GraphQLAPI(而非店面GraphQLAPI)绑定的GraphiQL Shopify应用程序


这就是为什么您会得到相同的结果,因为查询被忽略。

您从哪里获得这些信息的?我一直在翻这些文档,它们都开始变得模糊起来。@CW从这里开始:谢谢你提供的信息,可惜没有办法做到这一点,但至少现在我知道了原因。