Repository: strawberry-graphql/strawberry

Issue:
Generic input type broken from 0.69.0 onward
Generic input types were working correctly until version `0.68.4` but after `0.69.0` it's throwing a type error.
here's a test for it
```python
def test_generic_input():
    E = TypeVar('E')

    @strawberry.input
    class EnumInput(Generic[E]):
        value: E

    @strawberry.enum
    class Make(Enum):
        FORD = 'ford'
        TOYOTA = 'toyota'
        HONDA = 'honda'

    @strawberry.type
    class Car:
        make: Make

    @strawberry.type
    class Query:
        @strawberry.field
        def cars(self, make: Optional[EnumInput[Make]] = None) -> List[Car]:
            return []

    schema = strawberry.Schema(query=Query)
    query = '''
        query CarsList {
            cars(make: {value: FORD}) {
                __typename
            }
        }
        '''
    result = schema.execute_sync(query)
    assert result.errors is None
```
output error
```
self = <GraphQLObjectType 'Query'>

    @cached_property
    def fields(self) -> GraphQLFieldMap:
        """Get provided fields, wrapping them as GraphQLFields if needed."""
        try:
            fields = resolve_thunk(self._fields)
        except Exception as error:
>           raise TypeError(f"{self.name} fields cannot be resolved. {error}")
E           TypeError: Query fields cannot be resolved. 'EnumDefinition' object has no attribute '__name__'

.venv/lib/python3.9/site-packages/graphql/type/definition.py:769: TypeError
```

Generic input type broken from 0.69.0 onward
Generic input types were working correctly until version `0.68.4` but after `0.69.0` it's throwing a type error.
here's a test for it
```python
def test_generic_input():
    E = TypeVar('E')

    @strawberry.input
    class EnumInput(Generic[E]):
        value: E

    @strawberry.enum
    class Make(Enum):
        FORD = 'ford'
        TOYOTA = 'toyota'
        HONDA = 'honda'

    @strawberry.type
    class Car:
        make: Make

    @strawberry.type
    class Query:
        @strawberry.field
        def cars(self, make: Optional[EnumInput[Make]] = None) -> List[Car]:
            return []

    schema = strawberry.Schema(query=Query)
    query = '''
        query CarsList {
            cars(make: {value: FORD}) {
                __typename
            }
        }
        '''
    result = schema.execute_sync(query)
    assert result.errors is None
```
output error
```
self = <GraphQLObjectType 'Query'>

    @cached_property
    def fields(self) -> GraphQLFieldMap:
        """Get provided fields, wrapping them as GraphQLFields if needed."""
        try:
            fields = resolve_thunk(self._fields)
        except Exception as error:
>           raise TypeError(f"{self.name} fields cannot be resolved. {error}")
E           TypeError: Query fields cannot be resolved. 'EnumDefinition' object has no attribute '__name__'

.venv/lib/python3.9/site-packages/graphql/type/definition.py:769: TypeError
```



Discussion:

Resolving patch:
diff --git a/strawberry/types/types.py b/strawberry/types/types.py
--- a/strawberry/types/types.py
+++ b/strawberry/types/types.py
@@ -12,6 +12,8 @@
     Union,
 )
 
+from strawberry.enum import EnumDefinition
+from strawberry.lazy_type import LazyType
 from strawberry.type import StrawberryType, StrawberryTypeVar
 from strawberry.utils.str_converters import capitalize_first
 from strawberry.utils.typing import is_generic as is_type_generic
@@ -117,7 +119,11 @@ def get_name_from_types(self, types: Iterable[Union[StrawberryType, type]]) -> s
         names: List[str] = []
 
         for type_ in types:
-            if isinstance(type_, StrawberryUnion):
+            if isinstance(type_, LazyType):
+                name = type_.type_name
+            elif isinstance(type_, EnumDefinition):
+                name = type_.name
+            elif isinstance(type_, StrawberryUnion):
                 name = type_.name
             elif hasattr(type_, "_type_definition"):
                 field_type = type_._type_definition  # type: ignore


Test patch:
diff --git a/tests/types/resolving/test_generics.py b/tests/types/resolving/test_generics.py
--- a/tests/types/resolving/test_generics.py
+++ b/tests/types/resolving/test_generics.py
@@ -1,7 +1,9 @@
+from enum import Enum
 from typing import Generic, List, Optional, TypeVar, Union
 
 import strawberry
 from strawberry.annotation import StrawberryAnnotation
+from strawberry.enum import EnumDefinition
 from strawberry.field import StrawberryField
 from strawberry.type import StrawberryList, StrawberryOptional, StrawberryTypeVar
 from strawberry.types.types import TypeDefinition
@@ -80,3 +82,29 @@ def test_generic_unions():
     assert resolved.is_generic
 
     assert resolved == Union[S, T]
+
+
+def test_generic_with_enums():
+    T = TypeVar("T")
+
+    @strawberry.enum
+    class VehicleMake(Enum):
+        FORD = "ford"
+        TOYOTA = "toyota"
+        HONDA = "honda"
+
+    @strawberry.type
+    class GenericForEnum(Generic[T]):
+        generic_slot: T
+
+    annotation = StrawberryAnnotation(GenericForEnum[VehicleMake])
+    resolved = annotation.resolve()
+
+    # TODO: Simplify with StrawberryObject
+    assert isinstance(resolved, type)
+    assert hasattr(resolved, "_type_definition")
+    assert isinstance(resolved._type_definition, TypeDefinition)
+
+    generic_slot_field: StrawberryField = resolved._type_definition.fields[0]
+    assert isinstance(generic_slot_field.type, EnumDefinition)
+    assert generic_slot_field.type is VehicleMake._enum_definition
diff --git a/tests/types/test_lazy_types.py b/tests/types/test_lazy_types.py
--- a/tests/types/test_lazy_types.py
+++ b/tests/types/test_lazy_types.py
@@ -1,8 +1,12 @@
+# type: ignore
+from typing import Generic, TypeVar
+
 import strawberry
 from strawberry.annotation import StrawberryAnnotation
 from strawberry.field import StrawberryField
 from strawberry.lazy_type import LazyType
 from strawberry.types.fields.resolver import StrawberryResolver
+from strawberry.types.types import TypeDefinition
 
 
 # This type is in the same file but should adequately test the logic.
@@ -53,6 +57,30 @@ def test_lazy_type_field():
     assert field.type.resolve_type() is LaziestType  # type: ignore
 
 
+def test_lazy_type_generic():
+    T = TypeVar("T")
+
+    @strawberry.type
+    class GenericType(Generic[T]):
+        item: T
+
+    # Module path is short and relative because of the way pytest runs the file
+    LazierType = LazyType["LaziestType", "test_lazy_types"]
+    ResolvedType = GenericType[LazierType]
+
+    annotation = StrawberryAnnotation(ResolvedType)
+    resolved = annotation.resolve()
+
+    # TODO: Simplify with StrawberryObject
+    assert isinstance(resolved, type)
+    assert hasattr(resolved, "_type_definition")
+    assert isinstance(resolved._type_definition, TypeDefinition)
+
+    items_field: StrawberryField = resolved._type_definition.fields[0]
+    assert items_field.type is LazierType
+    assert items_field.type.resolve_type() is LaziestType
+
+
 def test_lazy_type_object():
     # Module path is short and relative because of the way pytest runs the file
     LazierType = LazyType["LaziestType", "test_lazy_types"]