Skip to content

Commit 66649df

Browse files
smyricksmyrick
authored and
smyrick
committed
fix some compile warnings (ExpediaGroup#285)
No impact on any library code
1 parent 052caf9 commit 66649df

File tree

4 files changed

+43
-5
lines changed

4 files changed

+43
-5
lines changed

graphql-kotlin-spring-example/src/main/kotlin/com/expedia/graphql/sample/datafetchers/SpringDataFetcherFactory.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class SpringDataFetcherFactory: DataFetcherFactory<Any>, BeanFactoryAware {
1616
this.beanFactory = beanFactory!!
1717
}
1818

19+
@Suppress("UNCHECKED_CAST")
1920
override fun get(environment: DataFetcherFactoryEnvironment?): DataFetcher<Any> {
2021

2122
//Strip out possible `Input` and `!` suffixes added to by the SchemaGenerator

graphql-kotlin-spring-example/src/main/kotlin/com/expedia/graphql/sample/extension/CustomSchemaGeneratorHooks.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ class CustomSchemaGeneratorHooks(validator: Validator, override val wiringFactor
2828
override val dataFetcherExecutionPredicate: DataFetcherExecutionPredicate? = DataFetcherExecutionValidator(validator)
2929
}
3030

31-
internal val graphqlUUIDType = GraphQLScalarType("UUID",
32-
"A type representing a formatted java.util.UUID",
33-
UUIDCoercing
34-
)
31+
internal val graphqlUUIDType = GraphQLScalarType.newScalar()
32+
.name("UUID")
33+
.description("A type representing a formatted java.util.UUID")
34+
.coercing(UUIDCoercing)
35+
.build()
3536

3637
private object UUIDCoercing : Coercing<UUID, String> {
3738
override fun parseValue(input: Any?): UUID = UUID.fromString(

graphql-kotlin-spring-example/src/main/kotlin/com/expedia/graphql/sample/query/PolymorphicQuery.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class PolymorphicQuery: Query {
2020
fun animal(type: AnimalType): Animal? = when (type) {
2121
AnimalType.CAT -> Cat()
2222
AnimalType.DOG -> Dog()
23-
else -> null
2423
}
2524

2625
fun dog(): Dog = Dog()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.expedia.graphql.sample.extension
2+
3+
import com.expedia.graphql.directives.KotlinDirectiveWiringFactory
4+
import io.mockk.mockk
5+
import org.junit.jupiter.api.Test
6+
import java.util.UUID
7+
import javax.validation.Validator
8+
import kotlin.reflect.full.createType
9+
import kotlin.test.assertEquals
10+
import kotlin.test.assertNotNull
11+
import kotlin.test.assertNull
12+
13+
class CustomSchemaGeneratorHooksTest {
14+
15+
data class NonScalar(val id: String)
16+
17+
@Test
18+
fun `UUID returns a string scalar`() {
19+
val validator: Validator = mockk()
20+
val wiringFactory: KotlinDirectiveWiringFactory = mockk()
21+
val hooks = CustomSchemaGeneratorHooks(validator, wiringFactory)
22+
23+
val result = hooks.willGenerateGraphQLType(UUID::class.createType())
24+
assertNotNull(result)
25+
assertEquals(expected = "UUID", actual = result.name)
26+
}
27+
28+
@Test
29+
fun `Non valid type returns null`() {
30+
val validator: Validator = mockk()
31+
val wiringFactory: KotlinDirectiveWiringFactory = mockk()
32+
val hooks = CustomSchemaGeneratorHooks(validator, wiringFactory)
33+
34+
val result = hooks.willGenerateGraphQLType(NonScalar::class.createType())
35+
assertNull(result)
36+
}
37+
}

0 commit comments

Comments
 (0)