Skip to content

Commit ad56eed

Browse files
committed
Minor improvements
1 parent 2e956f4 commit ad56eed

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,12 +392,7 @@ class SchemaParser internal constructor(
392392
throw SchemaError("Expected type '${typeDefinition.name}' to be a ${expectedType.simpleName}, but it wasn't! " +
393393
"Was a type only permitted for object types incorrectly used as an input type, or vice-versa?")
394394
}
395-
val found = inputObjects.filter { it.name == typeDefinition.name }
396-
if (found.size == 1) {
397-
found[0]
398-
} else {
399-
GraphQLTypeReference(typeDefinition.name)
400-
}
395+
inputObjects.find { it.name == typeDefinition.name } ?: GraphQLTypeReference(typeDefinition.name)
401396
}
402397
}
403398
else -> throw SchemaError("Unknown type: $typeDefinition")

src/test/groovy/graphql/kickstart/tools/SchemaParserSpec.groovy

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import graphql.kickstart.tools.resolver.FieldResolverError
44
import graphql.language.SourceLocation
55
import graphql.schema.GraphQLArgument
66
import graphql.schema.GraphQLInputObjectType
7-
import graphql.schema.GraphQLInputType
87
import graphql.schema.GraphQLNonNull
98
import graphql.schema.GraphQLSchema
109
import graphql.schema.idl.SchemaDirectiveWiring
@@ -394,7 +393,7 @@ class SchemaParserSpec extends Specification {
394393
GraphQLArgument onArgument(SchemaDirectiveWiringEnvironment<GraphQLArgument> environment) {
395394
switch (environment.getElement().type.class) {
396395
case GraphQLNonNull:
397-
assert (environment.getElement().type as graphql.schema.GraphQLNonNull).wrappedType.class == GraphQLInputObjectType
396+
assert (environment.getElement().type as GraphQLNonNull).wrappedType.class == GraphQLInputObjectType
398397
}
399398
return environment.getElement()
400399
}})
@@ -408,8 +407,8 @@ class SchemaParserSpec extends Specification {
408407
GraphQLArgument testNullableArgument = schema.getObjectType("Query")
409408
.getFieldDefinition("testNullable")
410409
.arguments.first()
411-
testNonNullableArgument.type.class == graphql.schema.GraphQLNonNull
412-
(testNonNullableArgument.type as graphql.schema.GraphQLNonNull).wrappedType.class == GraphQLInputObjectType
410+
testNonNullableArgument.type.class == GraphQLNonNull
411+
(testNonNullableArgument.type as GraphQLNonNull).wrappedType.class == GraphQLInputObjectType
413412
testNullableArgument.type.class == GraphQLInputObjectType
414413
}
415414

0 commit comments

Comments
 (0)