Closed naikrovek closed 2 years ago
I suspect what's happening is that the type of Enterprise.Members a list of EnterpriseMember, which is a GraphQL union:
https://docs.github.com/en/graphql/reference/unions#enterprisemember
So its type can be EnterpriseUserAccount or User. You may not be able to directly access their fields.
In the GraphQL query you showed, you're using GraphQL inline fragments:
nodes {
... on User {
login
suspendedAt
}
}
You should try the same in the Go code. See https://github.com/shurcooL/githubv4#inline-fragments for an example. It might look something like this:
var q struct {
Enterprise struct {
Members struct {
- Nodes []user
+ Nodes []struct {
+ User user `graphql:"... on User"`
+ }
PageInfo struct {
HasNextPage bool
EndCursor githubv4.String
}
} `graphql:"members(first: 100, after: $cursor)"`
} `graphql:"enterprise(slug: \"asdf\")"`
}
Thank you. I love you lol
Hello, thank you for this library. It will be extremely useful to me, if I can get through my small problem, here.
I have this GraphQL query which works fine if I run it in a tool like Insomnia:
but this query in your githubv4 library produces an error:
The error I get is this:
Selections can't be made directly on unions (see selections on EnterpriseMember)
which is a bit of a surprise to me, because this is effectively copied verbatim from your example on pagination, with relevantstruct
s changed to match the working GraphQL query above.I have a strong feeling that I am missing something very trivial that is obvious to you, so I'm asking if you see the problem, in the hopes that you can help.
Thank you again!