pub struct MutationDefinition {
pub name: String,
pub return_type: String,
pub arguments: Vec<ArgumentDefinition>,
pub description: Option<String>,
pub operation: MutationOperation,
pub deprecation: Option<DeprecationInfo>,
pub sql_source: Option<String>,
}Expand description
A mutation definition compiled from @fraiseql.mutation.
Mutations are declarative bindings to database functions. They describe which function to call, not arbitrary logic.
§Example
use fraiseql_core::schema::{MutationDefinition, MutationOperation};
let mutation = MutationDefinition {
name: "createUser".to_string(),
return_type: "User".to_string(),
arguments: vec![],
description: Some("Create a new user".to_string()),
operation: MutationOperation::Insert { table: "users".to_string() },
deprecation: None,
};Fields§
§name: StringMutation name (e.g., “createUser”).
return_type: StringReturn type name.
arguments: Vec<ArgumentDefinition>Input arguments.
description: Option<String>Description.
operation: MutationOperationSQL operation type.
deprecation: Option<DeprecationInfo>Deprecation information (from @deprecated directive). When set, this mutation is marked as deprecated in the schema.
sql_source: Option<String>PostgreSQL function name to call for this mutation.
When set, the runtime calls SELECT * FROM {sql_source}($1, $2, ...) with the
mutation arguments in ArgumentDefinition order, and parses the result as an
app.mutation_response composite row.
Implementations§
Source§impl MutationDefinition
impl MutationDefinition
Sourcepub fn new(name: impl Into<String>, return_type: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, return_type: impl Into<String>) -> Self
Create a new mutation definition.
Sourcepub fn deprecated(self, reason: Option<String>) -> Self
pub fn deprecated(self, reason: Option<String>) -> Self
Mark this mutation as deprecated.
§Example
use fraiseql_core::schema::MutationDefinition;
let mutation = MutationDefinition::new("oldCreateUser", "User")
.deprecated(Some("Use 'createUser' instead".to_string()));
assert!(mutation.is_deprecated());Sourcepub fn is_deprecated(&self) -> bool
pub fn is_deprecated(&self) -> bool
Check if this mutation is deprecated.
Sourcepub fn deprecation_reason(&self) -> Option<&str>
pub fn deprecation_reason(&self) -> Option<&str>
Get the deprecation reason if deprecated.
Trait Implementations§
Source§impl Clone for MutationDefinition
impl Clone for MutationDefinition
Source§fn clone(&self) -> MutationDefinition
fn clone(&self) -> MutationDefinition
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more