When using strawberry_django.field with resolve in this style,
def resolver(root: "FruitType") -> str:
return f"{root.id} - {root.name}"
@strawberry_django.type(model=Fruit)
class FruitType:
id: int
name: str
id_name: str = strawberry_django.field(resolver=resolver)
the type returned is going to be StrawberryDjangoField instead of str.
This happens only for resolvers with arguments. When the resolver uses no arguments, the correct type is returned.
This is similar to this issue reported at strawberry-graphql/strawberry
Describe the Bug
When using strawberry_django.field with resolve in this style,
the type returned is going to be
StrawberryDjangoField
instead ofstr
. This happens only for resolvers with arguments. When the resolver uses no arguments, the correct type is returned.This is similar to this issue reported at
strawberry-graphql/strawberry
As proposed by the above issue, a fix could be replacing this (https://github.com/strawberry-graphql/strawberry-graphql-django/blob/main/strawberry_django/fields/field.py#L387):
for this
Another options is to take the same approach used by
strawberry
hereSystem Information
Additional Context
I can create a PR with the preferred solution if this is indeed an issue.
Upvote & Fund