Merge pull request #1043 from dspicher/more-trailing-spaces
export_sdl: consistently avoid trailing spaces
This commit is contained in:
commit
d31cef270b
|
@ -281,29 +281,29 @@ impl Registry {
|
||||||
write!(sdl, "extend ").ok();
|
write!(sdl, "extend ").ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(sdl, "type {} ", name).ok();
|
write!(sdl, "type {}", name).ok();
|
||||||
self.write_implements(sdl, name);
|
self.write_implements(sdl, name);
|
||||||
|
|
||||||
if options.federation {
|
if options.federation {
|
||||||
if let Some(keys) = keys {
|
if let Some(keys) = keys {
|
||||||
for key in keys {
|
for key in keys {
|
||||||
write!(sdl, "@key(fields: \"{}\") ", key).ok();
|
write!(sdl, " @key(fields: \"{}\")", key).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if *shareable {
|
if *shareable {
|
||||||
write!(sdl, "@shareable ").ok();
|
write!(sdl, " @shareable").ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
if *inaccessible {
|
if *inaccessible {
|
||||||
write!(sdl, "@inaccessible ").ok();
|
write!(sdl, " @inaccessible").ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
for tag in *tags {
|
for tag in *tags {
|
||||||
write!(sdl, "@tag(name: \"{}\") ", tag.replace('"', "\\\"")).ok();
|
write!(sdl, " @tag(name: \"{}\")", tag.replace('"', "\\\"")).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
writeln!(sdl, "{{").ok();
|
writeln!(sdl, " {{").ok();
|
||||||
Self::export_fields(sdl, fields.values(), options);
|
Self::export_fields(sdl, fields.values(), options);
|
||||||
writeln!(sdl, "}}").ok();
|
writeln!(sdl, "}}").ok();
|
||||||
}
|
}
|
||||||
|
@ -324,25 +324,25 @@ impl Registry {
|
||||||
if options.federation && *extends {
|
if options.federation && *extends {
|
||||||
write!(sdl, "extend ").ok();
|
write!(sdl, "extend ").ok();
|
||||||
}
|
}
|
||||||
write!(sdl, "interface {} ", name).ok();
|
write!(sdl, "interface {}", name).ok();
|
||||||
|
|
||||||
if options.federation {
|
if options.federation {
|
||||||
if let Some(keys) = keys {
|
if let Some(keys) = keys {
|
||||||
for key in keys {
|
for key in keys {
|
||||||
write!(sdl, "@key(fields: \"{}\") ", key).ok();
|
write!(sdl, " @key(fields: \"{}\")", key).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if *inaccessible {
|
if *inaccessible {
|
||||||
write!(sdl, "@inaccessible ").ok();
|
write!(sdl, " @inaccessible").ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
for tag in *tags {
|
for tag in *tags {
|
||||||
write!(sdl, "@tag(name: \"{}\") ", tag.replace('"', "\\\"")).ok();
|
write!(sdl, " @tag(name: \"{}\")", tag.replace('"', "\\\"")).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.write_implements(sdl, name);
|
self.write_implements(sdl, name);
|
||||||
|
|
||||||
writeln!(sdl, "{{").ok();
|
writeln!(sdl, " {{").ok();
|
||||||
Self::export_fields(sdl, fields.values(), options);
|
Self::export_fields(sdl, fields.values(), options);
|
||||||
writeln!(sdl, "}}").ok();
|
writeln!(sdl, "}}").ok();
|
||||||
}
|
}
|
||||||
|
@ -358,13 +358,13 @@ impl Registry {
|
||||||
export_description(sdl, options, true, description);
|
export_description(sdl, options, true, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(sdl, "enum {} ", name).ok();
|
write!(sdl, "enum {}", name).ok();
|
||||||
if options.federation {
|
if options.federation {
|
||||||
if *inaccessible {
|
if *inaccessible {
|
||||||
write!(sdl, "@inaccessible ").ok();
|
write!(sdl, " @inaccessible").ok();
|
||||||
}
|
}
|
||||||
for tag in *tags {
|
for tag in *tags {
|
||||||
write!(sdl, "@tag(name: \"{}\") ", tag.replace('"', "\\\"")).ok();
|
write!(sdl, " @tag(name: \"{}\")", tag.replace('"', "\\\"")).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writeln!(sdl, "{{").ok();
|
writeln!(sdl, "{{").ok();
|
||||||
|
@ -405,17 +405,17 @@ impl Registry {
|
||||||
export_description(sdl, options, true, description);
|
export_description(sdl, options, true, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(sdl, "input {} ", name).ok();
|
write!(sdl, "input {}", name).ok();
|
||||||
|
|
||||||
if *oneof {
|
if *oneof {
|
||||||
write!(sdl, "@oneof ").ok();
|
write!(sdl, " @oneof").ok();
|
||||||
}
|
}
|
||||||
if options.federation {
|
if options.federation {
|
||||||
if *inaccessible {
|
if *inaccessible {
|
||||||
write!(sdl, "@inaccessible ").ok();
|
write!(sdl, " @inaccessible").ok();
|
||||||
}
|
}
|
||||||
for tag in *tags {
|
for tag in *tags {
|
||||||
write!(sdl, "@tag(name: \"{}\") ", tag.replace('"', "\\\"")).ok();
|
write!(sdl, " @tag(name: \"{}\")", tag.replace('"', "\\\"")).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writeln!(sdl, "{{").ok();
|
writeln!(sdl, "{{").ok();
|
||||||
|
@ -429,13 +429,13 @@ impl Registry {
|
||||||
if let Some(description) = field.description {
|
if let Some(description) = field.description {
|
||||||
export_description(sdl, options, false, description);
|
export_description(sdl, options, false, description);
|
||||||
}
|
}
|
||||||
write!(sdl, "\t{} ", export_input_value(&field)).ok();
|
write!(sdl, "\t{}", export_input_value(&field)).ok();
|
||||||
if options.federation {
|
if options.federation {
|
||||||
if field.inaccessible {
|
if field.inaccessible {
|
||||||
write!(sdl, "@inaccessible ").ok();
|
write!(sdl, " @inaccessible").ok();
|
||||||
}
|
}
|
||||||
for tag in field.tags {
|
for tag in field.tags {
|
||||||
write!(sdl, "@tag(name: \"{}\") ", tag.replace('"', "\\\"")).ok();
|
write!(sdl, " @tag(name: \"{}\")", tag.replace('"', "\\\"")).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writeln!(sdl).ok();
|
writeln!(sdl).ok();
|
||||||
|
@ -455,16 +455,16 @@ impl Registry {
|
||||||
export_description(sdl, options, true, description);
|
export_description(sdl, options, true, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(sdl, "union {} ", name).ok();
|
write!(sdl, "union {}", name).ok();
|
||||||
if options.federation {
|
if options.federation {
|
||||||
if *inaccessible {
|
if *inaccessible {
|
||||||
write!(sdl, "@inaccessible ").ok();
|
write!(sdl, " @inaccessible").ok();
|
||||||
}
|
}
|
||||||
for tag in *tags {
|
for tag in *tags {
|
||||||
write!(sdl, "@tag(name: \"{}\") ", tag.replace('"', "\\\"")).ok();
|
write!(sdl, " @tag(name: \"{}\")", tag.replace('"', "\\\"")).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write!(sdl, "=").ok();
|
write!(sdl, " =").ok();
|
||||||
|
|
||||||
for (idx, ty) in possible_types.iter().enumerate() {
|
for (idx, ty) in possible_types.iter().enumerate() {
|
||||||
if idx == 0 {
|
if idx == 0 {
|
||||||
|
@ -483,7 +483,7 @@ impl Registry {
|
||||||
if !implements.is_empty() {
|
if !implements.is_empty() {
|
||||||
write!(
|
write!(
|
||||||
sdl,
|
sdl,
|
||||||
"implements {} ",
|
" implements {}",
|
||||||
implements
|
implements
|
||||||
.iter()
|
.iter()
|
||||||
.map(AsRef::as_ref)
|
.map(AsRef::as_ref)
|
||||||
|
|
|
@ -534,6 +534,8 @@ pub async fn test_entity_inaccessible() {
|
||||||
assert!(schema_sdl.contains("input MyInputObjInaccessible @inaccessible"));
|
assert!(schema_sdl.contains("input MyInputObjInaccessible @inaccessible"));
|
||||||
// INPUT_FIELD_DEFINITION
|
// INPUT_FIELD_DEFINITION
|
||||||
assert!(schema_sdl.contains("inputFieldInaccessibleA: Int! @inaccessible"));
|
assert!(schema_sdl.contains("inputFieldInaccessibleA: Int! @inaccessible"));
|
||||||
|
// no trailing spaces
|
||||||
|
assert!(!schema_sdl.contains(" \n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
@ -733,4 +735,6 @@ pub async fn test_entity_tag() {
|
||||||
assert!(
|
assert!(
|
||||||
schema_sdl.contains(r#"inputFieldTaggedA: Int! @tag(name: "tagged_input_object_field")"#)
|
schema_sdl.contains(r#"inputFieldTaggedA: Int! @tag(name: "tagged_input_object_field")"#)
|
||||||
);
|
);
|
||||||
|
// no trailing spaces
|
||||||
|
assert!(!schema_sdl.contains(" \n"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user