A schema generator for async-graphql 4.x
In order to install, just run the following command
shell
cargo install aqlgen
Generate async-graphql 4.x schema in 4 easy steps 1. Create a new empty rust module ```rust //! main.rs mod schema;
...
2. Put your schema any folder (for example)
graphql
type Book {
id: ID!
name: String!
author: String!
}
input InputBook { name: String! author: String! }
type QueryRoot { books: [Book!] }
type MutationRoot {
createBook(book: InputBook!): Book
}
3. Run aqlgen
shell
cargo aqlgen --schema schema.graphql --output model
4. Enjoy your generation
rust
//! book.rs
use async_graphql::*;
pub struct Book;
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!()
}
} ```
```rust //! inputbook.rs use asyncgraphql::*;
pub struct InputBook { pub name: String, pub author: String, } ```
```rust //! queryroot.rs use crate::model::Book; use asyncgraphql::*;
pub struct QueryRoot;
impl QueryRoot {
pub async fn books(&self, ctx: &Context<'_>) -> Option
```rust //! mutationroot.rs use crate::model::Book; use crate::model::InputBook; use asyncgraphql::*;
pub struct MutationRoot;
impl MutationRoot {
pub async fn createbook(&self, ctx: &Context<'>, book: InputBook) -> Option