@@ -10,6 +10,7 @@ import com.expedia.graphql.schema.extensions.deepName
1010import com.expedia.graphql.schema.testSchemaConfig
1111import com.expedia.graphql.toSchema
1212import graphql.GraphQL
13+ import graphql.Scalars
1314import graphql.schema.GraphQLNonNull
1415import graphql.schema.GraphQLObjectType
1516import org.junit.jupiter.api.Assertions.assertNull
@@ -248,10 +249,10 @@ class SchemaGeneratorTest {
248249 val schema = toSchema(queries = listOf (TopLevelObjectDef (QueryWithId ())), config = testSchemaConfig)
249250
250251 val placeType = schema.getObjectType(" PlaceOfIds" )
251- assertEquals(graphql. Scalars .GraphQLID , (placeType.getFieldDefinition(" intId" ).type as ? GraphQLNonNull )?.wrappedType)
252- assertEquals(graphql. Scalars .GraphQLID , (placeType.getFieldDefinition(" longId" ).type as ? GraphQLNonNull )?.wrappedType)
253- assertEquals(graphql. Scalars .GraphQLID , (placeType.getFieldDefinition(" stringId" ).type as ? GraphQLNonNull )?.wrappedType)
254- assertEquals(graphql. Scalars .GraphQLID , (placeType.getFieldDefinition(" uuid" ).type as ? GraphQLNonNull )?.wrappedType)
252+ assertEquals(Scalars .GraphQLID , (placeType.getFieldDefinition(" intId" ).type as ? GraphQLNonNull )?.wrappedType)
253+ assertEquals(Scalars .GraphQLID , (placeType.getFieldDefinition(" longId" ).type as ? GraphQLNonNull )?.wrappedType)
254+ assertEquals(Scalars .GraphQLID , (placeType.getFieldDefinition(" stringId" ).type as ? GraphQLNonNull )?.wrappedType)
255+ assertEquals(Scalars .GraphQLID , (placeType.getFieldDefinition(" uuid" ).type as ? GraphQLNonNull )?.wrappedType)
255256 }
256257
257258 @Test
@@ -263,6 +264,15 @@ class SchemaGeneratorTest {
263264 assertEquals(" Person is not a valid ID type, only [kotlin.Int, kotlin.String, kotlin.Long, java.util.UUID] are accepted" , exception.message)
264265 }
265266
267+ @Test
268+ fun `SchemaGenerator supports Scalar GraphQLID for input types` () {
269+ val schema = toSchema(mutations = listOf (TopLevelObjectDef (MutationWithId ())), config = testSchemaConfig)
270+
271+ val furnitureType = schema.getObjectType(" Furniture" )
272+ val serialField = furnitureType.getFieldDefinition(" serial" ).type as ? GraphQLNonNull
273+ assertEquals(Scalars .GraphQLID , serialField?.wrappedType)
274+ }
275+
266276 class QueryObject {
267277 @GraphQLDescription(" A GraphQL query method" )
268278 fun query (@GraphQLDescription(" A GraphQL value" ) value : Int ): Geography = Geography (value, GeoType .CITY , listOf ())
@@ -407,4 +417,13 @@ class SchemaGeneratorTest {
407417 class QueryWithInvalidId {
408418 fun query (): InvalidIds = InvalidIds (Person (" person id not a valid type id" ))
409419 }
420+
421+ class MutationWithId {
422+ fun mutate (furniture : Furniture ): Furniture = furniture
423+ }
424+
425+ data class Furniture (
426+ @property:GraphQLID val serial : UUID ,
427+ val type : String
428+ )
410429}
0 commit comments