Mat*_*han 3 shopify graphql shopify-app
我正在使用以下 graphql 列出所有集合中的所有产品,我现在尝试将其修改为仅列出单个集合中的产品,我已经知道集合 ID,但我无法弄清楚将其放在哪里以便进行过滤集合 ID。
{
shop {
collections(first: 10) {
edges {
node {
id
description
products(first: 250) {
edges {
node {
id
description
variants(first: 10) {
edges {
node {
id
sku
price
selectedOptions {
name
value
}
}
}
}
}
}
}
}
cursor
}
pageInfo {
hasNextPage
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
您可以通过句柄抓取一个集合,而不是抓取所有集合然后进行过滤。
{
shop {
collectionByHandle(handle: "frontpage") {
id
description
products(first: 250) {
edges {
node {
id
description
variants(first: 10) {
edges {
node {
id
sku
price
selectedOptions {
name
value
}
}
}
}
}
cursor
}
pageInfo {
hasNextPage
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
只需更换frontpage您喜欢的任何手柄即可。
| 归档时间: |
|
| 查看次数: |
4046 次 |
| 最近记录: |