pub struct QueryDefinition {
pub name: String,
pub return_type: String,
pub returns_list: bool,
pub nullable: bool,
pub arguments: Vec<ArgumentDefinition>,
pub sql_source: Option<String>,
pub description: Option<String>,
pub auto_params: AutoParams,
pub deprecation: Option<DeprecationInfo>,
}Expand description
A query definition compiled from @fraiseql.query.
Queries are declarative bindings to database views/tables. They describe what to fetch, not how to fetch it.
§Example
use fraiseql_core::schema::{QueryDefinition, AutoParams};
let query = QueryDefinition {
name: "users".to_string(),
return_type: "User".to_string(),
returns_list: true,
nullable: false,
arguments: vec![],
sql_source: Some("v_user".to_string()),
description: Some("Get all users".to_string()),
auto_params: AutoParams::default(),
deprecation: None,
};Fields§
§name: StringQuery name (e.g., “users”).
return_type: StringReturn type name (e.g., “User”).
returns_list: boolDoes this query return a list?
nullable: boolIs the return value nullable?
arguments: Vec<ArgumentDefinition>Query arguments.
sql_source: Option<String>SQL source table/view (for direct table queries).
description: Option<String>Description.
auto_params: AutoParamsAuto-wired parameters (where, orderBy, limit, offset).
deprecation: Option<DeprecationInfo>Deprecation information (from @deprecated directive). When set, this query is marked as deprecated in the schema.
Implementations§
Source§impl QueryDefinition
impl QueryDefinition
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 query definition.
Sourcepub fn returning_list(self) -> Self
pub fn returning_list(self) -> Self
Set this query to return a list.
Sourcepub fn with_sql_source(self, source: impl Into<String>) -> Self
pub fn with_sql_source(self, source: impl Into<String>) -> Self
Set the SQL source.
Sourcepub fn deprecated(self, reason: Option<String>) -> Self
pub fn deprecated(self, reason: Option<String>) -> Self
Mark this query as deprecated.
§Example
use fraiseql_core::schema::QueryDefinition;
let query = QueryDefinition::new("oldUsers", "User")
.deprecated(Some("Use 'users' instead".to_string()));
assert!(query.is_deprecated());Sourcepub fn is_deprecated(&self) -> bool
pub fn is_deprecated(&self) -> bool
Check if this query 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 QueryDefinition
impl Clone for QueryDefinition
Source§fn clone(&self) -> QueryDefinition
fn clone(&self) -> QueryDefinition
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 QueryDefinition
impl Debug for QueryDefinition
Source§impl<'de> Deserialize<'de> for QueryDefinition
impl<'de> Deserialize<'de> for QueryDefinition
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 QueryDefinition
impl PartialEq for QueryDefinition
Source§impl Serialize for QueryDefinition
impl Serialize for QueryDefinition
impl StructuralPartialEq for QueryDefinition
Auto Trait Implementations§
impl Freeze for QueryDefinition
impl RefUnwindSafe for QueryDefinition
impl Send for QueryDefinition
impl Sync for QueryDefinition
impl Unpin for QueryDefinition
impl UnwindSafe for QueryDefinition
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