Skip to content

Latest commit

 

History

History
61 lines (48 loc) · 1.52 KB

README.md

File metadata and controls

61 lines (48 loc) · 1.52 KB

GrandLine

Rust macro framework to build graphql resolvers using sea-orm and graphql-async with powerful nested filter and relationship.

GrandLine banner

Examples

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!

Altair screenshot

Documentation

TODO