Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic input type broken from 0.69.0 onward #1104

Closed
daironmichel opened this issue Aug 3, 2021 · 0 comments · Fixed by #1235
Closed

Generic input type broken from 0.69.0 onward #1104

daironmichel opened this issue Aug 3, 2021 · 0 comments · Fixed by #1235
Assignees
Labels
bug Something isn't working

Comments

@daironmichel
Copy link

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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants