pub struct ProjectionField {
pub name: String,
pub kind: FieldKind,
pub sub_fields: Option<Vec<ProjectionField>>,
}Expand description
A field in a SQL projection with type information.
Used by typed projection generators to choose the correct JSONB extraction
operator based on FieldKind: -> (preserves JSONB) for composites and
native scalars, ->> (text) for text scalars (String, ID).
When sub_fields is populated on a composite field, generate_typed_projection_sql
will recurse and emit a nested jsonb_build_object(...) instead of returning the full
composite blob. Leave sub_fields as None to get the existing data->'field'
behaviour (full blob, no sub-selection).
Fields§
§name: StringGraphQL field name (camelCase).
kind: FieldKindSemantic kind of the field, controlling the JSONB extraction operator.
sub_fields: Option<Vec<ProjectionField>>Sub-fields to project for composite (Object) types.
When Some and non-empty, the generator recurses and produces a nested
jsonb_build_object instead of returning the entire composite blob.
Set to None (or Some([])) to fall back to data->'field'.
List fields should always use None — sub-projection inside aggregated
JSONB arrays is out of scope for this first iteration.
Implementations§
Source§impl ProjectionField
impl ProjectionField
Sourcepub fn scalar(name: impl Into<String>) -> Self
pub fn scalar(name: impl Into<String>) -> Self
Create a text scalar projection field (uses ->> text extraction).
Use for String and ID fields only. Other scalars (Int, Float, Boolean,
DateTime, etc.) should use Self::native.
Sourcepub fn native(name: impl Into<String>) -> Self
pub fn native(name: impl Into<String>) -> Self
Create a native JSON scalar projection field (uses -> to preserve type).
Use for Int, Float, Boolean, DateTime, Date, Time, Decimal, Vector, and
other non-text scalars. ->> would coerce these to strings inside
jsonb_build_object, losing type information.
Sourcepub fn composite(name: impl Into<String>) -> Self
pub fn composite(name: impl Into<String>) -> Self
Create a composite (object/list) projection field (uses -> JSONB extraction).
Sourcepub fn composite_with_sub_fields(
name: impl Into<String>,
sub_fields: Vec<Self>,
) -> Self
pub fn composite_with_sub_fields( name: impl Into<String>, sub_fields: Vec<Self>, ) -> Self
Create a composite projection field with known sub-fields.
The generator will recurse into sub_fields and emit a nested
jsonb_build_object(...) rather than returning the full composite blob.
Sourcepub const fn is_composite(&self) -> bool
pub const fn is_composite(&self) -> bool
Whether this field is a composite type (Object or List).
Trait Implementations§
Source§impl Clone for ProjectionField
impl Clone for ProjectionField
Source§fn clone(&self) -> ProjectionField
fn clone(&self) -> ProjectionField
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProjectionField
impl Debug for ProjectionField
Source§impl From<String> for ProjectionField
impl From<String> for ProjectionField
Source§impl PartialEq for ProjectionField
impl PartialEq for ProjectionField
impl Eq for ProjectionField
impl StructuralPartialEq for ProjectionField
Auto Trait Implementations§
impl Freeze for ProjectionField
impl RefUnwindSafe for ProjectionField
impl Send for ProjectionField
impl Sync for ProjectionField
impl Unpin for ProjectionField
impl UnsafeUnpin for ProjectionField
impl UnwindSafe for ProjectionField
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more