angee.graphql.data.hasura
Angee metadata bridge for strawberry-django-hasura resources.
AngeeHasuraWriteBackend
class AngeeHasuraWriteBackend()Authorized write backend for Angee Hasura resources.
strawberry-django-hasura owns the Hasura mutation envelope. This class owns the Angee write semantics inside that envelope: Django validation, REBAC row-scoped write targets, model save/delete signals, and returning a deleted instance in Hasura's delete_<res>_by_pk shape.
create
def create(info: strawberry.Info, data: dict[str, Any]) -> AnyCreate through strawberry-django's stock mutation resolver.
update
def update(info: strawberry.Info, pk: str, data: dict[str, Any]) -> AnyPatch one public-id-addressed row through the write queryset.
delete
def delete(info: strawberry.Info, pk: str) -> Any | NoneDelete one public-id-addressed row and return the deleted instance.
public_pk_decoder
def public_pk_decoder(model: type[models.Model]) -> Callable[[Any], Any]Return a decoder from Angee public id to database primary key.
aggregate_queryset
def aggregate_queryset(queryset: models.QuerySet[Any]) -> models.QuerySet[Any]Return the aggregate-safe variant of a REBAC queryset when available.
A REBAC-scoped queryset exposes scoped_for_aggregate to drop row-fanout joins before aggregation; a plain queryset has no such method and is returned unchanged. Resources with a custom aggregate source wrap it through here.
declared_hasura_resource_fields
def declared_hasura_resource_fields(model: type[models.Model],
attribute: str) -> tuple[str, ...]Return Hasura resource fields declared by a composed model or extension base.
Same-row model extensions own the fields they add and may declare which of those fields are writable/filterable/sortable on a Hasura resource by setting attribute on their source model class. The composed runtime model inherits those bases; this helper gathers only directly declared attributes from the MRO so a downstream extension can contribute without the base addon importing it.
hasura_model_resource
def hasura_model_resource(
node: type,
*,
model: type[models.Model],
name: str | None = None,
filterable: Sequence[str],
sortable: Sequence[str],
aggregatable: Sequence[str],
groupable: Sequence[str] = (),
writable: Sequence[str] | None = None,
insertable: Sequence[str] | None = None,
updatable: Sequence[str] | None = None,
insert: bool = True,
update: bool = True,
delete: bool = True,
field_id_decode: Mapping[str, Callable[[Any], Any]] | None = None,
get_queryset: Callable[[strawberry.Info], models.QuerySet[Any]]
| None = None,
get_aggregate_queryset: Callable[[strawberry.Info],
models.QuerySet[Any]] | None = None,
write_backend: WriteBackend | None = None,
id_decode: Callable[[Any], Any] | None = None,
id_column: str = "pk",
declared_fields: Sequence[str] = (),
model_label: str | None = None,
public_id_field: str = PUBLIC_ID_FIELD_NAME,
row_model: str = "server") -> HasuraResourceBuild a Hasura resource and attach Angee's model-resource metadata.
strawberry-django-hasura owns the portable Hasura dialect mechanics. This wrapper owns the Angee seam around that resource: attaching the Phase 1 angee.resources metadata contribution, and defaulting the standard glue a public-id model resource shares — base/aggregate querysets, the authorized write backend, and the public-id id decoder. A caller overrides any knob only where the resource's intent differs (REBAC-scoped reads, a custom write backend, a non-pk identity column).
attach_hasura_resource_metadata
def attach_hasura_resource_metadata(
resource: HasuraResource,
*,
node: type,
model: type[models.Model],
name: str,
filterable: tuple[str, ...],
sortable: tuple[str, ...],
aggregatable: tuple[str, ...],
groupable: tuple[str, ...] = (),
insert: bool = True,
update: bool = True,
delete: bool = True,
declared_fields: tuple[str, ...] = (),
model_label: str | None = None,
public_id_field: str = PUBLIC_ID_FIELD_NAME,
row_model: str = "server") -> HasuraResourceAttach Angee resource metadata to a built Hasura resource bundle.