private NodePrinter<FragmentSpread> fragmentSpread() { return (out, node) -> { String name = node.getName(); String directives = directives(node.getDirectives()); out.printf("...%s%s", name, directives); }; }
private NodePrinter<ScalarTypeDefinition> scalarTypeDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( "scalar", node.getName(), directives(node.getDirectives()))); }; }
private NodePrinter<EnumValueDefinition> enumValueDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( node.getName(), directives(node.getDirectives()) )); }; }
private NodePrinter<SchemaDefinition> schemaDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( "schema", directives(node.getDirectives()), block(node.getOperationTypeDefinitions()) )); }; }
private NodePrinter<InterfaceTypeDefinition> interfaceTypeDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( "interface", node.getName(), directives(node.getDirectives()), block(node.getFieldDefinitions()) ) ); }; }
private NodePrinter<EnumTypeDefinition> enumTypeDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( "enum", node.getName(), directives(node.getDirectives()), block(node.getEnumValueDefinitions()) )); }; }
private NodePrinter<InputObjectTypeDefinition> inputObjectTypeDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( "input", node.getName(), directives(node.getDirectives()), block(node.getInputValueDefinitions()) ) ); }; }
private NodePrinter<FragmentDefinition> fragmentDefinition() { return (out, node) -> { String name = node.getName(); String typeCondition = type(node.getTypeCondition()); String directives = directives(node.getDirectives()); String selectionSet = node(node.getSelectionSet()); out.printf("fragment %s on %s ", name, typeCondition); out.printf("%s", directives + selectionSet); }; }
private NodePrinter<UnionTypeDefinition> unionTypeDefinition() { String barSep = compactMode ? "|" : " | "; String equals = compactMode ? "=" : "= "; return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( "union", node.getName(), directives(node.getDirectives()), equals + join(node.getMemberTypes(), barSep) )); }; }
private NodePrinter<InputValueDefinition> inputValueDefinition() { String nameTypeSep = compactMode ? ":" : ": "; String defaultValueEquals = compactMode ? "=" : "= "; return (out, node) -> { Value defaultValue = node.getDefaultValue(); out.printf("%s", comments(node)); out.printf("%s", spaced( node.getName() + nameTypeSep + type(node.getType()), wrap(defaultValueEquals, defaultValue, ""), directives(node.getDirectives()) ) ); }; }
private NodePrinter<ObjectTypeDefinition> objectTypeDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( "type", node.getName(), wrap("implements ", join(node.getImplements(), " & "), ""), directives(node.getDirectives()), block(node.getFieldDefinitions()) )); }; }
private NodePrinter<InlineFragment> inlineFragment() { return (out, node) -> { TypeName typeName = node.getTypeCondition(); //Inline fragments may not have a type condition String typeCondition = typeName == null ? "" : wrap("on ", type(typeName), ""); String directives = directives(node.getDirectives()); String selectionSet = node(node.getSelectionSet()); out.printf("%s", comments(node)); out.printf("%s", spaced( "...", typeCondition, directives, selectionSet )); }; }
private NodePrinter<OperationDefinition> operationDefinition() { final String argSep = compactMode ? "," : ", "; return (out, node) -> { String op = node.getOperation().toString().toLowerCase(); String name = node.getName(); String varDefinitions = wrap("(", join(nvl(node.getVariableDefinitions()), argSep), ")"); String directives = directives(node.getDirectives()); String selectionSet = node(node.getSelectionSet()); // Anonymous queries with no directives or variable definitions can use // the query short form. if (isEmpty(name) && isEmpty(directives) && isEmpty(varDefinitions) && op.equals("QUERY")) { out.printf("%s", selectionSet); } else { out.printf("%s", spaced(op, smooshed(name, varDefinitions), directives, selectionSet)); } }; }
private NodePrinter<Field> field() { final String argSep = compactMode ? "," : ", "; final String aliasSuffix = compactMode ? ":" : ": "; return (out, node) -> { String alias = wrap("", node.getAlias(), aliasSuffix); String name = node.getName(); String arguments = wrap("(", join(node.getArguments(), argSep), ")"); String directives = directives(node.getDirectives()); String selectionSet = node(node.getSelectionSet()); out.printf("%s", spaced( alias + name + arguments, directives, selectionSet )); }; }
private NodePrinter<FieldDefinition> fieldDefinition() { final String argSep = compactMode ? "," : ", "; return (out, node) -> { out.printf("%s", comments(node)); String args; if (hasComments(node.getInputValueDefinitions()) && !compactMode) { args = join(node.getInputValueDefinitions(), "\n"); out.printf("%s", node.getName() + wrap("(\n", args, "\n)") + ": " + spaced( type(node.getType()), directives(node.getDirectives()) ) ); } else { args = join(node.getInputValueDefinitions(), argSep); out.printf("%s", node.getName() + wrap("(", args, ")") + ": " + spaced( type(node.getType()), directives(node.getDirectives()) ) ); } }; }
private NodePrinter<FragmentSpread> fragmentSpread() { return (out, node) -> { String name = node.getName(); String directives = directives(node.getDirectives()); out.printf("...%s%s", name, directives); }; }
private NodePrinter<SchemaDefinition> schemaDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( "schema", directives(node.getDirectives()), block(node.getOperationTypeDefinitions()) )); }; }
private NodePrinter<InputObjectTypeDefinition> inputObjectTypeDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( "input", node.getName(), directives(node.getDirectives()), block(node.getInputValueDefinitions()) ) ); }; }
private NodePrinter<FragmentDefinition> fragmentDefinition() { return (out, node) -> { String name = node.getName(); String typeCondition = type(node.getTypeCondition()); String directives = directives(node.getDirectives()); String selectionSet = node(node.getSelectionSet()); out.printf("fragment %s on %s ", name, typeCondition); out.printf("%s", directives + selectionSet); }; }
private NodePrinter<ObjectTypeDefinition> objectTypeDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( "type", node.getName(), wrap("implements ", join(node.getImplements(), " & "), ""), directives(node.getDirectives()), block(node.getFieldDefinitions()) )); }; }