File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed
main/kotlin/com/expedia/graphql
test/kotlin/com/expedia/graphql Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -9,4 +9,7 @@ import kotlin.reflect.KClass
99 * @param obj The target object (or proxy to target object)
1010 * @param kClass Optional KClass of the target (or the proxied object)
1111 */
12- data class TopLevelObject (val obj : Any , val kClass : KClass <* > = obj : :class)
12+ data class TopLevelObject (val obj : Any? , val kClass : KClass <* >) {
13+ constructor (obj: Any ) : this (obj, obj::class )
14+ constructor (kClass: KClass <* >) : this (null , kClass)
15+ }
Original file line number Diff line number Diff line change @@ -7,7 +7,5 @@ internal class SubTypeMapper(supportedPackages: List<String>) {
77
88 private val reflections = Reflections (supportedPackages)
99
10- fun getSubTypesOf (kclass : KClass <* >): List <Class <* >> =
11- reflections.getSubTypesOf(Class .forName(kclass.javaObjectType.name))
12- .filterNot { it.kotlin.isAbstract }
10+ fun getSubTypesOf (kclass : KClass <* >): List <Class <* >> = reflections.getSubTypesOf(kclass.java).filterNot { it.kotlin.isAbstract }
1311}
Original file line number Diff line number Diff line change 11package com.expedia.graphql
22
33import org.junit.jupiter.api.Test
4+ import kotlin.test.assertEquals
45
56class ToSchemaKtTest {
67
7- class TestClass
8+ @Suppress(" FunctionOnlyReturningConstant" )
9+ class TestClass {
10+ fun greeting () = " Hello World"
11+ }
812
913 @Test
1014 fun `valid schema` () {
1115 val queries = listOf (TopLevelObject (TestClass ()))
1216 toSchema(queries = queries, config = testSchemaConfig)
1317 }
18+
19+ @Test
20+ fun `generate standalone SDL` () {
21+ val queries = listOf (TopLevelObject (TestClass ::class ))
22+ val schema = toSchema(queries = queries, config = testSchemaConfig)
23+
24+ val greetingField = schema.queryType.getFieldDefinition(" greeting" )
25+ assertEquals(" String!" , greetingField.type.toString())
26+ }
1427}
You can’t perform that action at this time.
0 commit comments