【发布时间】:2020-09-09 03:51:19
【问题描述】:
我正在使用 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,它都会返回完全相同的产品数据。
【问题讨论】: