GQL union
query not getting me the results
Below is what I've done,
type Body {
content: Content
}
union Content = TextContent | BannerContent
type TextContent {
text: String
}
type BannerContent {
banners: [Banner]
}
Front End Query,
query {
someField {
body {
content: {
...on TextContent {
text
}
...on BannerContent {
banners
}
}
}
}
}
My Resolver Function,
async getBannerContent(_, { bannerType }, { injector }: ModuleContext) {
try {
const response = await injector.get(Crs).getBanner(bannerType);
return response.body[0];
} catch (err) {}
}
In Front end I'm getting response as null for Content
.
Please help.
Note:- I'm using GQL modules.