openresource.dev icon indicating copy to clipboard operation
openresource.dev copied to clipboard

Display "Used by" data in Showcase for GH repositories

Open julien-deramond opened this issue 2 years ago • 2 comments

Prerequisites

Proposal

Display "Used by" data on the Showcase page for GtiHub repositories.

Example in the following screenshot provided by GitHub assets:

Screenshot 2023-05-01 at 21 57 11

Motivation and context

This information can be really useful to see if the project is actually already used or not without going to GitHub.

julien-deramond avatar May 01 '23 19:05 julien-deramond

After a bit of research, this seems to not be "properly" doable at the moment.

The Repository object accessible through the public GraphQL API (note that the same applies to the REST API) does include a dependencyGraphManifests. This field is only available under the access to a repository's dependency graph preview, altho this can be easily added to the existing script:

this.#query = octokit.graphql.defaults({
  headers: {
    authorization: `token ${process.env.GITHUB_TOKEN}`,
  },
+  mediaType: {
+    previews: ["hawkgirl-preview"],
+  }
});

Note The GraphQL schema members under preview cannot be accessed via the Explorer so this can only be tested locally.

Unfortunately, the DependencyGraphManifestConnection provided by the API when using this preview only contains dependencies but not dependents which is what we are looking for here to mimick the Used by section.

I would assume that this is only a matter of time before this is added to the API as this is a preview feature, but for now, this is not possible.

An alternative could be fetching the https://github.com/owner/repo/network/dependents page (example) and grab that information from the HTML, but I am personally not a huge fan of this approach.

HiDeoo avatar Jun 01 '23 14:06 HiDeoo

when using this preview only contains dependencies but not dependents which is what we are looking for here to mimick the Used by section.

It rings a bell! If I remember well, I was stuck here as well while looking for a solution.

An alternative could be fetching the https://github.com/owner/repo/network/dependents page (example) and grab that information from the HTML, but I am personally not a huge fan of this approach.

Yep, I agree.

Thanks a lot for looking at this issue, I'm going to put it "on hold" waiting for an API update.

julien-deramond avatar Jun 01 '23 15:06 julien-deramond