Let's imagine we have two Django models: Cage
and Animal
where the second one has a FK
to the first one. Then we have the following strawberry definition:
@strawberry_django.type(models.Cage)
class Cage:
id: int
@strawberry_django.field(annotate={"total_animals": Count("animals")})
def total_animals(
self,
root: models.Cage,
) -> int:
return root.total_animals
It works great when I ask for totalAnimals
in a query but it fails if I ask for the same field in a mutation. Examples:
It works fine
query MyQuery {
cages {
id
totalAnimals
}
}
It fails with the error Error: "\'Cage\' object has no attribute \'total_animals\'"
mutation MyMutation {
updateCage(data: {id: 10}) {
id
totalAnimals
}
}
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too