Closed atmosx closed 4 years ago
Hi @atmosx,
Thanks for providing the exact GraphQL query and the Go code you tried, it made investigating this very easy.
The problem is here:
-Repo []struct {
+Repo struct {
It is because the `graphql:"repo: node"`
field corresponds to a SearchResultItemEdge.node
, which a single SearchResultItem
, not a list.
It's unfortunate the error message is not more helpful in spotting where the problem is. I have added a comment in https://github.com/shurcooL/graphql/issues/46#issuecomment-570762336 to investigate if it's possible to improve that.
Slightly off topic, I want to point out you could simplify that query by using the nodes
field directly (since the only field in SearchResultItemEdge
being used is node
):
nodes {
... on Repository {
name
}
}
Its Go code equivalent:
Repos []struct {
Repository struct {
Name githubv4.String
} `graphql:"... on Repository"`
} `graphql:"nodes"`
Thanks @dmitshur for the prompt reply and simplified version of the query!
I'm closing the issue as it is solved.
Hello,
I'm trying to convert the following GraphQL expression to Golang
struct
:I came up with something like this:
However, I'm getting back an empty struct:
Ideas, thoughts?
Thank you for your time & Happy new year!
P.