简体   繁体   English

如何使用 GraphQL 计算 Strapi 的一对多关系中的子项?

[英]How do I get children count in Strapi's one-to-many relation using GraphQL?

Lets say I have the following GraphQL query:假设我有以下 GraphQL 查询:

query {
  shops(id: 1) {
    id
    name
    products {
      id
    }
  }
}

How do I get the count of products ?我如何获得products数量? (for pagination purpose) (用于分页目的)

I overlooked at the issues on github.我忽略了github上的问题。 Apparently its not yet supported显然它还不支持

For REST API, you can use query param to get children row count https://test-id.herokuapp.com/childrentable/count?parentable.id=1对于 REST API,您可以使用查询参数获取子行数https://test-id.herokuapp.com/childrentable/count?parentable.id=1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM