Skip to content

Commit

Permalink
fetch projects using graphql
Browse files Browse the repository at this point in the history
Signed-off-by: Kartikey-star <[email protected]>
  • Loading branch information
Kartikey-star committed Feb 7, 2024
1 parent 8c21ad4 commit fcc3245
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,25 @@ func CallGithubApi() {
var listquery struct {
Organization struct {
Projectv2 struct {
Nodes struct {
id string
title string
Nodes []struct {
Id string
Title string
}
} `graphql:"projectsV2(first: 20)"`
} `graphql:"organization(login: \"open-connectors\")"`
} `graphql:"organization(login: $orgname)"`
}
// variables = map[string]interface{}{
// "orgname": githubv4.String("open-connectors"),
// }
err = client.Query(context.Background(), &listquery, nil)
variables = map[string]interface{}{
"orgname": githubv4.String("open-connectors"),
}
err = client.Query(context.Background(), &listquery, variables)
if err != nil {
fmt.Println(err)
}
// fmt.Println(listquery.Organization.Name)
fmt.Println(listquery.Organization.Projectv2.Nodes)
nodes := listquery.Organization.Projectv2.Nodes
for _, node := range nodes {
fmt.Println(node.Id)
fmt.Println(node.Title)
}
}

// printJSON prints v as JSON encoded with indent to stdout. It panics on any error.
Expand Down

0 comments on commit fcc3245

Please sign in to comment.