Is it possible in AWS appsync / amplify to combine filter operators, like:
`
const filterInput = {
or:[
{
and: [
{createdById: { eq: userID }},
{chatWithId: { eq: chatWithUser.id }}
]
},
{
and: [
{createdById: { eq: chatWithUser.id }},
{chatWithId: { eq: userID }}
]
}
]
}
`
Because for me this is not filtering / working as expected.
Hi @rpostulart
Yes, this is possible.
What is not working as expected?
I don't receive any result while the data is there in one dynamodb table
Is it working if you try a simple filter?
Is not working for me either. If i do something like this:
or: {
customId: {
contains: "abcd"
},
customId:{
contains: "defg"
}
}
i get only the results of the first filter always (even if i switch the order). If i run the query for a single filter it works. The results contains the customId that i introduced
Hi @rpostulart @ricardoribas @manueliglesias
I'm trying to achieve the same thing combining AND & OR filters in AppSync query.
Did you find a solution ? Could you please share ?
Thanks
It works !
For those still trying, here is a working example :
query list {
list (filter :{
and: [
{ available: {eq: true}},
{ id: {eq: "XXXXX"}},
{
or: [
{promo: {eq: true}},
{price: {between : [40,45] }}
]
}
]}
)
{
items {
id
price
}
}
}
With this example we can close this issue
Most helpful comment
It works !
For those still trying, here is a working example :
query list {
list (filter :{
and: [
{ available: {eq: true}},
{ id: {eq: "XXXXX"}},
{
or: [
{promo: {eq: true}},
{price: {between : [40,45] }}
]
}
]}
)
{
items {
id
price
}
}
}