Discussions API: Allow specifying label in createDiscussion and updateDiscussion mutations #15431
Replies: 4 comments 5 replies
-
In the same way, it would be great to be able to specify a label in a query to get only discussions with that label. |
Beta Was this translation helpful? Give feedback.
-
I was trying to add/update discussion labels when I found this post/issue. For others who haven't already realized it, it is possible to add labels to a discussion via
|
Beta Was this translation helpful? Give feedback.
-
I've written up an issue in our backlog for this, thanks for reporting it and for finding somewhat of a workaround! |
Beta Was this translation helpful? Give feedback.
-
Hi there, If anyone want to create a discussion with labels on GitHub action, it will be able to use the following code! name: Create a discussion with labels
on:
workflow_dispatch:
jobs:
create_discussion_with_label:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Create a discussion
id: create_discussion
uses: octokit/graphql-action@v2.x
with:
title: "Sample Discussion!!!"
body: |-
Hello, this is a sample discussion created by GitHub Actions.
query: |
mutation($title:String!, $body:String!) {
createDiscussion(input: {repositoryId: "[YOUR_REPOSITORY_ID]", categoryId: "[YOUR_CATEGORY_ID]", title: $title, body: $body}) {
discussion {
id
}
}
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: octokit/graphql-action@v2.x
id: add_label
with:
query: |
mutation {
addLabelsToLabelable(
input:{
labelableId: "${{ fromJSON(steps.create_discussion.outputs.data).createDiscussion.discussion.id }}"
labelIds: ["[YOUR_LABEL_ID]]"]
}
) {
clientMutationId
}
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
Beta Was this translation helpful? Give feedback.
-
The
createDiscussion
andupdateDiscussion
mutations do not support an input field forlabel
:https://docs.github.com/en/graphql/guides/using-the-graphql-api-for-discussions#creatediscussion
This means that the API can't be used to set labels on a new/existing discussion. It'd be nice to be able to specify a label, just like on the Issues API.
Beta Was this translation helpful? Give feedback.
All reactions