pub struct InterfaceDefinition {
pub name: String,
pub fields: Vec<FieldDefinition>,
pub description: Option<String>,
}Expand description
A GraphQL interface type definition.
Interfaces define a common set of fields that multiple types can implement. They enable polymorphic queries where a field can return any type that implements the interface.
§Example
use fraiseql_core::schema::{InterfaceDefinition, FieldDefinition, FieldType};
let node_interface = InterfaceDefinition {
name: "Node".to_string(),
fields: vec![
FieldDefinition::new("id", FieldType::Id),
],
description: Some("An object with an ID".to_string()),
};Fields§
§name: StringInterface name (e.g., “Node”).
fields: Vec<FieldDefinition>Fields that implementing types must define.
description: Option<String>Description of the interface.
Implementations§
Source§impl InterfaceDefinition
impl InterfaceDefinition
Sourcepub fn with_field(self, field: FieldDefinition) -> Self
pub fn with_field(self, field: FieldDefinition) -> Self
Add a field to this interface.
Sourcepub fn with_fields(self, fields: Vec<FieldDefinition>) -> Self
pub fn with_fields(self, fields: Vec<FieldDefinition>) -> Self
Add multiple fields to this interface.
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Set description.
Sourcepub fn find_field(&self, name: &str) -> Option<&FieldDefinition>
pub fn find_field(&self, name: &str) -> Option<&FieldDefinition>
Find a field by name.
Trait Implementations§
Source§impl Clone for InterfaceDefinition
impl Clone for InterfaceDefinition
Source§fn clone(&self) -> InterfaceDefinition
fn clone(&self) -> InterfaceDefinition
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 InterfaceDefinition
impl Debug for InterfaceDefinition
Source§impl<'de> Deserialize<'de> for InterfaceDefinition
impl<'de> Deserialize<'de> for InterfaceDefinition
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 InterfaceDefinition
impl PartialEq for InterfaceDefinition
Source§impl Serialize for InterfaceDefinition
impl Serialize for InterfaceDefinition
impl StructuralPartialEq for InterfaceDefinition
Auto Trait Implementations§
impl Freeze for InterfaceDefinition
impl RefUnwindSafe for InterfaceDefinition
impl Send for InterfaceDefinition
impl Sync for InterfaceDefinition
impl Unpin for InterfaceDefinition
impl UnwindSafe for InterfaceDefinition
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