Commit 260620da authored by Alp Deniz Ogut's avatar Alp Deniz Ogut
Browse files

Use gql file for ease

parent f7c9971c
Showing with 12 additions and 4 deletions
+12 -4
query {
uid (id: "5") {
age
}
}
\ No newline at end of file
use core::panic;
use std::fs;
use std::error::Error;
use graphql_parser::query::Field;
use graphql_parser::query::OperationDefinition;
......@@ -13,15 +15,16 @@ fn print_type_of<T>(_: &T) {
}
fn main() {
fn main() -> Result<(), Box<dyn Error>> {
let query_string = fs::read_to_string("graph_query.gql")?;
// let str = String::from("query { queryPersons{ name } }");
let str = String::from("query { uid(id: \"0x1000\") { age } }");
let str = String::from(query_string);
let res = parse_query::<String>(&str).unwrap().to_owned();
println!("{}", res);
println!("{}", res.definitions.len());
for def in res.definitions {
Ok(for def in res.definitions {
if let Definition::Operation(op) = def {
if let OperationDefinition::Query(query) = op{
......@@ -41,7 +44,7 @@ fn main() {
} else {
panic!("Fragments are not supported");
}
}
})
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment