Skip to content

Commit 154791d

Browse files
committed
Write test for complex null type
1 parent 85fe57c commit 154791d

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎src/test/groovy/com/coxautodev/graphql/tools/EndToEndSpec.groovy‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,23 @@ class EndToEndSpec extends Specification {
211211
then:
212212
data.defaultArgument == true
213213
}
214+
215+
def "generated schema should return null without errors for null value with nested fields"() {
216+
when:
217+
def data = Utils.assertNoGraphQlErrors(gql) {
218+
'''
219+
{
220+
complexNullType {
221+
first
222+
second
223+
third
224+
}
225+
}
226+
'''
227+
}
228+
229+
then:
230+
data.containsKey('complexNullType')
231+
data.complexNullType == null
232+
}
214233
}

‎src/test/kotlin/com/coxautodev/graphql/tools/EndToEndSpec.kt‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ type Query {
2828
2929
listList: [[String!]!]!
3030
futureItems: [Item!]!
31+
complexNullType: ComplexNull
32+
}
33+
34+
type ComplexNull {
35+
first: String!
36+
second: String!
37+
third: String!
3138
}
3239
3340
type Mutation {
@@ -108,6 +115,7 @@ class Query: GraphQLQueryResolver, ListListResolver<String>() {
108115
fun defaultArgument(arg: Boolean) = arg
109116

110117
fun futureItems() = CompletableFuture.completedFuture(items)
118+
fun complexNullType(): ComplexNull? = null
111119
}
112120

113121
abstract class ListListResolver<out E> {
@@ -146,6 +154,7 @@ data class OtherItemWithWrongName(val id: Int, override val name: String, overri
146154
data class Tag(val id: Int, val name: String)
147155
data class ItemSearchInput(val name: String)
148156
data class NewItemInput(val name: String, val type: Type)
157+
data class ComplexNull(val first: String, val second: String, val third: String)
149158

150159
val CustomUUIDScalar = GraphQLScalarType("UUID", "UUID", object : Coercing<UUID, String> {
151160

0 commit comments

Comments
 (0)