Consider code below
@dataclasses.dataclass
class FilterBase:
name: strawberry.auto
@strawberry_django.filter(SomeModel, lookups=True)
class Filter(FilterBase):
pass
@dataclasses.dataclass
class OrderBase:
name: strawberry.auto
@strawberry_django.order(SomeModel)
class Order(OrderBase):
pass
@strawberry_django.type(SomeModel, order=Order, filters=Filter)
class SomeModel(strawberry.relay.Node):
name: strawberry.auto
The filter will work just fine but the order will crash the schema converter. If I remove OrderBase
and inline the name annotation in Order
then everything works as inteded.
Stacktrace:
Traceback (most recent call last):
File "/workspace/backend/.venv/lib/python3.11/site-packages/graphql/type/definition.py", line 1456, in fields
fields = resolve_thunk(self._fields)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/backend/.venv/lib/python3.11/site-packages/graphql/type/definition.py", line 300, in resolve_thunk
return thunk() if callable(thunk) else thunk
^^^^^^^
File "/workspace/backend/.venv/lib/python3.11/site-packages/strawberry/schema/schema_converter.py", line 403, in <lambda>
fields=lambda: self.get_graphql_input_fields(type_definition),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/backend/.venv/lib/python3.11/site-packages/strawberry/schema/schema_converter.py", line 382, in get_graphql_input_fields
return _get_thunk_mapping(
^^^^^^^^^^^^^^^^^^^
File "/workspace/backend/.venv/lib/python3.11/site-packages/strawberry/schema/schema_converter.py", line 133, in _get_thunk_mapping
thunk_mapping[name_converter(field)] = field_converter(
^^^^^^^^^^^^^^^^
File "/workspace/backend/.venv/lib/python3.11/site-packages/strawberry/schema/schema_converter.py", line 349, in from_input_field
self.from_maybe_optional(
File "/workspace/backend/.venv/lib/python3.11/site-packages/strawberry/schema/schema_converter.py", line 769, in from_maybe_optional
return GraphQLNonNull(self.from_type(type_))
^^^^^^^^^^^^^^^^^^^^^
File "/workspace/backend/.venv/lib/python3.11/site-packages/strawberry/schema/schema_converter.py", line 802, in from_type
raise TypeError(f"Unexpected type '{type_}'")
TypeError: Unexpected type 'typing.Any'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.11/threading.py", line 975, in run
self._target(*self._args, **self._kwargs)
File "/workspace/backend/.venv/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/workspace/backend/.venv/lib/python3.11/site-packages/django/core/management/commands/runserver.py", line 118, in inner_run
self.check(display_num_errors=True)
File "/workspace/backend/.venv/lib/python3.11/site-packages/django/core/management/base.py", line 419, in check
all_issues = checks.run_checks(
^^^^^^^^^^^^^^^^^^
File "/workspace/backend/.venv/lib/python3.11/site-packages/django/core/checks/registry.py", line 76, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/backend/.venv/lib/python3.11/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/backend/.venv/lib/python3.11/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/backend/.venv/lib/python3.11/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File "/workspace/backend/.venv/lib/python3.11/site-packages/django/urls/resolvers.py", line 602, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
^^^^^^^^^^^^^^^^^^^
File "/workspace/backend/.venv/lib/python3.11/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File "/workspace/backend/.venv/lib/python3.11/site-packages/django/urls/resolvers.py", line 595, in urlconf_module
return import_module(self.urlconf_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/workspace/backend/foo/urls.py", line 13, in <module>
from .app.graphql.schema import schema
File "/workspace/backend/foo/app/graphql/schema.py", line 60, in <module>
schema = Schema(
^^^^^^^
File "/workspace/backend/.venv/lib/python3.11/site-packages/strawberry/schema/schema.py", line 141, in __init__
self._schema = GraphQLSchema(
^^^^^^^^^^^^^^
File "/workspace/backend/.venv/lib/python3.11/site-packages/graphql/type/schema.py", line 224, in __init__
collect_referenced_types(query)
File "/workspace/backend/.venv/lib/python3.11/site-packages/graphql/type/schema.py", line 435, in collect_referenced_types
collect_referenced_types(arg.type)
File "/workspace/backend/.venv/lib/python3.11/site-packages/graphql/type/schema.py", line 438, in collect_referenced_types
for field in named_type.fields.values():
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/functools.py", line 1001, in __get__
val = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File "/workspace/backend/.venv/lib/python3.11/site-packages/graphql/type/definition.py", line 1459, in fields
raise cls(f"{self.name} fields cannot be resolved. {error}") from error
TypeError: Order fields cannot be resolved. Unexpected type 'typing.Any'
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