pub struct ProjectionMapper {
pub fields: Vec<FieldMapping>,
pub typename: Option<String>,
pub federation_mode: bool,
}Expand description
Projection mapper - maps JSONB fields to GraphQL selection set.
Fields§
§fields: Vec<FieldMapping>Fields to project (with optional aliases).
typename: Option<String>Optional __typename value to add to each object.
federation_mode: boolWhen true, __typename is injected unconditionally regardless of selection set.
Used by federation _entities resolver where the gateway always expects __typename.
Implementations§
Source§impl ProjectionMapper
impl ProjectionMapper
Sourcepub fn new(fields: Vec<String>) -> Self
pub fn new(fields: Vec<String>) -> Self
Create new projection mapper from field names (no aliases).
Sourcepub const fn with_mappings(fields: Vec<FieldMapping>) -> Self
pub const fn with_mappings(fields: Vec<FieldMapping>) -> Self
Create new projection mapper 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 projected objects.
Sourcepub const fn with_federation_mode(self, enabled: bool) -> Self
pub const fn with_federation_mode(self, enabled: bool) -> Self
Enable federation mode: __typename is always injected regardless of selection set.
Sourcepub fn project(&self, jsonb: &JsonbValue) -> Result<JsonValue>
pub fn project(&self, jsonb: &JsonbValue) -> Result<JsonValue>
Sourcepub fn project_json_object(
&self,
map: &Map<String, JsonValue>,
) -> Result<JsonValue>
pub fn project_json_object( &self, map: &Map<String, JsonValue>, ) -> Result<JsonValue>
Project object fields from JSON object.
Maps source keys to output keys according to the configured FieldMappings,
injects __typename when configured, and recursively projects nested objects
and arrays.
§Errors
Returns error if nested value projection fails.
Trait Implementations§
Source§impl Clone for ProjectionMapper
impl Clone for ProjectionMapper
Source§fn clone(&self) -> ProjectionMapper
fn clone(&self) -> ProjectionMapper
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ProjectionMapper
impl RefUnwindSafe for ProjectionMapper
impl Send for ProjectionMapper
impl Sync for ProjectionMapper
impl Unpin for ProjectionMapper
impl UnsafeUnpin for ProjectionMapper
impl UnwindSafe for ProjectionMapper
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<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