Open patrick91 opened 3 years ago
(A light bit of triage since I encountered this in our codebase just now:)
Seemingly related issues:
In any case, this seems to still reproduce, although with slightly different symptoms:
KeyError: 'T'
(no longer any TypeError
wrapping it) when referring to the generic type directly https://play.strawberry.rocks/?gist=033b747cf59c3710ac5a0923dc2ee08eTypeError: Subclass fields cannot be resolved. The type "__main__.InnerGeneric[~U]" is generic, but no type has been passed
when using a concrete subclass: https://play.strawberry.rocks/?gist=896a661dd084980d3d6fa0cee05659caimport strawberry
from typing import Generic, TypeVar
import strawberry
T = TypeVar("T")
U = TypeVar("U")
@strawberry.input
class InnerGeneric(Generic[T]):
field: T
@strawberry.input
class OuterGeneric(Generic[U]):
outer: InnerGeneric[U]
# @strawberry.input
# class Subclass(OuterGeneric[int]): pass
@strawberry.type
class Query:
@strawberry.field
def direct(self, input: OuterGeneric[int]) -> int:
return 0
# @strawberry.field
# def via_subclass(self, input: Subclass) -> int:
# return 0
schema = strawberry.Schema(query=Query)
@huonw thanks for the reproduction, I'll try to check it on the weekend 😊
While chatting with @BryceBeagle we found a bug with Generics, the following code should work:
but instead it crashes with the following error:
Upvote & Fund