Document SDL schema export in the book

This commit is contained in:
tobi 2021-04-03 11:41:37 +02:00
parent db66d50e41
commit 87b7c28536
2 changed files with 26 additions and 0 deletions

View File

@ -16,6 +16,7 @@
- [Schema](define_schema.md)
- [Query and Mutation](query_and_mutation.md)
- [Subscription](subscription.md)
- [SDL Export](sdl_export.md)
- [Utilities](utilities.md)
- [Field guard](field_guard.md)
- [Input value validators](input_value_validators.md)

25
docs/en/src/sdl_export.md Normal file
View File

@ -0,0 +1,25 @@
# SDL Export
You can export your schema in Schema Definition Language (SDL) by using the `Schema::sdl()` method.
```rust
use async_graphql::*;
struct Query;
#[Object]
impl Query {
async fn add(&self, u: i32, v: i32) -> i32 {
u + v
}
}
#[tokio::main]
async fn main() {
let schema = Schema::build(Query, EmptyMutation, EmptySubscription).finish();
// Print the schema in SDL format
println!("{}", &schema.sdl());
}
```