Report a GraphQL Bug
What edition and version of Dgraph are you using?
Edition:
- SlashGraphQL
- Dgraph (community edition/Dgraph Cloud)
If you are using the community edition or enterprise edition of Dgraph, please list the version:
Dgraph Version
$ dgraph version
v21.03.0-56-gc900f96b3
Have you tried reproducing the issue with the latest release?
Yes.
Steps to reproduce the issue (paste the query/schema if possible)
I have a schema that I use a union type:
type Page {
PageID: ID!
components: [Component]
}
union Component = BannerComponent | TextComponent
type BannerComponent {
ComponentID: ID!
banner_url: String!
}
type TextComponent {
ComponentID: ID!
text: String!
}
And I created two components and assigned them to a page, So when I query page:
query getPageAndComponents {
queryPage {
PageID
components {
... on BannerComponent {
__typename
ComponentID
banner_url
}
... on TextComponent {
__typename
ComponentID
text
}
}
}
}
I get this result which is correct:
{
"data": {
"queryPage": [
{
"PageID": "0x3d4635056",
"components": [
{
"__typename": "BannerComponent",
"ComponentID": "0x3d4635055",
"banner_url": "https://banner.jpg"
},
{
"__typename": "TextComponent",
"ComponentID": "0x3d4635057",
"text": "sample"
}
]
}
]
}
Now I tried to delete one of the components:
mutation deleteTextComponent {
deleteTextComponent(filter: {
ComponentID: "0x3d4635057"
}) {
numUids
}
}
And as expected this is the result:
{
"data": {
"deleteTextComponent": {
"numUids": 1
}
}
Now When I want to query page and its components with the same query:
query getPageAndComponents {
queryPage {
PageID
components {
... on BannerComponent {
__typename
ComponentID
banner_url
}
... on TextComponent {
__typename
ComponentID
text
}
}
}
}
I get this error:
"errors": [
{
"message": "Non-nullable field 'banner_url' (type String!) was not present in result from Dgraph. GraphQL error propagation triggered.",
"locations": [
{
"line": 8,
"column": 9
}
],
"path": [
"queryPage",
0,
"components",
1,
"banner_url"
]
}
],
This is the URL if you want to give it a try:
https://green-pine.us-east-1.aws.cloud.dgraph.io/graphql
Expected behaviour and actual result.
Expected Result will be:
{
"data": {
"queryPage": [
{
"PageID": "0x3d4635056",
"components": [
{
"__typename": "BannerComponent",
"ComponentID": "0x3d4635055",
"banner_url": "https://banner.jpg"
}
]
}
]
}
}