Open hug6 opened 4 years ago
You can use a pointer to a struct, and check if the pointer value is nil
. For example:
var q struct {
RepositoryOwner *struct {
ProfileOwner struct {
PinnedItemsRemaining int
// ...
} `graphql:"... on ProfileOwner"`
} `graphql:"repositoryOwner(login: \"_dnxv__\")"`
}
// call client.Query(...)
if q.RepositoryOwner == nil {
// handle this case
}
// ...
query:
result:
but the variable
query
in golang is a struct, so how to check if it's null? any workaround or tricks?