1717package com.expediagroup.graphql.test.integration
1818
1919import com.expediagroup.graphql.TopLevelObject
20+ import com.expediagroup.graphql.annotations.GraphQLIgnore
21+ import com.expediagroup.graphql.extensions.deepName
2022import com.expediagroup.graphql.testSchemaConfig
2123import com.expediagroup.graphql.toSchema
2224import graphql.schema.GraphQLInterfaceType
2325import org.junit.jupiter.api.Test
2426import kotlin.test.assertEquals
2527import kotlin.test.assertNotNull
28+ import kotlin.test.assertNull
2629
2730class InterfaceOfInterfaceTest {
2831
2932 @Test
3033 fun `interface of interface` () {
3134 val queries = listOf (TopLevelObject (InterfaceOfInterfaceQuery ()))
3235 val schema = toSchema(queries = queries, config = testSchemaConfig)
33- assertEquals(expected = 1 , actual = schema.queryType.fieldDefinitions.size)
36+ assertEquals(expected = 2 , actual = schema.queryType.fieldDefinitions.size)
3437
3538 val implementation = schema.getObjectType(" MyClass" )
3639 assertNotNull(implementation)
@@ -49,6 +52,19 @@ class InterfaceOfInterfaceTest {
4952 assertNotNull(firstLevelInterface)
5053 }
5154
55+ @Test
56+ fun `ignore class and use interface as type` () {
57+ val queries = listOf (TopLevelObject (InterfaceOfInterfaceQuery ()))
58+ val schema = toSchema(queries = queries, config = testSchemaConfig)
59+
60+ // The ignored class should not be in the schema at all
61+ assertNull(schema.getType(" IgnoredClass" ))
62+
63+ assertEquals(expected = 2 , actual = schema.queryType.fieldDefinitions.size)
64+ val queryField = assertNotNull(schema.queryType.getFieldDefinition(" getIgnoredClass" ))
65+ assertEquals(" SecondLevel!" , queryField.type.deepName)
66+ }
67+
5268 interface FirstLevel {
5369 val id: String
5470 }
@@ -61,5 +77,12 @@ class InterfaceOfInterfaceTest {
6177
6278 class InterfaceOfInterfaceQuery {
6379 fun getClass () = MyClass (id = " 1" , name = " fooBar" )
80+ fun getIgnoredClass (): SecondLevel = IgnoredClass (id = " 2" , name = " baz" )
6481 }
82+
83+ @GraphQLIgnore
84+ class IgnoredClass (
85+ override val id : String ,
86+ override val name : String
87+ ) : SecondLevel
6588}
0 commit comments