Add `SDLExportOptions::include_specified_by` method to enable `specifiedBy` directive #1065
This commit is contained in:
parent
b54f598501
commit
f83d0a34d0
|
@ -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
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue