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

Badge request: GitHub Discussions #6047

Open
shurup opened this issue Jan 12, 2021 · 12 comments
Open

Badge request: GitHub Discussions #6047

shurup opened this issue Jan 12, 2021 · 12 comments
Labels
needs-upstream-help Not actionable without help from a service provider service-badge Accepted and actionable changes, features, and bugs

Comments

@shurup
Copy link

shurup commented Jan 12, 2021

📋 Description

Since GitHub has recently launched Discussions, the relevant badges will be useful. The number of answered/unanswered/total discussions is the most obvious stats to be displayed, e.g.: https://img.shields.io/badge/discussions-100%20open-brightgreen

🔗 Data

It seems that while the GH Discussions feature is still in beta, no relevant public API is available at the moment. If that's true (I can't find any other information but other thoughts on this issue are most welcome), we'll have to wait when the API is implemented.

🎤 Motivation

It can bring more people to discussions what is especially relevant now as the feature has been recently introduced and not everyone visiting the repo may be aware of it.

Personally, we'd like to use it for werf and some other projects to let our community know they can use GH discussions to interact with developers and other users. Previously, we've been using our self-hosted forums (based on Discourse) and relevant badges.

@shurup shurup added the service-badge Accepted and actionable changes, features, and bugs label Jan 12, 2021
@chris48s chris48s added the needs-upstream-help Not actionable without help from a service provider label Jan 12, 2021
@chris48s
Copy link
Member

refs community/community#43

@shurup
Copy link
Author

shurup commented Feb 5, 2021

Discussions GraphQL API is now available in beta, details are here.

@shurup
Copy link
Author

shurup commented Feb 24, 2021

GraphQL API for Discussions is finally announced. Does it mean we can expect the corresponding badge please?

@calebcartwright
Copy link
Member

GraphQL API for Discussions is finally announced.

Thanks for the posts with updates!

Does it mean we can expect the corresponding badge please?

It's possible for someone to potentially work on it now that GitHub has made it possible to retrieve the underlying data. That doesn't necessarily mean someone is going immediately start working on the implementation though 😉

We've got a great Tutorial on how to add a badge if you or anyone else is interested in working on this, and there's other GitHub badges which leverage the v4 GraphQL API (e.g. deployments badge) that should serve as a good reference.

I think it would also be helpful if you could enumerate the specific badges you'd like to see so that someone working on adding the badge knows what the target is.

For example, are you requesting badges that show the raw respective counts of answered vs unanswered vs total discussions?


or more of the "out of" badges, e.g.

@calebcartwright calebcartwright added good first issue New contributors, join in! and removed needs-upstream-help Not actionable without help from a service provider labels Feb 24, 2021
@williamhorning
Copy link

For example, are you requesting badges that show the raw respective counts of answered vs unanswered vs total discussions?


or more of the "out of" badges, e.g.

I would like the raw count badges because they would match with the badges that I have on some of my repos

@profgrammer
Copy link
Contributor

Hi, there is an easy way to get the total number of discussions for a repository - the totalCount attribute can fetch us that.

I'm trying to work out how we can efficiently get the answered/unanswered discussions but cannot think of anything after going through the docs and trying out some sample queries in the explorer, since we can only fetch 100 records at once, and repeatedly calling the API for a repository that contains thousands of discussion threads doesn't seem very productive.

This is my first encounter with GraphQL, so please pardon me if I am missing something.

@PyvesB
Copy link
Member

PyvesB commented May 9, 2021

I'm trying to work out how we can efficiently get the answered/unanswered discussions but cannot think of anything after going through the docs and trying out some sample queries in the explorer, since we can only fetch 100 records at once, and repeatedly calling the API for a repository that contains thousands of discussion threads doesn't seem very productive.

This is my first encounter with GraphQL, so please pardon me if I am missing something.

Not too sure either, maybe it's worth asking at https://github.community or raising as feedback at https://github.com/github/feedback?

Having a badge with the total number of discussions would be a good first step though, we don't need to get all the above badges in one go. :)

@profgrammer
Copy link
Contributor

I have asked in both places for good measure - GitHub Forum, Discussions Feedback. Will start working on the total discussions badge soon ✌

@profgrammer
Copy link
Contributor

profgrammer commented May 10, 2021

The discussions API requires a header to be set ( 'GraphQL-Features': 'discussions_api'). My current fetch() function looks like this:

async fetch({ user, repo }) {
    return this._requestGraphql({
      query: gql`
        query($user:String!, $repo:String!) {
          repository(name: $repo, owner: $user) {
            discussions {
              totalCount
            }
          }
        }
      `,
      variables: { user, repo },
      schema,
      options: { headers: { 'GraphQL-Features': 'discussions_api' } },
      transformErrors
    })
  }

However, the header is not being recognized. Am I doing something wrong? I tried to debug the part where the API call is made, and the header is being passed properly. Even then the error thrown looks like the one when we don't pass the error. I cannot find any implementations where we pass headers to GraphQL APIs, so I'm kind of stuck. Please help!

EDIT: Seems like the headers weren't being incorporated while actually sending the request. Will fix this in my PR

@PyvesB
Copy link
Member

PyvesB commented May 10, 2021

You may know this already this already, but running the service tests with npm run test:services:trace -- --only=my-service will spit out a lot of useful debugging information. :)

@PyvesB
Copy link
Member

PyvesB commented May 11, 2021

Our first Discussions badge is now available, thanks to @profgrammer! 🍾

For example:
https://img.shields.io/github/discussions/badges/shields

The other badge requests are not really possible at the moment given the limitations of the GitHub API. See #6047 (comment) for more details. I'll add the needs-upstream-help to this issue for the time being.

@PyvesB PyvesB added needs-upstream-help Not actionable without help from a service provider and removed good first issue New contributors, join in! labels May 11, 2021
@paulmelnikow paulmelnikow changed the title GitHub Discussions badge Badge request: GitHub Discussions Jul 9, 2021
@DawnSee0823
Copy link

I learnt many things.
I love discussion and I will attend this continues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-upstream-help Not actionable without help from a service provider service-badge Accepted and actionable changes, features, and bugs
Projects
None yet
Development

No branches or pull requests

7 participants