diff --git a/CHANGELOG.md b/CHANGELOG.md index 7730457c..419ca495 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add `no_cache` for `cache_control` attribute [#1051](https://github.com/async-graphql/async-graphql/issues/1051) - Resurrect code generation through tests [#1062](https://github.com/async-graphql/async-graphql/pull/1062) - Support for primitive type in CursorType [#1049](https://github.com/async-graphql/async-graphql/pull/1049) +- Add `SDLExportOptions::include_specified_by` method to enable `specifiedBy` directive [#1065](https://github.com/async-graphql/async-graphql/issues/1065) # [4.0.12] 2022-08-24 diff --git a/src/registry/export_sdl.rs b/src/registry/export_sdl.rs index 0461d380..2adf2596 100644 --- a/src/registry/export_sdl.rs +++ b/src/registry/export_sdl.rs @@ -13,6 +13,7 @@ pub struct SDLExportOptions { sorted_enum_values: bool, federation: bool, prefer_single_line_descriptions: bool, + include_specified_by: bool, } impl SDLExportOptions { @@ -71,6 +72,14 @@ impl SDLExportOptions { ..self } } + + /// Includes `specifiedBy` directive in SDL + pub fn include_specified_by(self) -> Self { + Self { + include_specified_by: true, + ..self + } + } } impl Registry { @@ -218,13 +227,15 @@ impl Registry { } write!(sdl, "scalar {}", name).ok(); - if let Some(specified_by_url) = specified_by_url { - write!( - sdl, - " @specifiedBy(url: \"{}\")", - specified_by_url.replace('"', "\\\"") - ) - .ok(); + if options.include_specified_by { + if let Some(specified_by_url) = specified_by_url { + write!( + sdl, + " @specifiedBy(url: \"{}\")", + specified_by_url.replace('"', "\\\"") + ) + .ok(); + } } if options.federation {