How to implement union in spring-graphql. I get error that I’m requesting object but its rather a ‘graphql.schema.GraohQLUnionType’

How to implement union in spring-graphql. I get error that I’m requesting object but its rather a ‘graphql.schema.GraohQLUnionType’


0

I wanted to create a union named Tables, that holds all the other tables and the user can request the table accordingly.
I get the error:
You have asked for named object type ‘Tables’, but it’s not an object type but rather a ‘graphql.schema.GraohQLUnionType’

Here is my graphql schema:

type Query{ 
  getData: [Tables]
}
union Tables = Address | Identifier
My query is a simple one: 
query allData{ 
 getData{ 
  __typename 
 } 
}

My Java method looks like this:

@QueryMapping 
Public List getData() { 
 return List.of{ new Address() }; }

I saw some implementations and this should work, but throws an error in my case.

I simply wanted to create a generic controller that can serve as an entry point for all the tables.
I thought union would do the job, what can I do in this case?


Load 5 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *