in src/main/com/intellij/lang/jsgraphql/types/schema/idl/SchemaPrinter.java [886:935]
private String directiveString(GraphQLDirective directive) {
if (!options.getIncludeSchemaElement().test(directive)) {
return "";
}
if (!options.getIncludeDirective().test(directive)) {
// @deprecated and @specifiedBy are special - we always print them
if (!isDeprecatedDirective(directive) && !isSpecifiedByDirective(directive)) {
return "";
}
}
StringBuilder sb = new StringBuilder();
sb.append("@").append(directive.getName());
GraphqlTypeComparatorEnvironment environment = GraphqlTypeComparatorEnvironment.newEnvironment()
.parentType(GraphQLDirective.class)
.elementType(GraphQLArgument.class)
.build();
Comparator<? super GraphQLSchemaElement> comparator = options.comparatorRegistry.getComparator(environment);
List<GraphQLArgument> args = directive.getArguments();
args = args
.stream()
.filter(arg -> arg.getValue() != null || arg.getDefaultValue() != null)
.sorted(comparator)
.toList();
if (!args.isEmpty()) {
sb.append("(");
for (int i = 0; i < args.size(); i++) {
GraphQLArgument arg = args.get(i);
String argValue = null;
if (arg.getValue() != null) {
argValue = printAst(arg.getValue(), arg.getType());
}
else if (arg.getDefaultValue() != null) {
argValue = printAst(arg.getDefaultValue(), arg.getType());
}
if (!isNullOrEmpty(argValue)) {
sb.append(arg.getName());
sb.append(": ");
sb.append(argValue);
if (i < args.size() - 1) {
sb.append(", ");
}
}
}
sb.append(")");
}
return sb.toString();
}