Using a field resolver with return type of list
or List
(as opposed to say list[int]
etc) raising an internal exception:
AttributeError: __args__. Did you mean: '__ror__'?
This is due to the lack of a len check when calling evaled_type.__args__[0]
in this function:
class StrawberryAnnotation:
... # skipped code
def create_list(self, evaled_type: Any) -> StrawberryList:
of_type = StrawberryAnnotation(
annotation=evaled_type.__args__[0],
namespace=self.namespace,
).resolve()
return StrawberryList(of_type
I am not sure what the desired behaviour is, maybe either:
list[Any]
.Example Code:
from typing import List
import strawberry
@strawberry.type
class MyItemType:
my_field: int
def typing_list_resolver() -> List:
return [MyItemType(2), MyItemType(3)]
def builtin_list_resolver() -> list:
return [MyItemType(2), MyItemType(3)]
@strawberry.type
class Query:
my_item: List[MyItemType] = strawberry.field(typing_list_resolver)
@strawberry.type
class Query2:
my_item: list[MyItemType] = strawberry.field(builtin_list_resolver)
if __name__ == "__main__":
# raises `AttributeError: __args__. Did you mean: '__ror__'?`
strawberry.Schema(Query)
# raises `AttributeError: __args__. Did you mean: '__ror__'?`
strawberry.Schema(Query2)
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