in src/main/com/intellij/lang/jsgraphql/types/schema/idl/SchemaPrinter.java [725:770]
private TypePrinter<GraphQLSchema> schemaPrinter() {
return (out, schema, visibility) -> {
List<GraphQLDirective> schemaDirectives = schema.getSchemaDirectives();
GraphQLObjectType queryType = schema.getQueryType();
GraphQLObjectType mutationType = schema.getMutationType();
GraphQLObjectType subscriptionType = schema.getSubscriptionType();
// when serializing a GraphQL schema using the type system language, a
// schema definition should be omitted if only uses the default root type names.
boolean needsSchemaPrinted = options.isIncludeSchemaDefinition();
if (!needsSchemaPrinted) {
if (queryType != null && !queryType.getName().equals("Query")) {
needsSchemaPrinted = true;
}
if (mutationType != null && !mutationType.getName().equals("Mutation")) {
needsSchemaPrinted = true;
}
if (subscriptionType != null && !subscriptionType.getName().equals("Subscription")) {
needsSchemaPrinted = true;
}
}
String indent = calcIndent(1);
if (needsSchemaPrinted) {
out.format("schema %s{\n", directivesString(GraphQLSchemaElement.class, schemaDirectives));
if (queryType != null) {
out.format("%squery: %s\n", indent, queryType.getName());
}
if (mutationType != null) {
out.format("%smutation: %s\n", indent, mutationType.getName());
}
if (subscriptionType != null) {
out.format("%ssubscription: %s\n", indent, subscriptionType.getName());
}
out.print("}\n\n");
}
if (options.isIncludeDirectiveDefinitions()) {
List<GraphQLDirective> directives = getSchemaDirectives(schema);
if (!directives.isEmpty()) {
out.print(directiveDefinitions(directives));
}
}
};
}