public static void WriteStringValue( this DocumentWriter writer, StringValueNode node) { if (node.Block) { writer.Write("\"\"\""); var lines = node.Value .Replace("\"\"\"", "\\\"\"\"") .Replace("\r", string.Empty) .Split('\n'); foreach (var line in lines) { writer.WriteLine(); writer.WriteIndentation(); writer.Write(line); } writer.WriteLine(); writer.WriteIndentation(); writer.Write("\"\"\""); } else { writer.Write($"\"{WriteEscapeCharacters(node.Value)}\""); } }
public static void WriteVariable( this DocumentWriter writer, VariableNode node) { writer.Write('$'); writer.Write(node.Name.Value); }
public static void WriteListType( this DocumentWriter writer, ListTypeNode node) { writer.Write('['); writer.WriteType(node.Type); writer.Write(']'); }
public static void WriteObjectValue( this DocumentWriter writer, ObjectValueNode node) { writer.Write("{ "); writer.WriteMany(node.Fields, (n, w) => w.WriteObjectField(n)); writer.Write(" }"); }
public static void WriteListValue( this DocumentWriter writer, ListValueNode node) { writer.Write("[ "); writer.WriteMany(node.Items, (n, w) => w.WriteValue(n)); writer.Write(" ]"); }
public static void WriteField( this DocumentWriter writer, NameNode name, IValueNode value) { writer.Write(name.Value); writer.Write(": "); writer.WriteValue(value); }
public static void WriteNonNullType( this DocumentWriter writer, NonNullTypeNode node) { writer.WriteType(node.Type); writer.Write('!'); }
public static void WriteDirective( this DocumentWriter writer, DirectiveNode node) { writer.Write('@'); writer.WriteName(node.Name); if (node.Arguments.Any()) { writer.Write('('); writer.WriteMany(node.Arguments, (n, w) => w.WriteArgument(n)); writer.Write(')'); } }
public static void WriteMany <T>( this DocumentWriter writer, IEnumerable <T> items, Action <T, DocumentWriter> action, string separator) { if (items.Any()) { action(items.First(), writer); foreach (T item in items.Skip(1)) { writer.Write(separator); action(item, writer); } } }
public static void WriteFloatValue( this DocumentWriter writer, FloatValueNode node) { writer.Write(node.Value); }
protected override void VisitOperationDefinition( OperationDefinitionNode node) { if (node.Name != null) { _writer.Write(node.Operation.ToString().ToLowerInvariant()); _writer.WriteSpace(); VisitName(node.Name); if (node.VariableDefinitions.Any()) { _writer.Write('('); WriteMany( node.VariableDefinitions, VisitVariableDefinition); _writer.Write(')'); } WriteMany(node.Directives, VisitDirective, " "); _writer.WriteSpace(); } VisitSelectionSet(node.SelectionSet); }
public static void WriteName( this DocumentWriter writer, NameNode node) { writer.Write(node.Value); }
public static void WriteNullValue( this DocumentWriter writer, NullValueNode node) { writer.Write("null"); }
public static void WriteEnumValue( this DocumentWriter writer, EnumValueNode node) { writer.Write(node.Value); }
public static void WriteBooleanValue( this DocumentWriter writer, BooleanValueNode node) { writer.Write(node.Value.ToString().ToLowerInvariant()); }