The QueryHook.apply_hook docstring (src/strawchemy/transpiler/hook.py:198) says:
alias is the alias of the model the hook's field belongs to.
This is wrong for a hook on a relation field. StrawchemyRepository._build attaches that hook to the child node (src/strawchemy/repository/strawberry/base.py:337: self._add_query_hooks(hooks, child if is_relation_field else node)), so alias is the related model's alias. _check_query_hooks in src/strawchemy/schema/factories/base.py and test_relation_field_hook_of_another_model agree with this.
The class docstring ("Loads extra columns and relations, or edits the SELECT, for the field it is attached to") also leaves out type-level hooks (@strawchemy.type(query_hook=...)) and repository hooks.
Suggested wording: "alias is the alias of the model the hook runs on: the related model for a relation field, the type's model otherwise." docs/reference/api/hooks.md picks it up when regenerated.
The
QueryHook.apply_hookdocstring (src/strawchemy/transpiler/hook.py:198) says:This is wrong for a hook on a relation field.
StrawchemyRepository._buildattaches that hook to the child node (src/strawchemy/repository/strawberry/base.py:337:self._add_query_hooks(hooks, child if is_relation_field else node)), soaliasis the related model's alias._check_query_hooksinsrc/strawchemy/schema/factories/base.pyandtest_relation_field_hook_of_another_modelagree with this.The class docstring ("Loads extra columns and relations, or edits the SELECT, for the field it is attached to") also leaves out type-level hooks (
@strawchemy.type(query_hook=...)) and repository hooks.Suggested wording: "
aliasis the alias of the model the hook runs on: the related model for a relation field, the type's model otherwise."docs/reference/api/hooks.mdpicks it up when regenerated.