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

[FEA]: Simplify GraphQL in our project automation #449

Open
1 task done
jarmak-nv opened this issue Sep 13, 2023 · 0 comments
Open
1 task done

[FEA]: Simplify GraphQL in our project automation #449

jarmak-nv opened this issue Sep 13, 2023 · 0 comments
Assignees
Labels
feature request New feature or request.

Comments

@jarmak-nv
Copy link
Collaborator

Is this a duplicate?

Area

Infrastructure

Is your feature request related to a problem? Please describe.

The automations are hard to read, partly because graphQL isn't a beautiful query language IMO, and partly because they're inefficient queries.

Describe the solution you'd like

We can and should use the global node IDs of items and query them directly. In action below:

query {
  organization(login: "${{ env.ORG }}") {
    repository(name: "${{ env.REPO }}") {
      issueOrPullRequest(number: ${{ env.PR_NUMBER }}) {
        ... on PullRequest {
          id
          projectItems(first: 10) {
            edges {
              node {
                id
                project {
                  id
                }
              }
            }
          }
        }
      }
    }
  }
}' > project_data.json

Can be simplified into:

query {
  node(id: "${{ env.PR_NODE_ID }}") {
    ... on PullRequest {
      projectItems(first: 10) {
        nodes {
          id
          project {
            id
          }
        }
      }
    }
  }
}' > project_data.json

Similarly, we don't need separate steps for an issue or PR to get its project specific ID, we can just modify the above query to include ... on Issue and query that. The output JSON will be the same regardless and downstream mutations don't care if it's a PR or an issue.

Describe alternatives you've considered

No response

Additional context

This saves us graphQL api usage, and it's always good to minimize that since we don't want to get rate limited on a busy day.

@jarmak-nv jarmak-nv added the feature request New feature or request. label Sep 13, 2023
@jarmak-nv jarmak-nv self-assigned this Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request.
Projects
Status: Todo
Development

No branches or pull requests

1 participant