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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more