From fcc324567d47b37f1a9d742f7a960f5f25f2c618 Mon Sep 17 00:00:00 2001 From: Kartikey-star Date: Wed, 7 Feb 2024 16:21:42 +0530 Subject: [PATCH] fetch projects using graphql Signed-off-by: Kartikey-star --- main.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index f76d6c7..cbb2979 100644 --- a/main.go +++ b/main.go @@ -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.