Crates.io | aqlgen |
lib.rs | aqlgen |
version | 0.8.0 |
source | src |
created_at | 2022-06-13 09:58:27.199975 |
updated_at | 2022-06-22 13:04:20.238769 |
description | Schema generator for async-graphql 4.x |
homepage | https://github.com/linksplatform/aqlgen |
repository | https://github.com/linksplatform/aqlgen |
max_upload_size | |
id | 604994 |
size | 28,402 |
A schema generator for async-graphql 4.x
In order to install, just run the following command
cargo install aqlgen
Generate async-graphql 4.x schema in 4 easy steps
//! main.rs
mod schema;
...
# example schema
type Book {
id: ID!
name: String!
author: String!
}
input InputBook {
name: String!
author: String!
}
type QueryRoot {
books: [Book!]
}
type MutationRoot {
createBook(book: InputBook!): Book
}
# in project/src
cargo aqlgen --schema schema.graphql --output schema
//! book.rs
use async_graphql::*;
#[derive(Debug)]
pub struct Book;
#[Object]
impl Book {
pub async fn id(&self, ctx: &Context<'_>) -> ID {
todo!()
}
pub async fn name(&self, ctx: &Context<'_>) -> String {
todo!()
}
pub async fn author(&self, ctx: &Context<'_>) -> String {
todo!()
}
}
//! input_book.rs
use async_graphql::*;
#[derive(InputObject, Debug)]
pub struct InputBook {
pub name: String,
pub author: String,
}
//! query_root.rs
use super::super::Book;
use async_graphql::*;
#[derive(Debug)]
pub struct QueryRoot;
#[Object]
impl QueryRoot {
pub async fn books(&self, ctx: &Context<'_>) -> Option<Vec<Book>> {
todo!()
}
}
//! mutation_root.rs
use super::super::{Book, InputBook};
use async_graphql::*;
#[derive(Debug)]
pub struct MutationRoot;
#[Object]
impl MutationRoot {
pub async fn create_book(&self, ctx: &Context<'_>, book: InputBook) -> Option<Book> {
todo!()
}
}