是否可以在 AWS appsync/amplify 中组合过滤器运算符,例如:
const filterInput = {
or:[
{
and: [
{createdById: { eq: userID }},
{chatWithId: { eq: chatWithUser.id }}
]
},
{
and: [
{createdById: { eq: chatWithUser.id }},
{chatWithId: { eq: userID }}
]
}
]
}
因为对我来说,这不是按预期过滤/工作。
感谢您提供的额外信息。使用如下所示的放大架构:
type Chat @model {
id: ID!
createdAt: String
createdById: String
chatWithId: String
messsages: [Message]
}
默认情况下,将创建一个具有存储 id 值的 HASH 键的表来存储值,并且无法仅使用默认键结构有效地运行您尝试运行的查询。将来,您将有更多的工具来控制@model表的索引结构,但现在唯一的方法是通过@connection。
下面是一个示例架构,它可能有助于你开始构建可以更有效地查询这些关系的 API。
ChatQL React schema.graphql