You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 16, 2019. It is now read-only.
Paweł Gutkowski edited this page Jul 28, 2017
·
1 revision
As Kotlin does not support unions, union properties have to be explicitly declared in Schema DSL. Creating union property requires defining resolver and return type. Return Type is reference returned by creation of union type.
Union type resolver is not type checked. Invalid resolver implementation which would return value of type other than members of union type will fail in runtime.
Example
data classUnionMember1(valone:String)
data classUnionMember2(valtwo:String)
data classPerson(valname:String, valage:Int)
KGraphQL.schema {
type<Person>{
unionProperty("union"){
returnType = unionType("UnionExample"){
type<UnionMember1>()
type<UnionMember2>()
}
resolver { person ->if (person.age <=18) UnionMember1("one") elseUnionMember2("two") }
}
}
}