GraphQL group queries fail if school_term is not requested
school_term
is queried by select_related
in GroupManager
's get_queryset
, which I guess is good, because it's necessary for the active_school_term filtering.
But how to deal with the optimizer, that wants to exclude it, because it is not requested by (and not necessary for) the frontend?
Traceback (most recent call last):
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
return view_func(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/django/views/generic/base.py", line 104, in view
return self.dispatch(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/django/utils/decorators.py", line 48, in _wrapper
return bound_method(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/django/utils/decorators.py", line 188, in _view_wrapper
result = _process_exception(request, e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/django/utils/decorators.py", line 186, in _view_wrapper
response = view_func(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/graphene_django/views.py", line 201, in dispatch
result, status_code = self.get_response(request, data, show_graphiql)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/graphene_django/views.py", line 218, in get_response
execution_result = self.execute_graphql_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/felix/src/aleksis/apps/official/AlekSIS-Core/aleksis/core/views.py", line 1278, in execute_graphql_request
raise error
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/graphql/execution/execute.py", line 542, in execute_field
completed = self.complete_value(
^^^^^^^^^^^^^^^^^^^^
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/graphql/execution/execute.py", line 634, in complete_value
return self.complete_list_value(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/graphql/execution/execute.py", line 703, in complete_list_value
for index, item in enumerate(result):
^^^^^^^^^^^^^^^^^
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/django/db/models/query.py", line 400, in __iter__
self._fetch_all()
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/django/db/models/query.py", line 1928, in _fetch_all
self._result_cache = list(self._iterable_class(self))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/django/db/models/query.py", line 91, in __iter__
results = compiler.execute_sql(
^^^^^^^^^^^^^^^^^^^^^
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 1561, in execute_sql
sql, params = self.as_sql()
^^^^^^^^^^^^^
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 747, in as_sql
extra_select, order_by, group_by = self.pre_sql_setup(
^^^^^^^^^^^^^^^^^^^
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 84, in pre_sql_setup
self.setup_query(with_col_aliases=with_col_aliases)
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 73, in setup_query
self.select, self.klass_info, self.annotation_col_map = self.get_select(
^^^^^^^^^^^^^^^^
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 279, in get_select
related_klass_infos = self.get_related_selections(select, select_mask)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 1224, in get_related_selections
if not select_related_descend(f, restricted, requested, select_mask):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/felix/.cache/pypoetry/virtualenvs/aleksis-core-VLqlbO2E-py3.12/lib/python3.12/site-packages/django/db/models/query_utils.py", line 387, in select_related_descend
raise FieldError(
graphql.error.graphql_error.GraphQLError: Field Group.school_term cannot be both deferred and traversed using select_related at the same time.
GraphQL request:2:3
1 | query gqlGroups {
2 | groups {
| ^
3 | id