Annotations and optimizations don't work on fields created with strawberry_django.auth.current_user()
With the following code:
@strawberry.type
class Query:
user: User = strawberry_django.node(extensions=[IsAuthenticated()])
current_user: User = strawberry_django.auth.current_user()
@strawberry_django.type(UserModel)
class User(Actor, relay.Node):
friend_count: int = strawberry_django.field(annotate=Count("friends"))
friend_count
will work on the user
field just fine, but attempting to access it on current_user
and you get this error:
{
"data": null,
"errors": [
{
"message": "'User' object has no attribute 'friend_count'",
"locations": [
{
"line": 3,
"column": 5
}
],
"path": [
"currentUser",
"friendCount"
]
}
]
}
It's not just annotations, it happens for all the optimizations too.
There is another similar issue here. They might be related.
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