现在我正试图在Strapi GraphQL游乐场中使用multiple_and内部查询。我使用的查询是:
{
clients(
where: {
_and: [{ name: { _contains: "a" } }, { endDate: { _gte: "2017-12-31" } }]
}
) {
id
name
endDate
reasonForEnding
}
}
但是得到一个错误说:
"Error: Your filters contain a field '_and' that doesn't appear on your model definition nor it's relations".
如何使用GraphQL在Strapi中正确查询多个条件和where子句
clients(
where: {
and: [{ name: { contains: "a" } }, { endDate: { gte: "2017-12-31" } }]
}
) {
id
name
endDate
reasonForEnding
}
这就是答案
只是添加到@Mohammad Sadeq Sirjani的答案中;它不是and
而是_and
。所以总结起来就是:
clients(
where: {
_and: [{ name: { contains: "a" } },
{ endDate: { gte: "2017-12-31" } }]
}
) {
id
name
endDate
reasonForEnding
}