Skip to content

Commit 3a1a5f6

Browse files
committed
Reference unions from the fields of wired types too, since a union can lead back to the wired type
1 parent 4171fb4 commit 3a1a5f6

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

‎src/main/kotlin/graphql/kickstart/tools/directive/DirectiveWiringHelper.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ internal class DirectiveWiringHelper(
7777
is GraphQLNonNull -> GraphQLNonNull.nonNull(of(type.wrappedType))
7878
is GraphQLList -> GraphQLList.list(of(type.wrappedType))
7979
// only these can lead back to the wired type. Scalars stay, since a reference only finds a scalar another field uses
80-
is GraphQLFieldsContainer, is GraphQLInputObjectType ->
80+
is GraphQLFieldsContainer, is GraphQLUnionType, is GraphQLInputObjectType ->
8181
if (schema.typeMap[type.name] === type) GraphQLTypeReference.typeRef(type.name) else built.getOrPut(type) { inFields(type) }
8282
else -> type
8383
}

‎src/test/kotlin/graphql/kickstart/tools/DirectiveTest.kt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,11 @@ class DirectiveTest {
273273
age: Int
274274
friend: Person @required
275275
best: Person @wrap
276+
someone: Someone
276277
}
277278
279+
union Someone = Person
280+
278281
input PersonFilter {
279282
name: String
280283
parent: PersonFilter @many
@@ -880,6 +883,7 @@ class DirectiveTest {
880883
class Person(val name: String, val age: Int = 1) {
881884
val friend: Person get() = this
882885
val best: Person get() = this
886+
val someone: Person get() = this
883887
}
884888

885889
data class PersonFilter(

0 commit comments

Comments
 (0)