String argsString()

in src/main/com/intellij/lang/jsgraphql/types/schema/idl/SchemaPrinter.java [792:849]


  String argsString(Class<? extends GraphQLSchemaElement> parent, List<GraphQLArgument> arguments, int initialIndent) {
    boolean hasDescriptions = ContainerUtil.exists(arguments, this::hasDescription);
    String indent = hasDescriptions ? calcIndent(initialIndent) : "";
    String nestedIndent = hasDescriptions ? calcIndent(initialIndent + 1) : "";
    int count = 0;
    StringBuilder sb = new StringBuilder();

    GraphqlTypeComparatorEnvironment environment = GraphqlTypeComparatorEnvironment.newEnvironment()
      .parentType(parent)
      .elementType(GraphQLArgument.class)
      .build();
    Comparator<? super GraphQLSchemaElement> comparator = options.comparatorRegistry.getComparator(environment);

    arguments = arguments
      .stream()
      .sorted(comparator)
      .filter(options.getIncludeSchemaElement())
      .collect(toList());
    for (GraphQLArgument argument : arguments) {
      if (count == 0) {
        sb.append("(");
      }
      else {
        sb.append(",");
      }

      if (hasDescriptions) {
        sb.append("\n");
      }
      else if (count > 0) {
        sb.append(" ");
      }

      sb.append(printComments(argument, nestedIndent));

      sb.append(nestedIndent).append(argument.getName()).append(": ").append(typeString(argument.getType()));
      Object defaultValue = argument.getDefaultValue();
      if (defaultValue != null) {
        sb.append(" = ");
        sb.append(printAst(defaultValue, argument.getType()));
      }

      argument.getDirectives().stream()
        .filter(options.getIncludeSchemaElement())
        .map(this::directiveString)
        .filter(it -> !it.isEmpty())
        .forEach(directiveString -> sb.append(" ").append(directiveString));

      count++;
    }
    if (count > 0) {
      if (hasDescriptions) {
        sb.append("\n");
      }
      sb.append(indent).append(")");
    }
    return sb.toString();
  }