How does one specify that a certain resolver retur...
# kgraphql
m
How does one specify that a certain resolver returns I union type. I see how to define a type in the docs but not how to use it
j
Hi, Sorry for being so inactive the latetly. I will be more active in this project soon again 🙂 I have updated the docs for union types with a bit more example code: https://kgraphql.io/Reference/Type%20System/unions/ Currently there is one common use case that is not supported which is using non sealed classes union types within query definitions. Other than this everything should work.
m
I see. I am trying to return either the error or an object based on the union type above. However when I build I still get this error.
j
these screenshots do not show where you are trying to return your union type. But by the error you are getting it seems you are using the
query
. Which I mentioned currently is not supported 😞
m
sorry here us the full operation
it is a mutation and I am trying to return the encodedTokens if they are not null otherwise the errorMessage
j
Sorry I mean both
query
and
mutation
are not supported as they are both using the same DSL implementation. Currently a workaround is required to make something like this work. Which is to change the
EncodedTokens
and
ServerError
to a Kotlin Sealed class.