-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QueryString with Search creating issue #87
Comments
I don't see anything wrong in the snippets you posted. I tried putting them together into a complete program, and can't reproduce the problem with it. It seems to work fine: package main
import (
"context"
"encoding/json"
"flag"
"fmt"
"log"
"os"
"github.com/shurcooL/githubv4"
"golang.org/x/oauth2"
)
func main() {
flag.Parse()
err := run()
if err != nil {
log.Println(err)
}
}
func run() error {
src := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: os.Getenv("GITHUB_GRAPHQL_TEST_TOKEN")},
)
httpClient := oauth2.NewClient(context.Background(), src)
client := githubv4.NewClient(httpClient)
// Query some details about a repository, an issue in it, and its comments.
{
var q struct {
Search struct {
RepositoryCount githubv4.Int
Edges []struct {
Node struct {
Repository struct {
Name githubv4.String
NameWithOwner githubv4.String
Owner struct {
Login githubv4.String
}
PrimaryLanguage struct {
Name githubv4.String
}
DefaultBranchRef struct {
Name githubv4.String
}
} `graphql:"... on Repository"`
}
}
} `graphql:"search(first: $count, query: $searchQuery, type: REPOSITORY)"`
}
variables := map[string]interface{}{
"searchQuery": githubv4.String(fmt.Sprintf(`user:%s language:%s`, githubv4.String("shurcooL"), githubv4.String("Go"))),
"count": githubv4.Int(2),
}
fmt.Println("searchQuery:", variables["searchQuery"])
err := client.Query(context.Background(), &q, variables)
if err != nil {
return err
}
printJSON(q)
}
return nil
}
// printJSON prints v as JSON encoded with indent to stdout. It panics on any error.
func printJSON(v interface{}) {
w := json.NewEncoder(os.Stdout)
w.SetIndent("", "\t")
err := w.Encode(v)
if err != nil {
panic(err)
}
} Output: searchQuery: user:shurcooL language:Go
{
"Search": {
"RepositoryCount": 36,
"Edges": [
{
"Node": {
"Repository": {
"Name": "vfsgen",
"NameWithOwner": "shurcooL/vfsgen",
"Owner": {
"Login": "shurcooL"
},
"PrimaryLanguage": {
"Name": "Go"
},
"DefaultBranchRef": {
"Name": "master"
}
}
}
},
{
"Node": {
"Repository": {
"Name": "Go-Package-Store",
"NameWithOwner": "shurcooL/Go-Package-Store",
"Owner": {
"Login": "shurcooL"
},
"PrimaryLanguage": {
"Name": "Go"
},
"DefaultBranchRef": {
"Name": "master"
}
}
}
}
]
}
} Are you sure your values for If you're still running into this, please provide a complete program that reproduces it. In general, a surefire way to debug these kind of issues is to inspect the GraphQL query generated and sent by the library. That can be done by modifying its source code or providing an |
Looks like the issue is coming due to not resetting token, I am getting below response on a few of git repo, however, others are giving me the right response I have modified the query a little bit to fine search So I am not sure how I will reset the token, so get the desire response. |
I have my code for fetching the information from repo based on programming language
Executing them but not getting any result back
See Below
While from Graphql
I am getting this
Any help, as I have seen most of the closed tickets, and implemented what has been suggested.
The text was updated successfully, but these errors were encountered: