OrganizationProjectsV2 fetches all open projectsV2 for an organization.
(client *Client, repo ghrepo.Interface)
| 206 | |
| 207 | // OrganizationProjectsV2 fetches all open projectsV2 for an organization. |
| 208 | func OrganizationProjectsV2(client *Client, repo ghrepo.Interface) ([]ProjectV2, error) { |
| 209 | type responseData struct { |
| 210 | Organization struct { |
| 211 | ProjectsV2 struct { |
| 212 | Nodes []ProjectV2 |
| 213 | PageInfo struct { |
| 214 | HasNextPage bool |
| 215 | EndCursor string |
| 216 | } |
| 217 | } `graphql:"projectsV2(first: 100, orderBy: {field: TITLE, direction: ASC}, after: $endCursor, query: $query)"` |
| 218 | } `graphql:"organization(login: $owner)"` |
| 219 | } |
| 220 | |
| 221 | variables := map[string]interface{}{ |
| 222 | "owner": githubv4.String(repo.RepoOwner()), |
| 223 | "endCursor": (*githubv4.String)(nil), |
| 224 | "query": githubv4.String("is:open"), |
| 225 | } |
| 226 | |
| 227 | var projectsV2 []ProjectV2 |
| 228 | for { |
| 229 | var query responseData |
| 230 | err := client.Query(repo.RepoHost(), "OrganizationProjectV2List", &query, variables) |
| 231 | if err != nil { |
| 232 | return nil, err |
| 233 | } |
| 234 | |
| 235 | projectsV2 = append(projectsV2, query.Organization.ProjectsV2.Nodes...) |
| 236 | |
| 237 | if !query.Organization.ProjectsV2.PageInfo.HasNextPage { |
| 238 | break |
| 239 | } |
| 240 | variables["endCursor"] = githubv4.String(query.Organization.ProjectsV2.PageInfo.EndCursor) |
| 241 | } |
| 242 | |
| 243 | return projectsV2, nil |
| 244 | } |
| 245 | |
| 246 | // RepoProjectsV2 fetches all open projectsV2 for a repository. |
| 247 | func RepoProjectsV2(client *Client, repo ghrepo.Interface) ([]ProjectV2, error) { |
no test coverage detected