pub struct ResultProjector { /* private fields */ }Expand description
Result projector - high-level result transformation.
Implementations§
Source§impl ResultProjector
impl ResultProjector
Sourcepub fn new(fields: Vec<String>) -> Self
pub fn new(fields: Vec<String>) -> Self
Create new result projector from field names (no aliases).
Sourcepub fn with_mappings(fields: Vec<FieldMapping>) -> Self
pub fn with_mappings(fields: Vec<FieldMapping>) -> Self
Create new result projector with field mappings (supports aliases).
Sourcepub fn with_typename(self, typename: impl Into<String>) -> Self
pub fn with_typename(self, typename: impl Into<String>) -> Self
Set __typename to include in all projected objects.
Per GraphQL spec §2.7, __typename returns the name of the object type.
This should be called when the client requests __typename in the selection set.
Sourcepub fn project_results(
&self,
results: &[JsonbValue],
is_list: bool,
) -> Result<JsonValue>
pub fn project_results( &self, results: &[JsonbValue], is_list: bool, ) -> Result<JsonValue>
Sourcepub fn wrap_in_data_envelope(result: JsonValue, query_name: &str) -> JsonValue
pub fn wrap_in_data_envelope(result: JsonValue, query_name: &str) -> JsonValue
Sourcepub fn add_typename_only(
&self,
projected_data: &JsonbValue,
typename: &str,
) -> Result<JsonValue>
pub fn add_typename_only( &self, projected_data: &JsonbValue, typename: &str, ) -> Result<JsonValue>
Add __typename field to SQL-projected data.
For data that has already been projected at the SQL level, we only need to add
the __typename field in Rust. This is much faster than projecting all fields
since the SQL already filtered to only requested fields.
§Arguments
projected_data- JSONB data already projected by SQLtypename- GraphQL type name to add
§Returns
New JSONB value with __typename field added
§Example
ⓘ
// Database already returned only: { "id": "123", "name": "Alice" }
let result = projector.add_typename_only(
&JsonbValue::new(json!({ "id": "123", "name": "Alice" })),
"User"
).unwrap();
// Result: { "id": "123", "name": "Alice", "__typename": "User" }Sourcepub fn wrap_error(error: &FraiseQLError) -> JsonValue
pub fn wrap_error(error: &FraiseQLError) -> JsonValue
Auto Trait Implementations§
impl Freeze for ResultProjector
impl RefUnwindSafe for ResultProjector
impl Send for ResultProjector
impl Sync for ResultProjector
impl Unpin for ResultProjector
impl UnsafeUnpin for ResultProjector
impl UnwindSafe for ResultProjector
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
Mutably borrows from an owned value. Read more