Closed Tedsterh closed 2 years ago
Can you show me the schema and the query that you used? You can adjust type names if you want to keep any of it private, but I think I need to know the structure.
type Trait @model @searchable @count {
id: ID!
trait: String! @default(value: "trait")
name: String! @index(name: "traitByName", queryField: "traitByName", sortKeyFields: ["animalId"])
animalId: ID @index(name: "traitByAnimal", queryField: "traitByAnimal", sortKeyFields: ["createdAt"])
animal: Animal @belongsTo(fields: ["animalId"])
createdAt: AWSDateTime!
}
so I am trying to filtering the count based on how many traits have an animal id, luckily I already have a default string on every trait so that I could use sorting on amplify indexes, but I have to have this extra filter {trait: {eq: "trait"}}
alongside the {animalId: {attributeExists: true}}
Hope this helps
So you are saying your overall filter is this?
{
countTrait(filter: {
and: {
trait: {eq: "trait"},
animalId: {attributeExists: true}}
})
}
Can you run this query directly in the AppSync console and let me know if it gives you the same response?
Yes that's the query sorry, I can run that one fine but as soon as I remove the trait filter and leave just the attributeExists I get the error
Fixed in 1.1.0.
Hi,
I am trying to filter based on wether an attribute exists or not, if I use an and statement alongside the
attributeExists
I am able to get a count but on its own it throws and error