Closed
Description
When i start server with go run example/starwars/server/server.go
and execute this query :
query TestMerge {
hero {
__typename
name
... on Character {
...Droid
name
__typename
}
}
}
fragment Droid on Droid {
name
__typename
}
GraphiQL merge __typename field but the server response has multiple __typename.
Result with server response (browser network inspect) :
{"data":{"hero":{"__typename":"Droid","name":"R2-D2","__typename":"Droid","__typename":"Droid"}}}
Expected :
{"data":{"hero":{"name":"R2-D2","__typename":"Droid"}}}
With graphql-js __typename is merged.
link #365
Activity
pavelnikolov commentedon May 1, 2020
Hi, I just ran the following test:
go run example/starwars/server/server.go
I am closing this issue because I am unable to reproduce it in the latest version of the library.
pavelnikolov commentedon May 1, 2020
Oh, I just read more carefully. Indeed, the GraphiQL UI is merging this and is hiding the real problem. I am reopening the issue.

pavelnikolov commentedon May 1, 2020
Apparently there is an issue with our unit tests too. I just wrote this unit test and it passes:
pavelnikolov commentedon May 1, 2020
In our
testing.go
file we have this function:This function hides the real issue during tests 🤦
qneyrat commentedon May 2, 2020
Oh! yes
json.Unmarshal
merge same keys 🤕Any idea to fix that? I'll investigate.
pavelnikolov commentedon Mar 22, 2021
@qneyrat any luck with this?
qneyrat commentedon Mar 23, 2021
I dont know why field is merged but typename no.
Typename and name has different level in execFieldSelection but field name merged.
Before execFieldSelection
After exec (alias of field
pavelnikolov commentedon Mar 24, 2021
I haven't had the time to investigate but
__typename
is supposed to be also a key in the map. Could it be stored with different keys?Fixed duplicated __typename in response (fixes graph-gophers#369)
eko commentedon Mar 29, 2021
Hi,
I just proposed a fix, all tests seems to be still OK and I added a new test to ensure this issue is fixed :-)
Please let me know if you see something I should change because I don't know the code of this library.
Fixed duplicated __typename in response (fixes graph-gophers#369)
6 remaining items