File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
src/test/kotlin/com/expedia/graphql/integration Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ package com.expedia.graphql.integration
2+
3+ import com.expedia.graphql.TopLevelObject
4+ import com.expedia.graphql.testSchemaConfig
5+ import com.expedia.graphql.toSchema
6+ import graphql.GraphQL
7+ import kotlin.test.Test
8+ import kotlin.test.assertEquals
9+ import kotlin.test.assertNotNull
10+ import kotlin.test.assertNull
11+
12+ class OptionalResultsTest {
13+ @Test
14+ fun `SchemaGenerator generates a simple GraphQL schema` () {
15+ val schema = toSchema(
16+ listOf (TopLevelObject (QueryObject ())),
17+ listOf (),
18+ config = testSchemaConfig
19+ )
20+ val graphQL = GraphQL .newGraphQL(schema).build()
21+
22+ val result = graphQL.execute(" {optionalResults{required optional}}" )
23+ val data: Map <String , Map <String , Any >>? = result.getData()
24+
25+ val optionalResults = data?.get(" optionalResults" )
26+ assertNotNull(optionalResults)
27+ assertEquals(2 , optionalResults.size)
28+ assertEquals(" req" , optionalResults[" required" ])
29+ assertNull(optionalResults[" optional" ])
30+ }
31+ }
32+
33+ data class HasOptionalData (
34+ val required : String ,
35+ val optional : String?
36+ )
37+
38+ class QueryObject {
39+ fun optionalResults () = HasOptionalData (" req" , null )
40+ }
You can’t perform that action at this time.
0 commit comments