我在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
我们想要设置一个过滤器组件来按物种获取帖子:例如,“猫”,我们尝试修改上面的物种查询:“猫”,但没有成功。非常感谢您的建议,谢谢
发布于 2018-02-22 22:58:56
你查过了吗:https://graphcms.com/docs/api_simple/#filtering-entries
它应该是这样工作的:
query {
allAdoptions(
filter: {
species: "maine-coon"
}
) {
id
name
}
}迈克尔
https://stackoverflow.com/questions/48930050
复制相似问题