Skip to content

Commit 2ded2f1

Browse files
author
Thomas
committed
Improve readability by storing a seperate variable
1 parent 61f1490 commit 2ded2f1

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

src/main/kotlin/graphql/kickstart/tools/SchemaClassScanner.kt

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -333,26 +333,29 @@ internal class SchemaClassScanner(
333333
}
334334

335335
is InputObjectTypeDefinition -> {
336-
(listOf(graphQLType) + inputExtensionDefinitions.filter { it.name == graphQLType.name }).flatMap { it.inputValueDefinitions }.forEach { inputValueDefinition ->
337-
val inputGraphQLType = inputValueDefinition.type.unwrap()
338-
if (inputGraphQLType is TypeName && !ScalarInfo.GRAPHQL_SPECIFICATION_SCALARS_DEFINITIONS.containsKey(inputGraphQLType.name)) {
339-
val inputValueJavaType = findInputValueType(inputValueDefinition.name, inputGraphQLType, javaType.unwrap())
340-
if (inputValueJavaType != null) {
341-
handleFoundType(typeClassMatcher.match(TypeClassMatcher.PotentialMatch.parameterType(
342-
inputValueDefinition.type,
343-
inputValueJavaType,
344-
GenericType(javaType, options).relativeToType(inputValueJavaType),
345-
InputObjectReference(inputValueDefinition)
346-
)))
347-
} else {
348-
var mappingAdvice = "Try adding it manually to the dictionary"
349-
if (javaType.unwrap().name.contains("Map")) {
350-
mappingAdvice = " or add a class to represent your input type instead of a Map."
336+
val inputObjectTypes = listOf(graphQLType) + inputExtensionDefinitions.filter { it.name == graphQLType.name }
337+
inputObjectTypes
338+
.flatMap { it.inputValueDefinitions }
339+
.forEach { inputValueDefinition ->
340+
val inputGraphQLType = inputValueDefinition.type.unwrap()
341+
if (inputGraphQLType is TypeName && !ScalarInfo.GRAPHQL_SPECIFICATION_SCALARS_DEFINITIONS.containsKey(inputGraphQLType.name)) {
342+
val inputValueJavaType = findInputValueType(inputValueDefinition.name, inputGraphQLType, javaType.unwrap())
343+
if (inputValueJavaType != null) {
344+
handleFoundType(typeClassMatcher.match(TypeClassMatcher.PotentialMatch.parameterType(
345+
inputValueDefinition.type,
346+
inputValueJavaType,
347+
GenericType(javaType, options).relativeToType(inputValueJavaType),
348+
InputObjectReference(inputValueDefinition)
349+
)))
350+
} else {
351+
var mappingAdvice = "Try adding it manually to the dictionary"
352+
if (javaType.unwrap().name.contains("Map")) {
353+
mappingAdvice = " or add a class to represent your input type instead of a Map."
354+
}
355+
log.warn("Cannot find definition for field '${inputValueDefinition.name}: ${inputGraphQLType.name}' on input type '${graphQLType.name}' -> ${javaType.unwrap().name}. $mappingAdvice")
351356
}
352-
log.warn("Cannot find definition for field '${inputValueDefinition.name}: ${inputGraphQLType.name}' on input type '${graphQLType.name}' -> ${javaType.unwrap().name}. $mappingAdvice")
353357
}
354358
}
355-
}
356359
}
357360
}
358361
}

0 commit comments

Comments
 (0)