【发布时间】:2021-09-21 19:43:46
【问题描述】:
我不确定这是否是一个错误,但我无法让 GraphQL 在 Cornerstone 模板中工作。我预计至少会出现错误或返回某些内容,但 gql 根本没有呈现任何内容。
我在pages/product.html 模板上,我什至尝试了docs 中的这个例子:
---
product:
videos:
limit: {{theme_settings.productpage_videos_count}}
reviews:
limit: {{theme_settings.productpage_reviews_count}}
related_products:
limit: {{theme_settings.productpage_related_products_count}}
similar_by_views:
limit: {{theme_settings.productpage_similar_by_views_count}}
gql: "query productById($productId: Int!) {
site {
product(entityId: $productId) {
variants(first: 25) {
edges {
node {
sku
defaultImage {
url(width: 1000)
}
}
}
}
}
}
}
"
我的目标是访问每个产品类别的路径/URL,因为product.category 只是一个类别名称数组。这是我能够在 GraphQL 操场上进行的查询(我认为,在前面的 GraphQL 查询中,86 将被 $productId 替换?):
query getProductCategories {
site {
product(entityId: 86) {
categories {
edges {
node {
name
path
}
}
}
}
}
}
如果没有办法解决这个问题,也许我会尝试在客户端进行获取。
【问题讨论】:
-
目前有一个错误,在 stencil-cli 中本地查看主题时,GQL 结果不起作用,但在您上传主题时它们起作用。即将修复 CLI 错误。
-
@NathanBooker 我明白了,感谢您的回复!
标签: bigcommerce