@@ -22,6 +22,7 @@ fun createSchema() = SchemaParser.newParser()
2222 .dictionary(" ThirdItem" , ThirdItem ::class )
2323 .dictionary(" ComplexMapItem" , ComplexMapItem ::class )
2424 .dictionary(" NestedComplexMapItem" , NestedComplexMapItem ::class )
25+ .dictionary(" OutOfBeerError" , OutOfBeerError ::class )
2526 .build()
2627 .makeExecutableSchema()
2728
@@ -83,6 +84,9 @@ type Query {
8384 arrayItems: [Item!]!
8485
8586 throwsIllegalArgumentException: String
87+
88+ allBars: [Bar!]!
89+ findAvailableBar(persons: Int!): BarResult!
8690}
8791
8892type ExtendedType {
@@ -216,6 +220,16 @@ type Tag {
216220type ItemWithGenericProperties {
217221 keys: [String!]!
218222}
223+
224+ type Bar {
225+ name: String
226+ }
227+
228+ type OutOfBeerError {
229+ msg: String
230+ }
231+
232+ union BarResult = Bar | OutOfBeerError
219233"""
220234
221235val items = listOf (
@@ -314,6 +328,16 @@ class Query : GraphQLQueryResolver, ListListResolver<String>() {
314328 fun throwsIllegalArgumentException (): String {
315329 throw IllegalArgumentException (" Expected" )
316330 }
331+
332+ fun allBars (): List <Bar > {
333+ return listOf (BarEntityImpl (" 123" , " Bar Name" ))
334+ }
335+ fun findAvailableBar (persons : Int ): Any {
336+ if (persons < 56 )
337+ return BarEntityImpl (" 123" , " Bar Name" );
338+ else
339+ return OutOfBeerError (" No room for $persons persons" )
340+ }
317341}
318342
319343class UnusedRootResolver : GraphQLQueryResolver
@@ -410,6 +434,11 @@ class MockPart(private val name: String, private val content: String) : Part {
410434 override fun delete () = throw IllegalArgumentException (" Not supported" )
411435}
412436
437+ interface Bar { val name: String }
438+ interface BarEntity : Bar { val id: String }
439+ class BarEntityImpl (override val id : String , override val name : String ) : BarEntity
440+ class OutOfBeerError (val msg : String )
441+
413442val customScalarId = GraphQLScalarType .newScalar()
414443 .name(" ID" )
415444 .description(" Overrides built-in ID" )
0 commit comments