I have two types Stream and Video and a listResources query that returns a mixed list of streams and videos:
type Stream {
pk: String!
starts_at: String!
}
type Video {
pk: String!
created_at: String!
}
union SearchResult = Stream | Video
type Query {
listResources(code: String!): [SearchResult]
}
and below an example of calling the query:
query {
listResources(code: "234") {
... on Stream {
pk
starts_at
}
... on Video {
pk
created_at
}
}
}
For some reason, even though the query should be formed correctly according to the appsync and graphql docs (https://graphql.org/learn/schema/#union-types, https://docs.aws.amazon.com/appsync/latest/devguide/interfaces-and-unions.html), the query throws a 400 error.
- Already checked the lambda locally and in cloudwatch, the lambda returns data correctly.
- If I change the return type of
listResourcesquery toAWSJSONthe data gets returned properly, which confirms proper funcitonality of the lambda. The error must either be the query return type or the schema definition.
Where might the culprit be?