Document SDL schema export in the book
This commit is contained in:
parent
db66d50e41
commit
87b7c28536
|
@ -16,6 +16,7 @@
|
||||||
- [Schema](define_schema.md)
|
- [Schema](define_schema.md)
|
||||||
- [Query and Mutation](query_and_mutation.md)
|
- [Query and Mutation](query_and_mutation.md)
|
||||||
- [Subscription](subscription.md)
|
- [Subscription](subscription.md)
|
||||||
|
- [SDL Export](sdl_export.md)
|
||||||
- [Utilities](utilities.md)
|
- [Utilities](utilities.md)
|
||||||
- [Field guard](field_guard.md)
|
- [Field guard](field_guard.md)
|
||||||
- [Input value validators](input_value_validators.md)
|
- [Input value validators](input_value_validators.md)
|
||||||
|
|
25
docs/en/src/sdl_export.md
Normal file
25
docs/en/src/sdl_export.md
Normal 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());
|
||||||
|
}
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user