fn main() {
println!("{}", cynic::to_query::<TestStruct>(TestArgs {}));
}
mod query_dsl {
type JSON = serde_json::Value;
cynic::query_dsl!("cynic/examples/simple.graphql");
}
use cynic::selection_set;
#[derive(cynic::FragmentArguments)]
struct TestArgs {}
#[derive(cynic::QueryFragment)]
#[cynic(
schema_path = "cynic/examples/simple.graphql",
query_module = "query_dsl",
graphql_type = "TestStruct",
argument_struct = "TestArgs"
)]
struct TestStruct {
#[cynic_arguments(x = Some(1), y = Some("1".to_string()))]
field_one: String,
nested: Nested,
opt_nested: Option<Nested>,
}
#[derive(cynic::QueryFragment)]
#[cynic(
schema_path = "cynic/examples/simple.graphql",
query_module = "query_dsl",
graphql_type = "Nested"
)]
struct Nested {
a_string: String,
opt_string: Option<String>,
}
#[derive(cynic::QueryFragment)]
#[cynic(
schema_path = "cynic/examples/simple.graphql",
query_module = "query_dsl",
graphql_type = "TestStruct"
)]
struct Test {
#[cynic_arguments(x = Some(1), y = Some("1".to_string()))]
field_one: String,
}
impl Test {
fn new(field_one: String) -> Self {
Test { field_one }
}
}
impl cynic::QueryRoot for query_dsl::TestStruct {}
mod test {
type JSON = serde_json::Value;
pub struct DateTime {}
impl cynic::Scalar for DateTime {
fn decode(_: &serde_json::Value) -> Result<Self, json_decode::DecodeError> {
Ok(DateTime {})
}
}
struct Upload;
}