A uniontype accepts only ObjectTypes as argument for possibleType. Not a TypeReference.
newUnionType()
.possibleType(newObject().build()) //Works
.possibleType(new GraphQLTypeReference("SomeOtherType")) //doesn't work!
.build();
Is this on purpose? Is there a workaround to allow two objects to reference each other in fields with a union type? i.e. How can I make the code below work?
GraphQLObjectType extraObject = newObject()
.name("extraObject")
.field(newFieldDefinition()
.name("some field")
.type(Scalars.GraphQLString)
).build();
GraphQLObjectType objA = newObject()
.name("objA")
.field(newFieldDefinition()
.name("some field")
.type(newUnionType()
.possibleType(extraObject)
.possibleType(new GraphQLTypeReference("objB")) //doesn't work
)
).build();
GraphQLObjectType objB = newObject()
.name("objB")
.field(newFieldDefinition()
.name("some field")
.type(newUnionType()
.possibleType(extraObject)
.possibleType(objA)
)
).build();
A uniontype accepts only ObjectTypes as argument for possibleType. Not a TypeReference.
Is this on purpose? Is there a workaround to allow two objects to reference each other in fields with a union type? i.e. How can I make the code below work?