简体   繁体   English

GraphQL 查询嵌套对象

[英]GraphQL Query Nested Object

I'm new to GraphQL, reading up on the documentation and just messing around so apologies in advance for any lack of understanding here (including whether or not this is impossible).我是 GraphQL 的新手,阅读了文档,只是为了在这里缺乏理解而提前道歉(包括这是否不可能)。 My schema is generated by the CMS I'm using (Strapi).我的架构是由我使用的 CMS (Strapi) 生成的。

I am wondering if it is possible to query a field on a nested component?我想知道是否可以查询嵌套组件上的字段?

For example, say there is a Restaurant object例如,假设有一个Restaurant对象

{
    "name": "Luigi's Pizza",
    "michelinStars": 1
    "page": {
      "title": "Luigi's Pizza | The Best Pizza in Italy",
      "slug": "luigis-pizza"
    }
}

I can query for a Restaurant with Restaurants(where: {michelinStars: 1}) etc, but if I wanted to get the Restaurant with the slug "luigis-pizza", I'm struggling to work out how.我也可以查询RestaurantRestaurants(where: {michelinStars: 1})等,但如果我想获得的Restaurantslug “luigis比萨饼”,我努力工作,如何。 Pseduo code for what I want to do:我想做的伪代码:

query {
    Restaurants(where: { page: { slug: "luigis-pizza" } }) {
        name
    }
}

Is this possible?这可能吗? And if so, how would I go about doing it?如果是这样,我将如何去做?

I just tried with last version of Strapi and the deep filter is working well.我刚刚尝试使用最新版本的 Strapi,深度过滤器运行良好。

Here is a short video of what I did - https://www.loom.com/share/cf8360252b1044128c9b07a2bb390638这是我所做的简短视频 - https://www.loom.com/share/cf8360252b1044128c9b07a2bb390638

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

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