pub struct InputFieldDefinition {
pub name: String,
pub field_type: String,
pub description: Option<String>,
pub default_value: Option<String>,
pub deprecation: Option<DeprecationInfo>,
pub validation_rules: Vec<ValidationRule>,
}Expand description
A field within a GraphQL input object type.
§Example
use fraiseql_core::schema::InputFieldDefinition;
let field = InputFieldDefinition::new("email", "String!")
.with_description("User's email address")
.with_default_value("\"user@example.com\"");Fields§
§name: StringField name.
field_type: StringField type (e.g., "String!", "[Int]", "UserFilter").
description: Option<String>Description.
default_value: Option<String>Default value (as JSON string).
deprecation: Option<DeprecationInfo>Deprecation information (if this field is deprecated).
validation_rules: Vec<ValidationRule>Validation rules applied to this field (from @validate directives).
Implementations§
Source§impl InputFieldDefinition
impl InputFieldDefinition
Sourcepub fn new(name: impl Into<String>, field_type: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, field_type: impl Into<String>) -> Self
Create a new input field.
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Set description.
Sourcepub fn with_default_value(self, value: impl Into<String>) -> Self
pub fn with_default_value(self, value: impl Into<String>) -> Self
Set default value.
Sourcepub fn deprecated(self, reason: Option<String>) -> Self
pub fn deprecated(self, reason: Option<String>) -> Self
Mark this field as deprecated.
Sourcepub fn is_deprecated(&self) -> bool
pub fn is_deprecated(&self) -> bool
Check if this field is deprecated.
Sourcepub fn is_required(&self) -> bool
pub fn is_required(&self) -> bool
Check if this field is required (non-nullable without default).
Sourcepub fn with_validation_rule(self, rule: ValidationRule) -> Self
pub fn with_validation_rule(self, rule: ValidationRule) -> Self
Add a validation rule to this field.
Sourcepub fn with_validation_rules(self, rules: Vec<ValidationRule>) -> Self
pub fn with_validation_rules(self, rules: Vec<ValidationRule>) -> Self
Add multiple validation rules to this field.
Sourcepub fn has_validation_rules(&self) -> bool
pub fn has_validation_rules(&self) -> bool
Check if this field has validation rules.
Trait Implementations§
Source§impl Clone for InputFieldDefinition
impl Clone for InputFieldDefinition
Source§fn clone(&self) -> InputFieldDefinition
fn clone(&self) -> InputFieldDefinition
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 InputFieldDefinition
impl Debug for InputFieldDefinition
Source§impl<'de> Deserialize<'de> for InputFieldDefinition
impl<'de> Deserialize<'de> for InputFieldDefinition
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 InputFieldDefinition
impl PartialEq for InputFieldDefinition
Source§impl Serialize for InputFieldDefinition
impl Serialize for InputFieldDefinition
impl StructuralPartialEq for InputFieldDefinition
Auto Trait Implementations§
impl Freeze for InputFieldDefinition
impl RefUnwindSafe for InputFieldDefinition
impl Send for InputFieldDefinition
impl Sync for InputFieldDefinition
impl Unpin for InputFieldDefinition
impl UnwindSafe for InputFieldDefinition
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