Skip to content

angee.graphql.data.pydantic_resource

A Hasura data resource over a pydantic row model — the computed-source seam.

The non-model sibling of :func:hasura_model_resource. strawberry-django- hasura owns the dialect mechanics (hasura_run_query_resource + the in-memory evaluator); this wrapper owns the Angee seam: deriving the GraphQL node from the pydantic row model (the row-shape SSOT) and attaching the angee.resources metadata so the frontend drives the computed resource through the same useList path as a model resource — no bespoke client path.

pydantic_node

python
def pydantic_node(row_model: type[BaseModel], *, name: str) -> type

Derive the GraphQL node type from a pydantic row model (all fields).

The resolver returns the pydantic instances directly (strawberry resolves each field by getattr); this holds while the strawberry-exposed field types coincide with the pydantic runtime types (no custom conversion).

hasura_pydantic_resource

python
def hasura_pydantic_resource(row_model: type[BaseModel],
                             *,
                             name: str,
                             model_label: str,
                             filterable: Sequence[str],
                             sortable: Sequence[str],
                             rows: Callable[[Any], Iterable[BaseModel]]
                             | None = None,
                             source: RowSource | None = None,
                             node_name: str | None = None,
                             id_field: str = "id") -> HasuraResource

Build a read-only Hasura resource from a pydantic row model.

row_model is the pydantic SSOT for the row shape; the GraphQL node is derived from it. name is the resource stem (plural snake, the list field name); model_label is the dotted app.model label the frontend keys on. rows(info) -> Iterable[row_model] is the in-memory provider; pass a source instead for a pushdown :class:RowSource.

The attached DataResourceMetadata carries roots.list so the frontend treats the resource as Hasura-backed and drives it through useList.

Released under the AGPL-3.0 License.