【发布时间】:2019-12-18 10:48:19
【问题描述】:
下面是我从 Strapi 后端获取帖子的 GraphQL 查询。
请注意,我在我的 Nuxt 应用上运行此程序。
现在我只想带上那些有post_status = "Publish"的帖子
post_status 是一个 ENUM 字段,有两个选项作为草稿和发布
query GetPosts{
posts {
id
post_title
post_excerpt
post_featured_image{url}
post_content
post_category{category_name}
postingredients{ingredient{ingredient_name}, ingredient_unit}
updated_at
post_author{username}
post_slug
}
}
我不明白我怎样才能得到
- 如何在我的原始查询中添加
post_status值 -
如何过滤
post_status我只能获得已发布的帖子。query GetStatusEnum{ __type(name: "ENUM_POST_POST_STATUS") { name enumValues { name } } }
以上结果:
{
"data": {
"__type": {
"name": "ENUM_POST_POST_STATUS",
"enumValues": [
{
"name": "Publish"
},
{
"name": "Draft"
}
]
}
}
}
【问题讨论】: