UnionTypeResolvers: Querying the same field multiple times, or different fields with same alias, override each other
leoloso opened this issue · comments
Leonardo Losoviz commented
When executing this query:
{
customPosts {
__typename
id
title @upperCase
self {
title
}
}
}
The response should be:
{
"data": {
"customPosts": [
{
"__typename": "Page",
"id": 2,
"title": "SAMPLE PAGE",
"self": {
"title": "Sample Page"
}
},
{
"__typename": "Post",
"id": 1,
"title": "HELLO WORLD!",
"self": {
"title": "Hello world!"
}
}
]
}
}
But instead it is:
{
"data": {
"customPosts": [
{
"__typename": "Page",
"id": 2,
"self": {
"title": "Sample Page"
}
},
{
"__typename": "Post",
"id": 1,
"self": {
"title": "Hello world!"
}
}
]
}
}
In this case, the title
field under self
is overriding the value of the first title
field. Hence, the value "Hello world!"
is overriding value "HELLO WORLD!"
. That's a bug.
Leonardo Losoviz commented
To test in GraphQL by PoP, use query:
?query=customPosts.__typename|id|title%3CupperCase%3E|self.title