robvanderleek / create-issue-branch

Boost your GitHub workflow 🚀
https://github.com/apps/create-issue-branch
ISC License
325 stars 42 forks source link

copyIssueProjectsToPR does not work for Projects #922

Open bagermen opened 4 days ago

bagermen commented 4 days ago

I guess copyIssueProjectsToPR works for Classic Projects but not for new Projects.

The query shows me my project:

projectItems(first: 1) {
  nodes {
    project {
      id
    }
  }
}

This one return empty results

projectCards {
  nodes {
    project {
      id
    }
  }
}

There should be at least a note for that in the documentation

create-issue-branch[bot] commented 2 days ago

Branch issue-922-copyIssueProjectsToPR_does_not_work_for_Projects created!

robvanderleek commented 2 days ago

Hi @bagermen

You are right, it broke for the "new" projects, thanks for the detailed issue!

So far, I'm able to query "classic" and "new" projects IDs:

query ($owner: String!, $repo: String!, $number: Int!) {
    repository(owner: $owner, name: $repo) {
      issue(number: $number) {
        projectCards {
          nodes {
            project {
              id
            }
          }
        },
        projectItems(first: 10) {
          nodes {
            project {
              id
            }
          }
        }
      }
    }
  }

Unfortunately, I'm unable to use the IDs from the projectItems part in the mutation for the pull-request. The following mutation gives the error message "Could not resolve to Project node with the global id of 'PVT_kwDOBL_hb84ApI2u'":

mutation ($pullRequestId: ID!, $projectIds: [ID!]) {
  updatePullRequest(
    input: {pullRequestId: $pullRequestId, projectIds: $projectIds}
  ) {
    pullRequest {
      id
    }
  }
}

I'm using the GitHub GraphQL explorer for testing.

One difference I noticed in the query is that for "new" projects, the node type is "Projectv2", where the error message mentions a "Project" node. But I'm not sure if that's causing the error.

It would be helpful if you could verify the above behavior on your own projects/PRs.

Kind regards, Rob