Open shurup opened 3 years ago
GraphQL API for Discussions is finally announced. Does it mean we can expect the corresponding badge please?
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 :wink:
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.
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
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.
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. :)
I have asked in both places for good measure - GitHub Forum, Discussions Feedback. Will start working on the total discussions badge soon ✌
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
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. :)
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 https://github.com/badges/shields/issues/6047#issuecomment-836321560 for more details. I'll add the needs-upstream-help
to this issue for the time being.
I learnt many things. I love discussion and I will attend this continues.
:clipboard: 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
:link: 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.
:microphone: 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.