fraiseql_cli/config/toml_schema/
operations.rs1use serde::{Deserialize, Serialize};
4
5use super::types::ArgumentDefinition;
6
7#[derive(Debug, Clone, Deserialize, Serialize)]
20#[serde(default, deny_unknown_fields)]
21pub struct QueryDefaults {
22 #[serde(rename = "where", default = "default_true")]
24 pub where_clause: bool,
25 #[serde(default = "default_true")]
27 pub order_by: bool,
28 #[serde(default = "default_true")]
30 pub limit: bool,
31 #[serde(default = "default_true")]
33 pub offset: bool,
34}
35
36impl Default for QueryDefaults {
37 fn default() -> Self {
38 Self {
39 where_clause: true,
40 order_by: true,
41 limit: true,
42 offset: true,
43 }
44 }
45}
46
47fn default_true() -> bool {
48 true
49}
50
51#[derive(Debug, Clone, Deserialize, Serialize)]
53#[serde(default, deny_unknown_fields)]
54pub struct SchemaMetadata {
55 pub name: String,
57 pub version: String,
59 pub description: Option<String>,
61 pub database_target: String,
63}
64
65impl Default for SchemaMetadata {
66 fn default() -> Self {
67 Self {
68 name: "myapp".to_string(),
69 version: "1.0.0".to_string(),
70 description: None,
71 database_target: "postgresql".to_string(),
72 }
73 }
74}
75
76#[derive(Debug, Clone, Deserialize, Serialize)]
78#[serde(default, deny_unknown_fields)]
79pub struct QueryDefinition {
80 pub return_type: String,
82 #[serde(default)]
84 pub return_array: bool,
85 pub sql_source: String,
87 pub description: Option<String>,
89 pub args: Vec<ArgumentDefinition>,
91}
92
93impl Default for QueryDefinition {
94 fn default() -> Self {
95 Self {
96 return_type: "String".to_string(),
97 return_array: false,
98 sql_source: "v_entity".to_string(),
99 description: None,
100 args: vec![],
101 }
102 }
103}
104
105#[derive(Debug, Clone, Deserialize, Serialize)]
107#[serde(default, deny_unknown_fields)]
108pub struct MutationDefinition {
109 pub return_type: String,
111 pub sql_source: String,
113 pub operation: String,
115 pub description: Option<String>,
117 pub args: Vec<ArgumentDefinition>,
119}
120
121impl Default for MutationDefinition {
122 fn default() -> Self {
123 Self {
124 return_type: "String".to_string(),
125 sql_source: "fn_operation".to_string(),
126 operation: "CREATE".to_string(),
127 description: None,
128 args: vec![],
129 }
130 }
131}