Skip to content
This repository was archived by the owner on Jul 8, 2023. It is now read-only.
This repository was archived by the owner on Jul 8, 2023. It is now read-only.

FieldDoesNotExist when using field via mixin #188

@blueyed

Description

@blueyed

Given:

# from strawberry_django import field as django_field
# from strawberry_django import type as django_type
from strawberry_django_plus.gql.django import field as django_field
from strawberry_django_plus.gql.django import type as django_type

class UrnFieldMixin:
    urn: str = django_field()

@django_type(models.Foo, filters=TrayTypeFilter, pagination=True)
class Foo(UrnFieldMixin):
    ...

I get:


../../../Vcs/django/django/db/models/options.py:669: in get_field
    return self.fields_map[field_name]
E   KeyError: 'field'

During handling of the above exception, another exception occurred:
testing/api/test_foo.py:3: in <module>
    from csd.api.schema import schema
.../schema.py:11: in <module>
    from ...api_types import Baz
.../api_types.py:11: in <module>
    from ....api_types import Bar
.../api_types.py:51: in <module>
    @django_type(models.Foo, filters=FooFilter, pagination=True)
../../../Vcs/strawberry-django-plus/strawberry_django_plus/type.py:379: in wrapper
    return _process_type(
../../../Vcs/strawberry-django-plus/strawberry_django_plus/type.py:276: in _process_type
    fields = list(_get_fields(django_type).values())
../../../Vcs/strawberry-django-plus/strawberry_django_plus/type.py:210: in _get_fields
    fields[name] = _from_django_type(
../../../Vcs/strawberry-django-plus/strawberry_django_plus/type.py:149: in _from_django_type
    model_field = get_model_field(
../../../Vcs/strawberry-graphql-django/strawberry_django/fields/types.py:252: in get_model_field
    raise e
../../../Vcs/strawberry-graphql-django/strawberry_django/fields/types.py:235: in get_model_field
    return model._meta.get_field(field_name)
../../../Vcs/django/django/db/models/options.py:671: in get_field
    raise FieldDoesNotExist(
E   django.core.exceptions.FieldDoesNotExist: Foo has no field named 'field', did you mean ...

When not using a mixin, or when not using strawberry-django-plus it works.

I am happy to debug this further, but would appreciate some pointer(s).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions