I'm searching for an answer to this problem, and it seems others have as well but no clear answer I could find anywhere (Appsync query union return type throws 400)
I have a GraphlQL type that has a property than can return either a String or an array of Strings, like so.
type Button {
color: String | [String]
}
Is there a way to accomplish this using Appsync? I've tried using a Union, but get a 400 error instead
type ColorSingle {
color: String
}
type ColorMulti {
color: [String]
}
union Colors = ColorSingle | ColorMulti
type Button {
color: Colors
}
and the query:
getSource(sourceId: "company") {
themeConfig {
component {
...on ColorSingle {
__typename
color
}
...on ColorMulti {
__typename
color
}
}
}
}