Skip to content

Commit fcc3245

Browse files
committed
fetch projects using graphql
Signed-off-by: Kartikey-star <[email protected]>
1 parent 8c21ad4 commit fcc3245

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

main.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,25 @@ func CallGithubApi() {
5858
var listquery struct {
5959
Organization struct {
6060
Projectv2 struct {
61-
Nodes struct {
62-
id string
63-
title string
61+
Nodes []struct {
62+
Id string
63+
Title string
6464
}
6565
} `graphql:"projectsV2(first: 20)"`
66-
} `graphql:"organization(login: \"open-connectors\")"`
66+
} `graphql:"organization(login: $orgname)"`
6767
}
68-
// variables = map[string]interface{}{
69-
// "orgname": githubv4.String("open-connectors"),
70-
// }
71-
err = client.Query(context.Background(), &listquery, nil)
68+
variables = map[string]interface{}{
69+
"orgname": githubv4.String("open-connectors"),
70+
}
71+
err = client.Query(context.Background(), &listquery, variables)
7272
if err != nil {
7373
fmt.Println(err)
7474
}
75-
// fmt.Println(listquery.Organization.Name)
76-
fmt.Println(listquery.Organization.Projectv2.Nodes)
75+
nodes := listquery.Organization.Projectv2.Nodes
76+
for _, node := range nodes {
77+
fmt.Println(node.Id)
78+
fmt.Println(node.Title)
79+
}
7780
}
7881

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

0 commit comments

Comments
 (0)