我正在使用React中的GraphCMS网站,并希望设置一个GraphQL查询来过滤帖子。我们有这个查询设置可以工作并提取所有帖子(收养):
export const allAdoptions = gql`
query allAdoptions($first: Int!, $skip: Int!) {
allAdoptions(orderBy: date_DESC, first: $first, skip: $skip) {
id
name
date
image {
handle
}
desc
sex
species
neutered
},
_allAdoptionsMeta {
count
}
}
`
代码可在此处找到:https://github.com/foxreymann/foranimals/blob/master/src/components/Adoptions.js
我们想设置一个过滤器组件来获取物种的帖子:例如“猫”,我们尝试修改上面的物种查询:“猫”没有运气。任何建议都非常感谢,谢谢
答案 0 :(得分:0)
您检查过:https://graphcms.com/docs/api_simple/#filtering-entries?
它应该像这样工作:
query {
allAdoptions(
filter: {
species: "maine-coon"
}
) {
id
name
}
}
迈克尔