EddieHubCommunity / HealthCheck

Checks how friendly your Open Source project is and suggests improvements! Sponsored by @Flagsmith
https://healthcheck.eddiehubcommunity.org
MIT License
70 stars 26 forks source link

GitHub projects REST API move to GraphQL #249

Closed SaptarshiSarkar12 closed 1 month ago

SaptarshiSarkar12 commented 2 months ago

Description

In my Drifty project, I use GitHub projects for streamlining issues and milestones and is actively updated. But HealthCheck shows that GitHub Projects is not used and is asked to be removed.

You can check the latest report generated here - https://healthcheck.eddiehubcommunity.org/repo/report/cm0ze3dl800151w3l05qyxazu

Screenshots

image

Additional information

I wish to discuss and work on this issue.

eddiejaoude commented 2 months ago

Relevant files

SaptarshiSarkar12 commented 2 months ago

@eddiejaoude Thank you Eddie :slightly_smiling_face: for providing the relevant files. I suppose the problem occurs in projectsData.length === 0 check. I will try and open a PR if I do not encounter any issues while fixing. Can you please assign the issue to me?

eddiejaoude commented 2 months ago

Sure I can assign it to you. I was just making notes before my call about the issue. Here are some more of my findings when researching

Your repo data https://api.github.com/repos/SaptarshiSarkar12/Drifty

// ...
"has_projects": true,
// ...

But I think the issue is not with our conditional checks but all GitHub Projects were migrated from "classic" to "new", so the API we are using is for "classic" so all projects now will get an error for this.

response = await octokit.rest.projects.listForRepo(...)

I think this needs to be updated to query the new Project board API.

SaptarshiSarkar12 commented 2 months ago

@eddiejaoude Thank you for providing your research data. That would help me in fixing this bug.

But I think the issue is not with our conditional checks but all GitHub Projects were migrated from "classic" to "new", so the API we are using is for "classic" so all projects now will get an error for this.

response = await octokit.rest.projects.listForRepo(...)

I think this needs to be updated to query the new Project board API.

Yes, you are correct. I tested with gh api and it returned an empty result. As I read through the rest api docs, I found this important information :point_down:

Creation of new projects (classic) is now disabled. Projects (classic) will be sunset and removed on August 23, 2024. You can read more about this change on the GitHub Blog.

and GitHub asks us to use the GraphQL api for accessing information about the new Projects. Here's the GraphQL docs - https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/using-the-api-to-manage-projects So, I think we should be using the GraphQL api to get info about projects. What do you think? Please let me know.

eddiejaoude commented 2 months ago

Thank you for researching further. That is a shame that GitHub doesn't support REST for the new project boards.

Octokit seems to have a GraphQL version also, which could be used to query for projects https://github.com/octokit/graphql.js

I will remove the project check from the report for now, so it doesn't confuse people.

If this issue could update src/utils/github/getProjectsApi.js to use octokit/graphql?

eddiejaoude commented 2 months ago

Here is the temporary fix https://github.com/EddieHubCommunity/HealthCheck/commit/2bd924a0fe7df061dd7affbb3fa441b27ab141a0

SaptarshiSarkar12 commented 2 months ago

That is a shame that GitHub doesn't support REST for the new project boards.

@eddiejaoude Yes, that's true. But GitHub has publicly disclosed the reason why it chose GraphQL over REST for the new Projects board. You can read it here - https://github.blog/developer-skills/github/the-github-graphql-api/#the-future:~:text=Our%20new%20Projects,these%20simultaneous%20releases.

Octokit seems to have a GraphQL version also, which could be used to query for projects https://github.com/octokit/graphql.js

Yeah, we can use that.

I will remove the project check from the report for now, so it doesn't confuse people.

Yeah, that's better.

If this issue could update src/utils/github/getProjectsApi.js to use octokit/graphql?

Yes, I will make the change and test it locally using my repo data. Thank you for helping.

eddiejaoude commented 2 months ago

Great! Thank you 👍