Skip to content

Commit 0362bdf

Browse files
committed
Log schema resources during application startup
This commit logs the number of schema resources that were loaded to create the GraphQL schema, at the INFO level. If DEBUG is enabled for this package, the description of all schema resources will be logged as well. Closes gh-566
1 parent 0bd3058 commit 0362bdf

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultSchemaResourceGraphQlSourceBuilder.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.List;
2525
import java.util.Set;
2626
import java.util.function.BiFunction;
27+
import java.util.stream.Collectors;
2728

2829
import graphql.language.InterfaceTypeDefinition;
2930
import graphql.language.UnionTypeDefinition;
@@ -36,6 +37,8 @@
3637
import graphql.schema.idl.SchemaParser;
3738
import graphql.schema.idl.TypeDefinitionRegistry;
3839
import graphql.schema.idl.WiringFactory;
40+
import org.apache.commons.logging.Log;
41+
import org.apache.commons.logging.LogFactory;
3942

4043
import org.springframework.core.io.Resource;
4144
import org.springframework.lang.Nullable;
@@ -53,6 +56,8 @@ final class DefaultSchemaResourceGraphQlSourceBuilder
5356
extends AbstractGraphQlSourceBuilder<GraphQlSource.SchemaResourceBuilder>
5457
implements GraphQlSource.SchemaResourceBuilder {
5558

59+
private static final Log logger = LogFactory.getLog(DefaultSchemaResourceGraphQlSourceBuilder.class);
60+
5661
private final Set<Resource> schemaResources = new LinkedHashSet<>();
5762

5863
private final List<RuntimeWiringConfigurer> runtimeWiringConfigurers = new ArrayList<>();
@@ -98,6 +103,14 @@ protected GraphQLSchema initGraphQlSchema() {
98103
.reduce(TypeDefinitionRegistry::merge)
99104
.orElseThrow(MissingSchemaException::new);
100105

106+
logger.info("Loaded " + this.schemaResources.size() + " resource(s) in the GraphQL schema.");
107+
if (logger.isDebugEnabled()) {
108+
String resources = this.schemaResources.stream()
109+
.map(Resource::getDescription)
110+
.collect(Collectors.joining(","));
111+
logger.debug("Loaded GraphQL schema resources: (" + resources + ")");
112+
}
113+
101114
RuntimeWiring runtimeWiring = initRuntimeWiring();
102115

103116
TypeResolver typeResolver = initTypeResolver();

0 commit comments

Comments
 (0)