Hopefully this is an error on my part. The query in the comment works in places like graphql explorer and postman but when I try to run it in Go I get the error:
Parse error on "{" (LCURLY) at [1, 36]
Can someone point out what I'm doing wrong?
Thanks in advance!
package main
import (
"context"
"fmt"
"os"
"github.com/shurcooL/githubv4"
"golang.org/x/oauth2"
)
/*
query($repoId: ID!) {
node(id: $repoId){
... on Repository {
id
name
}
}
}
*/
var query struct {
Node struct {
Repository struct {
ID string `graphql:"id"`
Name string `graphql:"name"`
}`graphql:"... on Repository"`
} `graphql:"node(id: $repoId")`
}
func main() {
repoID := "<INSERT REPO ID>"
GithubURL := os.Getenv("GITHUB_URL")
AccessToken := os.Getenv("ACCESS_TOKEN")
// Create a new GHE graphQL client
src := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: AccessToken},
)
httpClient := oauth2.NewClient(context.Background(), src)
v4client := githubv4.NewEnterpriseClient(GithubURL+"/api/graphql", httpClient)
variables := map[string]interface{}{
"repoId": githubv4.ID(repoID),
}
if err := v4client.Query(context.Background(), &query, variables); err != nil {
fmt.Println(err.Error())
return
}
fmt.Printf("%#v", query)
}
Hi Everyone,
Hopefully this is an error on my part. The query in the comment works in places like graphql explorer and postman but when I try to run it in Go I get the error:
Parse error on "{" (LCURLY) at [1, 36]
Can someone point out what I'm doing wrong?
Thanks in advance!