Found while reviewing #389.
StrawchemyField._validate_type (src/strawchemy/schema/field.py) raises StrawchemyFieldError when root_aggregations is enabled on a field whose type is not a root aggregation type, but only for strawchemy types: a plain strawberry type is skipped. A root field without resolver then builds a repository at execution, and dto_model_from_type fails with AttributeError on __dto_model__.
Reproduction
@strawberry.type
class Plain:
name: str
@strawberry.type
class Query:
plain: list[Plain] = strawchemy.field(root_aggregations=True)
Schema builds; querying plain raises AttributeError instead of a StrawchemyFieldError at definition.
Expected
root_aggregations on a field whose type is not a strawchemy root aggregation type raises StrawchemyFieldError at definition, plain strawberry types included (at least for root fields without a custom resolver).
Found while reviewing #389.
StrawchemyField._validate_type(src/strawchemy/schema/field.py) raisesStrawchemyFieldErrorwhenroot_aggregationsis enabled on a field whose type is not a root aggregation type, but only for strawchemy types: a plain strawberry type is skipped. A root field without resolver then builds a repository at execution, anddto_model_from_typefails withAttributeErroron__dto_model__.Reproduction
Schema builds; querying
plainraisesAttributeErrorinstead of aStrawchemyFieldErrorat definition.Expected
root_aggregationson a field whose type is not a strawchemy root aggregation type raisesStrawchemyFieldErrorat definition, plain strawberry types included (at least for root fields without a custom resolver).