pub fn project_entity(
entity: &Value,
type_name: &str,
selections: &[FieldSelection],
schema: &CompiledSchema,
) -> ValueExpand description
Project an entity-shaped JSONB value into a GraphQL response object, mirroring the query path’s SQL projection exactly.
This is the single, canonical entity projector, shared by the mutation
success arm (projecting the returned entity) and the error arm (projecting the
error metadata). It is behaviourally equivalent to the SQL query projection
(projection_generator::render_field):
- output key = the selection’s response key (the camelCase GraphQL surface name, honouring aliases),
- source key =
to_snake_caseof the field name (the stored JSONB key), with acamelCasefallback for legacy metadata that used the surface casing, - single object fields with a sub-selection are recursed (depth-capped at
MAX_ENTITY_PROJECTION_DEPTH), - list fields, scalar fields, sub-selection-less object fields and over-depth fields pass through their stored value (matching the SQL side’s full-sub-blob fallback),
__typenameis emitted only where the client selected it.
type_name is the concrete GraphQL object type of entity (resolved by the
caller). selections is the result selection set for this level, with inline
... on T fragments preserved; an empty slice means “no field filtering”
and returns the stored entity unchanged.