Simple enough graphQL query,
{
products(first: 10) {
nodes {
id
title
category {
name
}
status
tracksInventory
totalInventory
productType
featuredMedia {
preview {
image {
url
}
}
}
}
}
}
Which works fine with GraphiQL,
But fails through a direct api access call. If I remove category, it also works fine.
The same graphQL also works fine through a server-side admin call,
const { admin } = await shopify.unauthenticated.admin(shop)
const resp = await admin
.graphql(/* GraphQL */ `
{
products(first: 10) {
nodes {
id
title
category {
name
}
status
tracksInventory
totalInventory
productType
featuredMedia {
preview {
image {
url
}
}
}
}
}
}
`)
.then((res) => res.json())
console.log(resp)
Only place it fails strangely, by category not being on a product is with direct api access,
const res = await fetch("shopify:admin/api/graphql.json", {
method: "POST",
body: JSON.stringify({
query: `{
products(first: 10) {
nodes {
id
title
category {
name
}
status
tracksInventory
totalInventory
productType
featuredMedia {
preview {
image {
url
}
}
}
}
}
}`
})
})
const response = await res.json()
console.log(response)

