Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate GitHub's GraphQL API #44

Closed
AlekSi opened this issue May 9, 2022 · 2 comments · Fixed by #64
Closed

Investigate GitHub's GraphQL API #44

AlekSi opened this issue May 9, 2022 · 2 comments · Fixed by #64
Assignees
Labels
code/chore Code maintenance improvements

Comments

@AlekSi
Copy link
Member

AlekSi commented May 9, 2022

For #45, we will need to start interacting with GitHub Projects (beta) via GraphQL API: https://docs.github.com/en/issues/trying-out-the-new-projects-experience/using-the-api-to-manage-projects

First, let's try querying that API manually via gh tool.

Second, let's investigate what Go modules we should use for that API (probably https://github.com/shurcooL/githubv4?)

Lastly, let's add some code to conform-pr GitHub Action that queries project's iteration for PRs.

@AlekSi AlekSi added the code/chore Code maintenance improvements label May 10, 2022
@rumyantseva
Copy link
Contributor

rumyantseva commented Jun 20, 2022

Current state

WiP in a local branch - https://github.com/rumyantseva/github-actions/tree/issue-44-trying-graphql (there are some things to try/discuss)

@AlekSi AlekSi added not ready Issues that are not ready to be worked on; PRs that should skip CI and removed not ready Issues that are not ready to be worked on; PRs that should skip CI labels Jun 20, 2022
@rumyantseva
Copy link
Contributor

rumyantseva commented Jun 21, 2022

Main learnings

API

  • There is no GraphQL API for GithubActions.
  • Useful docs: everything starting from the ProjectNext prefix here. ProjectNext is used for new (beta) projects.
  • If we are going to use GraphQL from GitHub CI, it might be important to keep in mind Rate Limit.

Objects and ids

  • PR - PR_
  • Issue - I_
  • Project Next (new beta projects) - PN_
  • Card on a board (project next item) - PNI_ (draft, issue or pull request)
  • View in a project next - PNV_
  • Field in a project next - PNF_
  • Field values (in cards) - PNIFV_
  • etc.

How to find PR id or Issue id from Card

It works through content:

{
	user(login: "rumyantseva") {
		
		projectNext(number: 1) {
			id 
			title
			
			items(first: 20) {
				totalCount
				nodes {
					id
					title
					type
					content {
						... on PullRequest  {
								id
						}
						
						... on Issue {
							id
						}
					}

...

				}
			}
		
		}
	}
}

How to find current status, sprint, etc

It is set in field values (PNIFV_) for cards (PNI_), but not for PR/Issue themselves.

How to find a PNI card by Issue id or PR id?

Through projectNextItems:

{
	node(id: "PR_kwDOGTO-Gs45XwlA") { 
		... on PullRequest  {
			
			title
			state
			id
			
			
			projectNextItems(first: 20) {
				totalCount
				nodes {
					id
					fieldValues(first: 20) {
						totalCount
						nodes {
							value
							projectField {
								name 
								settings 
							}
						}
					}
				}
				
			}
			
		}	
		
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code/chore Code maintenance improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants