Quote key names in complex type field argument literals
@@ -158,7 +158,7 @@ pub fn write_value(schema: &SDLSchema, value: &Value, mut result: &mut impl Writ
pub struct PrinterOptions {
pub compact: bool,
pub sort_keys: bool,
- pub print_enums_as_str: bool,
+ pub json_format: bool,
/// Print `data` from Directive nodes
pub debug_directive_data: bool,
}
@@ -570,7 +570,7 @@ impl<'schema, 'writer, W: Write> Printer<'schema, 'writer, W> {
ConstantValue::Boolean(val) => write!(self.writer, "{}", val),
ConstantValue::Null() => write!(self.writer, "null"),
ConstantValue::Enum(val) => {
- if self.options.print_enums_as_str {
+ if self.options.json_format {
write!(self.writer, "\"{}\"", val)
} else {
write!(self.writer, "{}", val)
@@ -598,7 +598,11 @@ impl<'schema, 'writer, W: Write> Printer<'schema, 'writer, W> {
write!(self.writer, " ")?;
}
}
+ if self.options.json_format {
+ write!(self.writer, "\"{}\":", arg.name.item)?;
+ } else {
write!(self.writer, "{}:", arg.name.item)?;
+ }
if !self.options.compact {
write!(self.writer, " ")?;
}
