pub struct UnionDefinition {
pub name: String,
pub member_types: Vec<String>,
pub description: Option<String>,
}Expand description
A GraphQL union type definition.
Unions represent a type that can be one of several possible object types. Unlike interfaces, union member types don’t need to share any fields. Per GraphQL spec §3.8, unions are useful for polymorphic returns.
§Example
use fraiseql_core::schema::UnionDefinition;
let search_result = UnionDefinition {
name: "SearchResult".to_string(),
member_types: vec!["User".to_string(), "Post".to_string(), "Comment".to_string()],
description: Some("Possible search result types".to_string()),
};Fields§
§name: StringUnion name (e.g., “SearchResult”).
member_types: Vec<String>Member types that this union can represent. Order is significant for resolution.
description: Option<String>Description of the union.
Implementations§
Source§impl UnionDefinition
impl UnionDefinition
Sourcepub fn with_member(self, type_name: impl Into<String>) -> Self
pub fn with_member(self, type_name: impl Into<String>) -> Self
Add a member type to this union.
Sourcepub fn with_members(self, members: Vec<String>) -> Self
pub fn with_members(self, members: Vec<String>) -> Self
Add multiple member types to this union.
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Set description.
Sourcepub fn contains_type(&self, type_name: &str) -> bool
pub fn contains_type(&self, type_name: &str) -> bool
Check if a type is a member of this union.
Trait Implementations§
Source§impl Clone for UnionDefinition
impl Clone for UnionDefinition
Source§fn clone(&self) -> UnionDefinition
fn clone(&self) -> UnionDefinition
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for UnionDefinition
impl Debug for UnionDefinition
Source§impl<'de> Deserialize<'de> for UnionDefinition
impl<'de> Deserialize<'de> for UnionDefinition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for UnionDefinition
impl PartialEq for UnionDefinition
Source§impl Serialize for UnionDefinition
impl Serialize for UnionDefinition
impl StructuralPartialEq for UnionDefinition
Auto Trait Implementations§
impl Freeze for UnionDefinition
impl RefUnwindSafe for UnionDefinition
impl Send for UnionDefinition
impl Sync for UnionDefinition
impl Unpin for UnionDefinition
impl UnsafeUnpin for UnionDefinition
impl UnwindSafe for UnionDefinition
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