The implementation of this has caused issues on Strawberry Django and it is also broken in cases like this:
@strawberry.type
class MyGenericType(Generic[T]):
my_value: T
@strawberry.type
class MyConcreteType(MyGenericType[int], Generic[K]):
other_value: K
and
import strawberry
from strawberry import Schema
from strawberry.extensions import FieldExtension
from strawberry.field import StrawberryField
from typing import Generic, TypeVar
T = TypeVar("T")
class CheckAtRuntime(FieldExtension):
def apply(self, field: StrawberryField) -> None:
print('concrete_of when applying extension is', field.type.__strawberry_definition__.concrete_of)
def resolve(self, next_, source, info, **kwargs):
return next_(source, info, **kwargs)
@strawberry.type
class MyGenericType(Generic[T]):
my_value: T
@strawberry.type
class MyConcreteType(MyGenericType[int]):
pass
@strawberry.type
class Query:
@strawberry.field(extensions=[CheckAtRuntime()])
def my_concrete_type(self) -> MyConcreteType:
return MyConcreteType(my_value=123)
schema = Schema(query=Query)
print('concrete_of when booting is', MyConcreteType.__strawberry_definition__.concrete_of)
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