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>,
pub jsonb_column: String,
}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,
jsonb_column: "data".to_string(),
};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.
jsonb_column: StringJSONB column name (e.g., “data”). Used to extract data from JSONB columns in query results.
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
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more