Reputation: 1811
I am using Shopify's GraphQL Tool to verify that my query is correct and it response exactly what I would expect to see
Here is the code that I'm using on my storefront.
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));
and here is the very incorrect response that I'm getting from Shopify. Not only is it incorrect, but no matter what SKU I pass in for my query it returns the exact same product data.
Upvotes: 0
Views: 700
Reputation: 12933
You are confusing the Admin GraphQL with the Storefront GraphQL.
The available Storefront GraphQL query
params for the products
are:
available_for_sale
created_at
product_type
tag
title
updated_at
variants.price
vendor
There is no SKU there.
Your screenshot seems to show the GraphiQL Shopify App that is tied to the Admin GraphQL API, not the Storefront GraphQL API.
That's why you get the same result, since the query is just ignored.
Upvotes: 1