@@ -3,6 +3,11 @@ package graphql.kickstart.tools
3
3
import graphql.kickstart.tools.resolver.FieldResolverError
4
4
import graphql.schema.GraphQLInterfaceType
5
5
import graphql.schema.GraphQLObjectType
6
+ import graphql.schema.GraphQLArgument
7
+ import graphql.schema.GraphQLInputObjectType
8
+ import graphql.schema.GraphQLNonNull
9
+ import graphql.schema.idl.SchemaDirectiveWiring
10
+ import graphql.schema.idl.SchemaDirectiveWiringEnvironment
6
11
import org.junit.Before
7
12
import org.junit.Rule
8
13
import org.junit.Test
@@ -479,6 +484,47 @@ class SchemaParserTest {
479
484
class Poodle (override var traits : List <PoodleTrait >) : Dog<PoodleTrait>()
480
485
}
481
486
487
+ @Test
488
+ fun `NonNull and nullable input arguments should resolve to GraphQLInputObjectType` () {
489
+ val schema = SchemaParser .newParser()
490
+ .schemaString(
491
+ """
492
+ type Query {
493
+ testNonNullable(filter: Filter!): Boolean
494
+ testNullable(filter: Filter): Boolean
495
+ }
496
+
497
+ input Filter {
498
+ filter: String
499
+ }
500
+ """ )
501
+ .resolvers(object : GraphQLQueryResolver {
502
+ fun testNonNullable (filter : Filter ): Boolean = false
503
+ fun testNullable (filter : Filter ): Boolean = false
504
+ })
505
+ .directiveWiring(object : SchemaDirectiveWiring {
506
+ override fun onArgument (environment : SchemaDirectiveWiringEnvironment <GraphQLArgument >): GraphQLArgument {
507
+ when (environment.element.type) {
508
+ is GraphQLNonNull ->
509
+ assert ((environment.element.type as GraphQLNonNull ).wrappedType is GraphQLInputObjectType )
510
+ }
511
+ return environment.element
512
+ }
513
+ })
514
+ .build()
515
+ .makeExecutableSchema()
516
+
517
+ val testNonNullableArgument = schema.getObjectType(" Query" )
518
+ .getFieldDefinition(" testNonNullable" )
519
+ .arguments.first()
520
+ val testNullableArgument = schema.getObjectType(" Query" )
521
+ .getFieldDefinition(" testNullable" )
522
+ .arguments.first()
523
+ assert (testNonNullableArgument.type is GraphQLNonNull )
524
+ assert ((testNonNullableArgument.type as GraphQLNonNull ).wrappedType is GraphQLInputObjectType )
525
+ assert (testNullableArgument.type is GraphQLInputObjectType )
526
+ }
527
+
482
528
enum class EnumType {
483
529
TEST
484
530
}
0 commit comments