Add DEBUG logging for skipped types

See gh-662
This commit is contained in:
rstoyanchev
2023-04-19 14:35:27 +01:00
parent ca526f5769
commit d4fa7cbe71
2 changed files with 19 additions and 3 deletions

View File

@@ -34,6 +34,8 @@ import graphql.schema.GraphQLScalarType;
import graphql.schema.GraphQLSchema;
import graphql.schema.GraphQLType;
import graphql.schema.idl.RuntimeWiring;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
@@ -71,6 +73,9 @@ import org.springframework.util.MultiValueMap;
*/
class SchemaMappingInspector {
private static final Log logger = LogFactory.getLog(SchemaMappingInspector.class);
private final GraphQLSchema schema;
private final RuntimeWiring runtimeWiring;
@@ -132,11 +137,19 @@ class SchemaMappingInspector {
if (!(type instanceof GraphQLFieldsContainer fieldContainer)) {
if (isNotScalarOrEnumType(type)) {
if (logger.isDebugEnabled()) {
logger.debug("Skipped '" + getTypeName(type) + "': " +
"inspection does not support " + type.getClass().getSimpleName() + ".");
}
this.reportBuilder.addSkippedType(getTypeName(type));
}
return;
}
else if (resolvableType != null && resolveClassToCompare(resolvableType) == Object.class) {
if (logger.isDebugEnabled()) {
logger.debug("Skipped '" + getTypeName(type) + "': " +
"inspection could not determine the Java object return type.");
}
this.reportBuilder.addSkippedType(getTypeName(type));
return;
}
@@ -152,6 +165,10 @@ class SchemaMappingInspector {
inspectType(field.getType(), selfDescribingDataFetcher.getReturnType());
}
else if (isNotScalarOrEnumType(field.getType())) {
if (logger.isDebugEnabled()) {
logger.debug("Skipped '" + getTypeName(field.getType()) + "': " +
fetcher.getClass().getName() + " does not implement SelfDescribingDataFetcher.");
}
this.reportBuilder.addSkippedType(getTypeName(field.getType()));
}
}

View File

@@ -34,7 +34,6 @@ import org.springframework.data.domain.OffsetScrollPosition;
import org.springframework.data.domain.Window;
import org.springframework.graphql.Author;
import org.springframework.graphql.Book;
import org.springframework.graphql.GraphQlSetup;
import org.springframework.graphql.data.method.annotation.Argument;
import org.springframework.graphql.data.method.annotation.MutationMapping;
import org.springframework.graphql.data.method.annotation.QueryMapping;
@@ -423,7 +422,7 @@ class SchemaMappingInspectorTests {
}
""";
GraphQLSchema schema = GraphQlSetup.schemaContent(schemaContent).toGraphQlSource().schema();
GraphQLSchema schema = SchemaGenerator.createdMockedSchema(schemaContent);
RuntimeWiring wiring = RuntimeWiring.newRuntimeWiring()
.type("Query", builder -> builder.dataFetcher("bookById", environment -> null))
.build();
@@ -440,7 +439,7 @@ class SchemaMappingInspectorTests {
}
""";
GraphQLSchema schema = GraphQlSetup.schemaContent(schemaContent).toGraphQlSource().schema();
GraphQLSchema schema = SchemaGenerator.createdMockedSchema(schemaContent);
RuntimeWiring wiring = RuntimeWiring.newRuntimeWiring()
.type("Query", builder -> builder.dataFetcher("greeting", environment -> null))
.build();