【发布时间】:2019-01-22 14:57:39
【问题描述】:
我正在尝试使用 in 运算符执行查询,其中条件基于数组中的值。如何执行下面的查询以获取数组并将其基于变量数组的标准?我正在使用 reactjs + gatsby。
... graphql`
query pageHeader {
.... there is another query in the real code above this line
allContentInSites (filter: {slug: {in: ` + JSON.stringify(searchCriteria.map(item => item.value)) + ` }}) {
edges {
node {
title,
link
}
}
}
}'
我最初认为上面的示例代码会为 in 标准传递一个 json 字符串对象,但这似乎破坏了页面。
【问题讨论】: