Rust macro framework to build graphql resolvers using sea-orm
and graphql-async
with powerful nested filter and relationship.
use grand_line::*;
use serde_json::to_string as json;
// create the graphql input object for pagination
pagination!();
// create a sea orm model and graphql object
// id, created_at, updated_at will be inserted automatically
#[model]
pub struct Todo {
pub content: String,
pub done: bool,
}
// search Todo with filter, sort, pagination
#[search(Todo)]
fn resolver() {
println!(
"todoSearch filter={} order_by={} page={}",
json(&filter)?,
json(&order_by)?,
json(&page)?,
);
(None, None)
}
// we can also have a custom name
// with extra filter, or default sort in the resolver as well
#[search(Todo)]
fn todoSearch2024() {
let f = todo_filter!({
content_starts_with: "2024",
});
let o = todo_order_by!([DoneAsc, ContentAsc]);
(f, o)
}
// checkout the examples or documentation for more builtin crud and available api!
TODO