From 87b7c285364d7949e3c4050d97f91769e6439b77 Mon Sep 17 00:00:00 2001 From: tobi Date: Sat, 3 Apr 2021 11:41:37 +0200 Subject: [PATCH] Document SDL schema export in the book --- docs/en/src/SUMMARY.md | 1 + docs/en/src/sdl_export.md | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 docs/en/src/sdl_export.md diff --git a/docs/en/src/SUMMARY.md b/docs/en/src/SUMMARY.md index 281ecccf..c11a8739 100644 --- a/docs/en/src/SUMMARY.md +++ b/docs/en/src/SUMMARY.md @@ -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) diff --git a/docs/en/src/sdl_export.md b/docs/en/src/sdl_export.md new file mode 100644 index 00000000..fb05c652 --- /dev/null +++ b/docs/en/src/sdl_export.md @@ -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()); +} +```