@@ -3,27 +3,28 @@ package com.expedia.graphql.test.integration
33import com.expedia.graphql.TopLevelObject
44import com.expedia.graphql.testSchemaConfig
55import com.expedia.graphql.toSchema
6+ import graphql.schema.GraphQLObjectType
7+ import graphql.schema.GraphQLTypeReference
68import org.junit.jupiter.api.Test
79import kotlin.test.assertEquals
10+ import kotlin.test.assertFalse
811
912class NodeGraphTest {
1013
1114 @Test
1215 fun nodeGraph () {
13- val root = Node (id = 0 , value = " root" , parent = null , children = emptyList())
14- val nodeA = Node (id = 1 , value = " A" , parent = root, children = emptyList())
15- val nodeB = Node (id = 2 , value = " B" , parent = root, children = emptyList())
16- val nodeC = Node (id = 3 , value = " C" , parent = nodeB, children = emptyList())
17-
18- root.children = listOf (nodeA, nodeB)
19- nodeB.children = listOf (nodeC)
20-
2116 val queries = listOf (TopLevelObject (NodeQuery ()))
2217
2318 val schema = toSchema(queries = queries, config = testSchemaConfig)
2419
2520 assertEquals(expected = 1 , actual = schema.queryType.fieldDefinitions.size)
2621 assertEquals(expected = " nodeGraph" , actual = schema.queryType.fieldDefinitions.first().name)
22+
23+ val nodeFields = (schema.typeMap[" Node" ] as ? GraphQLObjectType )?.fieldDefinitions
24+
25+ nodeFields?.forEach {
26+ assertFalse(it.type is GraphQLTypeReference , " Node.${it.name} is a GraphQLTypeReference" )
27+ }
2728 }
2829}
2930
@@ -34,16 +35,16 @@ class NodeGraphTest {
3435data class Node (
3536 val id : Int ,
3637 val value : String ,
37- val parent : Node ? ,
38- var children : List <Node >
38+ val parent : Node ? = null ,
39+ var children : List <Node > = emptyList()
3940)
4041
4142class NodeQuery {
4243
43- private val root = Node (id = 0 , value = " root" , parent = null , children = emptyList() )
44- private val nodeA = Node (id = 1 , value = " A" , parent = root, children = emptyList() )
45- private val nodeB = Node (id = 2 , value = " B" , parent = root, children = emptyList() )
46- private val nodeC = Node (id = 3 , value = " C" , parent = nodeB, children = emptyList() )
44+ private val root = Node (id = 0 , value = " root" )
45+ private val nodeA = Node (id = 1 , value = " A" , parent = root)
46+ private val nodeB = Node (id = 2 , value = " B" , parent = root)
47+ private val nodeC = Node (id = 3 , value = " C" , parent = nodeB)
4748
4849 init {
4950 root.children = listOf (nodeA, nodeB)
0 commit comments