Skip to content

Commit 420aabb

Browse files
author
Oryan M
committed
Add test back after merge
1 parent 1bfd3f9 commit 420aabb

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

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

Whitespace-only changes.

src/test/kotlin/graphql/kickstart/tools/SchemaParserTest.kt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package graphql.kickstart.tools
22

33
import graphql.kickstart.tools.resolver.FieldResolverError
4+
import graphql.schema.GraphQLArgument
5+
import graphql.schema.GraphQLInputObjectType
6+
import graphql.schema.GraphQLNonNull
7+
import graphql.schema.idl.SchemaDirectiveWiring
8+
import graphql.schema.idl.SchemaDirectiveWiringEnvironment
49
import org.junit.Before
510
import org.junit.Rule
611
import org.junit.Test
@@ -402,6 +407,47 @@ class SchemaParserTest {
402407
.makeExecutableSchema()
403408
}
404409

410+
@Test
411+
fun `NonNull and nullable input arguments should resolve to GraphQLInputObjectType`() {
412+
val schema = SchemaParser.newParser()
413+
.schemaString(
414+
"""
415+
type Query {
416+
testNonNullable(filter: Filter!): Boolean
417+
testNullable(filter: Filter): Boolean
418+
}
419+
420+
input Filter {
421+
filter: String
422+
}
423+
""")
424+
.resolvers(object : GraphQLQueryResolver {
425+
fun testNonNullable(filter: Filter): Boolean = false
426+
fun testNullable(filter: Filter): Boolean = false
427+
})
428+
.directiveWiring(object : SchemaDirectiveWiring {
429+
override fun onArgument(environment: SchemaDirectiveWiringEnvironment<GraphQLArgument>): GraphQLArgument {
430+
when (environment.element.type) {
431+
is GraphQLNonNull ->
432+
assert((environment.element.type as GraphQLNonNull).wrappedType is GraphQLInputObjectType)
433+
}
434+
return environment.element
435+
}
436+
})
437+
.build()
438+
.makeExecutableSchema()
439+
440+
val testNonNullableArgument = schema.getObjectType("Query")
441+
.getFieldDefinition("testNonNullable")
442+
.arguments.first()
443+
val testNullableArgument = schema.getObjectType("Query")
444+
.getFieldDefinition("testNullable")
445+
.arguments.first()
446+
assert(testNonNullableArgument.type is GraphQLNonNull)
447+
assert((testNonNullableArgument.type as GraphQLNonNull).wrappedType is GraphQLInputObjectType)
448+
assert(testNullableArgument.type is GraphQLInputObjectType)
449+
}
450+
405451
enum class EnumType {
406452
TEST
407453
}

0 commit comments

Comments
 (0)