Skip to content

Commit d4fa7cb

Browse files
committed
Add DEBUG logging for skipped types
See gh-662
1 parent ca526f5 commit d4fa7cb

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import graphql.schema.GraphQLSchema;
3535
import graphql.schema.GraphQLType;
3636
import graphql.schema.idl.RuntimeWiring;
37+
import org.apache.commons.logging.Log;
38+
import org.apache.commons.logging.LogFactory;
3739

3840
import org.springframework.beans.BeanUtils;
3941
import org.springframework.beans.BeansException;
@@ -71,6 +73,9 @@
7173
*/
7274
class SchemaMappingInspector {
7375

76+
private static final Log logger = LogFactory.getLog(SchemaMappingInspector.class);
77+
78+
7479
private final GraphQLSchema schema;
7580

7681
private final RuntimeWiring runtimeWiring;
@@ -132,11 +137,19 @@ else if (type instanceof GraphQLList listType) {
132137

133138
if (!(type instanceof GraphQLFieldsContainer fieldContainer)) {
134139
if (isNotScalarOrEnumType(type)) {
140+
if (logger.isDebugEnabled()) {
141+
logger.debug("Skipped '" + getTypeName(type) + "': " +
142+
"inspection does not support " + type.getClass().getSimpleName() + ".");
143+
}
135144
this.reportBuilder.addSkippedType(getTypeName(type));
136145
}
137146
return;
138147
}
139148
else if (resolvableType != null && resolveClassToCompare(resolvableType) == Object.class) {
149+
if (logger.isDebugEnabled()) {
150+
logger.debug("Skipped '" + getTypeName(type) + "': " +
151+
"inspection could not determine the Java object return type.");
152+
}
140153
this.reportBuilder.addSkippedType(getTypeName(type));
141154
return;
142155
}
@@ -152,6 +165,10 @@ else if (resolvableType != null && resolveClassToCompare(resolvableType) == Obje
152165
inspectType(field.getType(), selfDescribingDataFetcher.getReturnType());
153166
}
154167
else if (isNotScalarOrEnumType(field.getType())) {
168+
if (logger.isDebugEnabled()) {
169+
logger.debug("Skipped '" + getTypeName(field.getType()) + "': " +
170+
fetcher.getClass().getName() + " does not implement SelfDescribingDataFetcher.");
171+
}
155172
this.reportBuilder.addSkippedType(getTypeName(field.getType()));
156173
}
157174
}

spring-graphql/src/test/java/org/springframework/graphql/execution/SchemaMappingInspectorTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.springframework.data.domain.Window;
3535
import org.springframework.graphql.Author;
3636
import org.springframework.graphql.Book;
37-
import org.springframework.graphql.GraphQlSetup;
3837
import org.springframework.graphql.data.method.annotation.Argument;
3938
import org.springframework.graphql.data.method.annotation.MutationMapping;
4039
import org.springframework.graphql.data.method.annotation.QueryMapping;
@@ -423,7 +422,7 @@ void reportHasSkippedTypeForUnknownDataFetcherType() {
423422
}
424423
""";
425424

426-
GraphQLSchema schema = GraphQlSetup.schemaContent(schemaContent).toGraphQlSource().schema();
425+
GraphQLSchema schema = SchemaGenerator.createdMockedSchema(schemaContent);
427426
RuntimeWiring wiring = RuntimeWiring.newRuntimeWiring()
428427
.type("Query", builder -> builder.dataFetcher("bookById", environment -> null))
429428
.build();
@@ -440,7 +439,7 @@ void reportIsEmptyIfUnknownDataFetcherReturnsSimpleType() {
440439
}
441440
""";
442441

443-
GraphQLSchema schema = GraphQlSetup.schemaContent(schemaContent).toGraphQlSource().schema();
442+
GraphQLSchema schema = SchemaGenerator.createdMockedSchema(schemaContent);
444443
RuntimeWiring wiring = RuntimeWiring.newRuntimeWiring()
445444
.type("Query", builder -> builder.dataFetcher("greeting", environment -> null))
446445
.build();

0 commit comments

Comments
 (0)