(Imagine the user wants to serialize the response later, or uses some struct that happens to have json tags defined for other reasons.)
The JSON-encoded response from GraphQL server will be:
{
"data": {
"viewer": {
"login": "gopher"
}
}
}
So query.Viewer.Login will not be populated, since the Go struct has a JSON tag calling it "username", but the field is "login" in the response, which doesn't match.
This happens because encoding/json package, which is currently used to decode the JSON response from GraphQL server into the query data structure, is affected by json struct field tags.
Related to #10, because a solution to that will resolve this too.
If you do a query like this:
(Imagine the user wants to serialize the response later, or uses some struct that happens to have json tags defined for other reasons.)
The JSON-encoded response from GraphQL server will be:
So
query.Viewer.Login
will not be populated, since the Go struct has a JSON tag calling it "username", but the field is "login" in the response, which doesn't match.This happens because
encoding/json
package, which is currently used to decode the JSON response from GraphQL server into the query data structure, is affected byjson
struct field tags.Related to #10, because a solution to that will resolve this too.