Skip to content

Commit 9dce44d

Browse files
author
Oryan M
committed
Add test back after merge
1 parent 3fd161e commit 9dce44d

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

src/test/groovy/graphql/kickstart/tools/SchemaParserSpec.groovy

Whitespace-only changes.

src/test/kotlin/graphql/kickstart/tools/SchemaParserTest.kt

+77
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package graphql.kickstart.tools
22

33
import graphql.kickstart.tools.resolver.FieldResolverError
4+
import graphql.schema.GraphQLInterfaceType
5+
import graphql.schema.GraphQLObjectType
46
import org.junit.Before
57
import org.junit.Rule
68
import org.junit.Test
@@ -402,6 +404,81 @@ class SchemaParserTest {
402404
.makeExecutableSchema()
403405
}
404406

407+
@Test
408+
fun `interface implementing an interface should have non-empty interface list`() {
409+
val schema = SchemaParser.newParser()
410+
.schemaString(
411+
"""
412+
interface Trait {
413+
id: ID!
414+
}
415+
interface MammalTrait implements Trait {
416+
id: ID!
417+
}
418+
type PoodleTrait implements Trait & MammalTrait {
419+
id: ID!
420+
}
421+
422+
interface Animal {
423+
id: ID!
424+
traits: [Trait]
425+
}
426+
interface Dog implements Animal {
427+
id: ID!
428+
traits: [MammalTrait]
429+
}
430+
type Poodle implements Animal & Dog {
431+
id: ID!
432+
traits: [PoodleTrait]
433+
}
434+
435+
type Query { test: [Poodle] }
436+
""")
437+
.resolvers(MultiLevelInterfaceResolver())
438+
.build()
439+
.makeExecutableSchema()
440+
val traitInterface = schema.getType("Trait") as GraphQLInterfaceType
441+
val animalInterface = schema.getType("Animal") as GraphQLInterfaceType
442+
val mammalTraitInterface = schema.getType("MammalTrait") as GraphQLInterfaceType
443+
val dogInterface = schema.getType("Dog") as GraphQLInterfaceType
444+
val poodleObject = schema.getType("Poodle") as GraphQLObjectType
445+
val poodleTraitObject = schema.getType("PoodleTrait") as GraphQLObjectType
446+
447+
assert(poodleObject.interfaces.containsAll(listOf(dogInterface, animalInterface)))
448+
assert(poodleTraitObject.interfaces.containsAll(listOf(mammalTraitInterface, traitInterface)))
449+
assert(dogInterface.interfaces.contains(animalInterface))
450+
assert(mammalTraitInterface.interfaces.contains(traitInterface))
451+
assert(traitInterface.definition.implements.isEmpty())
452+
assert(animalInterface.definition.implements.isEmpty())
453+
}
454+
455+
class MultiLevelInterfaceResolver : GraphQLQueryResolver {
456+
fun test(): List<Poodle> = listOf()
457+
458+
interface Trait {
459+
var id: String
460+
}
461+
462+
interface MammalTrait : Trait {
463+
override var id: String
464+
}
465+
466+
interface PoodleTrait : MammalTrait {
467+
override var id: String
468+
}
469+
470+
abstract class Animal<T : Trait> {
471+
var id: String? = null
472+
abstract var traits: List<T>
473+
}
474+
475+
abstract class Dog<T : MammalTrait> : Animal<T>() {
476+
abstract override var traits: List<T>
477+
}
478+
479+
class Poodle(override var traits: List<PoodleTrait>) : Dog<PoodleTrait>()
480+
}
481+
405482
enum class EnumType {
406483
TEST
407484
}

0 commit comments

Comments
 (0)