Graphql 在GatsbyJS中从Shopify查询多个集合
我想根据与Shopify产品相关联的集合,使用 筛选以从一个集合中获取所有产品,就像运行此查询一样简单:Graphql 在GatsbyJS中从Shopify查询多个集合,graphql,gatsby,Graphql,Gatsby,我想根据与Shopify产品相关联的集合,使用 筛选以从一个集合中获取所有产品,就像运行此查询一样简单: const { allShopifyCollection } = useStaticQuery( graphql` query { allShopifyCollection(filter: {id: {in: "Shopify__Collection__Z2lkOi8vc2hvcGlmeS9Db2xsZWN0aW9uLzE3NzAxMjY3M
const { allShopifyCollection } = useStaticQuery(
graphql`
query {
allShopifyCollection(filter: {id: {in: "Shopify__Collection__Z2lkOi8vc2hvcGlmeS9Db2xsZWN0aW9uLzE3NzAxMjY3MDQ5OA=="}}) {
edges {
node {
products {
title
}
}
}
}
`
)
但是(据我所知)不可能在同一组件中对同一数据类型进行多次查询
解决这个问题的首选方法是什么
- 使用多个组件获取每个集合的数据,并 是否将其传递给栅格组件
- 获取所有集合并筛选出每个集合
- 另一个解决方案
啊!!我不知道这是可能的。非常感谢。我很高兴这有帮助。啊!我不知道这是可能的。非常感谢。我很高兴这有帮助。
const { allShopifyCollection } = useStaticQuery(
graphql`
query {
collection1: allShopifyCollection(filter: {id: {in: "Shopify__Collection__Z2lkOi8vc2hvcGlmeS9Db2xsZWN0aW9uLzE3NzAxMjY3MDQ5OA=="}}) {
edges {
node {
products {
title
}
}
}
}
collection2: allShopifyCollection(filter: {id: {in: "Shopify__Collection__someOtherCollection"}}) {
edges {
node {
products {
title
}
}
}
}
collection3: allShopifyCollection(filter: {id: {in: "Shopify__Collection__yetAnotherCollection"}}) {
edges {
node {
products {
title
}
}
}
}
`
)