Table of contents
To make requests against Discussions resources within the GraphQL API, you'll first need to be added to a feature flag.
If you're using a personal access token to authenticate the requests, your user account will need to be added to the flag. Personal access tokens need to be granted the public_repo
scope to perform Discussions-related mutations on public repositories, or the repo
scope for private repositories.
If you've created a GitHub App, the App itself will need to be added to the flag. Once it's been added, you'll be able to see the "Discussions" permission among your app permissions, which may then be granted as Read or Read & Write.
When making GraphQL requests, you'll then need to include the GraphQL-Features: discussions_api
HTTP header.
List the Discussions within a repository. If the optional categoryId
is specified, only results within that category will be returned.
Signature:
discussions(
after: String,
before: String,
first: Int,
last: Int,
categoryId: ID = null,
orderBy: DiscussionOrder = {field: UPDATED_AT, direction: DESC}
) : Discussion
"""
Ways in which lists of discussions can be ordered upon return.
"""
input DiscussionOrder {
"""
The direction in which to order discussions by the specified field.
"""
direction: OrderDirection!
"""
The field by which to order discussions.
"""
field: DiscussionOrderField!
}
"""
Properties by which discussion connections can be ordered.
"""
enum DiscussionOrderField {
"""
Order discussions by creation time.
"""
CREATED_AT
"""
Order discussions by most recent modification time.
"""
UPDATED_AT
}
Return the available discussion categories defined within this repository. Note that there is a maximum of 10 categories possible at the moment.
Signature:
discussionCategories(
after: String,
before: String,
first: Int,
last: Int,
) : DiscussionCategoryConnection!
Locate a specific discussion by its number. Returns null
if no such discussion exists or if the specified number is actually an Issue or Pull Request.
Signature:
discussion(number: Int!) : Discussion
Return discussions pinned to this repository, ordered by pin position (from left to right).
Signature:
pinnedDiscussions(
after: String,
before: String,
first: Int,
last: Int,
) : PinnedDiscussionConnection!
Notice that Connection types are not expanded here (for brevity). Each Connection type mentioned in the schema follows the same pattern that other connections in our API observe:
query {
repository(owner: "github", name: "some-repo") {
discussions(first: 10) {
# type: DiscussionConnection
totalCount # Int!
pageInfo {
# type: PageInfo (from the public schema)
startCursor
endCursor
hasNextPage
hasPreviousPage
}
edges {
# type: DiscussionEdge
cursor
node {
# type: Discussion
id
}
}
nodes {
# type: Discussion
id
}
}
}
}
Fields:
"""
A discussion in a repository.
"""
type Discussion implements Comment & Deletable & Lockable & Node & Reactable & RepositoryNode & Subscribable & Updatable {
"""
Reason that the conversation was locked.
"""
activeLockReason: LockReason
"""
The comment chosen as this discussion's answer, if any.
"""
answer: DiscussionComment
"""
The time when a user chose this discussion's answer, if answered.
"""
answerChosenAt: DateTime
"""
The user who chose this discussion's answer, if answered.
"""
answerChosenBy: Actor
"""
The actor who authored the comment.
"""
author: Actor
"""
Author's association with the subject of the comment.
"""
authorAssociation: CommentAuthorAssociation!
"""
The main text of the discussion post.
"""
body: String!
"""
The body rendered to HTML.
"""
bodyHTML: HTML!
"""
The body rendered to text.
"""
bodyText: String!
"""
The category for this discussion.
"""
category: DiscussionCategory!
"""
The replies to the discussion.
"""
comments(
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String
"""
Returns the elements in the list that come before the specified cursor.
"""
before: String
"""
Returns the first _n_ elements from the list.
"""
first: Int
"""
Returns the last _n_ elements from the list.
"""
last: Int
): DiscussionCommentConnection!
"""
Identifies the date and time when the object was created.
"""
createdAt: DateTime!
"""
Check if this comment was created via an email reply.
"""
createdViaEmail: Boolean!
"""
Identifies the primary key from the database.
"""
databaseId: Int
"""
The actor who edited the comment.
"""
editor: Actor
id: ID!
"""
Check if this comment was edited and includes an edit with the creation data
"""
includesCreatedEdit: Boolean!
"""
The moment the editor made the last edit
"""
lastEditedAt: DateTime
"""
`true` if the object is locked
"""
locked: Boolean!
"""
The number identifying this discussion within the repository.
"""
number: Int!
"""
Identifies when the comment was published at.
"""
publishedAt: DateTime
"""
A list of reactions grouped by content left on the subject.
"""
reactionGroups: [ReactionGroup!]
"""
A list of Reactions left on the Issue.
"""
reactions(
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String
"""
Returns the elements in the list that come before the specified cursor.
"""
before: String
"""
Allows filtering Reactions by emoji.
"""
content: ReactionContent
"""
Returns the first _n_ elements from the list.
"""
first: Int
"""
Returns the last _n_ elements from the list.
"""
last: Int
"""
Allows specifying the order in which reactions are returned.
"""
orderBy: ReactionOrder
): ReactionConnection!
"""
The repository associated with this node.
"""
repository: Repository!
"""
The path for this discussion.
"""
resourcePath: URI!
"""
The title of this discussion.
"""
title: String!
"""
Identifies the date and time when the object was last updated.
"""
updatedAt: DateTime!
"""
The URL for this discussion.
"""
url: URI!
"""
A list of edits to this content.
"""
userContentEdits(
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String
"""
Returns the elements in the list that come before the specified cursor.
"""
before: String
"""
Returns the first _n_ elements from the list.
"""
first: Int
"""
Returns the last _n_ elements from the list.
"""
last: Int
): UserContentEditConnection
"""
Check if the current viewer can delete this object.
"""
viewerCanDelete: Boolean!
"""
Can user react to this subject
"""
viewerCanReact: Boolean!
"""
Check if the viewer is able to change their subscription status for the repository.
"""
viewerCanSubscribe: Boolean!
"""
Check if the current viewer can update this object.
"""
viewerCanUpdate: Boolean!
"""
Did the viewer author this comment.
"""
viewerDidAuthor: Boolean!
"""
Identifies if the viewer is watching, not watching, or ignoring the subscribable entity.
"""
viewerSubscription: SubscriptionState
}
Fields
"""
A comment on a discussion.
"""
type DiscussionComment implements Comment & Deletable & Minimizable & Node & Reactable & Updatable & UpdatableComment {
"""
The actor who authored the comment.
"""
author: Actor
"""
Author's association with the subject of the comment.
"""
authorAssociation: CommentAuthorAssociation!
"""
The body as Markdown.
"""
body: String!
"""
The body rendered to HTML.
"""
bodyHTML: HTML!
"""
The body rendered to text.
"""
bodyText: String!
"""
Identifies the date and time when the object was created.
"""
createdAt: DateTime!
"""
Check if this comment was created via an email reply.
"""
createdViaEmail: Boolean!
"""
Identifies the primary key from the database.
"""
databaseId: Int
"""
The time when this replied-to comment was deleted
"""
deletedAt: DateTime
"""
The discussion this comment was created in
"""
discussion: Discussion
"""
The actor who edited the comment.
"""
editor: Actor
id: ID!
"""
Check if this comment was edited and includes an edit with the creation data
"""
includesCreatedEdit: Boolean!
"""
Has this comment been chosen as the answer of its discussion?
"""
isAnswer: Boolean!
"""
Returns whether or not a comment has been minimized.
"""
isMinimized: Boolean!
"""
The moment the editor made the last edit
"""
lastEditedAt: DateTime
"""
Returns why the comment was minimized.
"""
minimizedReason: String
"""
Identifies when the comment was published at.
"""
publishedAt: DateTime
"""
A list of reactions grouped by content left on the subject.
"""
reactionGroups: [ReactionGroup!]
"""
A list of Reactions left on the Issue.
"""
reactions(
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String
"""
Returns the elements in the list that come before the specified cursor.
"""
before: String
"""
Allows filtering Reactions by emoji.
"""
content: ReactionContent
"""
Returns the first _n_ elements from the list.
"""
first: Int
"""
Returns the last _n_ elements from the list.
"""
last: Int
"""
Allows specifying the order in which reactions are returned.
"""
orderBy: ReactionOrder
): ReactionConnection!
"""
The threaded replies to this comment.
"""
replies(
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String
"""
Returns the elements in the list that come before the specified cursor.
"""
before: String
"""
Returns the first _n_ elements from the list.
"""
first: Int
"""
Returns the last _n_ elements from the list.
"""
last: Int
): DiscussionCommentConnection!
"""
The discussion comment this comment is a reply to
"""
replyTo: DiscussionComment
"""
The path for this discussion comment.
"""
resourcePath: URI!
"""
Identifies the date and time when the object was last updated.
"""
updatedAt: DateTime!
"""
The URL for this discussion comment.
"""
url: URI!
"""
A list of edits to this content.
"""
userContentEdits(
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String
"""
Returns the elements in the list that come before the specified cursor.
"""
before: String
"""
Returns the first _n_ elements from the list.
"""
first: Int
"""
Returns the last _n_ elements from the list.
"""
last: Int
): UserContentEditConnection
"""
Check if the current viewer can delete this object.
"""
viewerCanDelete: Boolean!
"""
Can the current user mark this comment as an answer?
"""
viewerCanMarkAsAnswer: Boolean!
"""
Check if the current viewer can minimize this object.
"""
viewerCanMinimize: Boolean!
"""
Can user react to this subject
"""
viewerCanReact: Boolean!
"""
Can the current user unmark this comment as an answer?
"""
viewerCanUnmarkAsAnswer: Boolean!
"""
Check if the current viewer can update this object.
"""
viewerCanUpdate: Boolean!
"""
Reasons why the current viewer can not update this comment.
"""
viewerCannotUpdateReasons: [CommentCannotUpdateReason!]!
"""
Did the viewer author this comment.
"""
viewerDidAuthor: Boolean!
}
Fields
"""
A category for discussions in a repository.
"""
type DiscussionCategory implements Node & RepositoryNode {
"""
Identifies the date and time when the object was created.
"""
createdAt: DateTime!
"""
A description of this category.
"""
description: String
"""
An emoji representing this category.
"""
emoji: String!
"""
This category's emoji rendered as HTML.
"""
emojiHTML: HTML!
id: ID!
"""
Whether or not discussions in this category support choosing an answer with the markDiscussionCommentAsAnswer mutation.
"""
isAnswerable: Boolean!
"""
The name of this category.
"""
name: String!
"""
The repository associated with this node.
"""
repository: Repository!
"""
Identifies the date and time when the object was last updated.
"""
updatedAt: DateTime!
}
Fields:
"""
A Pinned Discussion is a discussion pinned to a repository's index page.
"""
type PinnedDiscussion implements Node & RepositoryNode {
"""
Identifies the date and time when the object was created.
"""
createdAt: DateTime!
"""
Identifies the primary key from the database.
"""
databaseId: Int
"""
The discussion that was pinned.
"""
discussion: Discussion!
"""
Color stops of the chosen gradient
"""
gradientStopColors: [String!]!
id: ID!
"""
Background texture pattern
"""
pattern: PinnedDiscussionPattern!
"""
The actor that pinned this discussion.
"""
pinnedBy: Actor!
"""
Preconfigured background gradient option
"""
preconfiguredGradient: PinnedDiscussionGradient
"""
The repository associated with this node.
"""
repository: Repository!
"""
Identifies the date and time when the object was last updated.
"""
updatedAt: DateTime!
}
Values
"""
Preconfigured background patterns that may be used to style discussions pinned within a repository.
"""
enum PinnedDiscussionPattern {
"""
An upward-facing chevron pattern
"""
CHEVRON_UP
"""
A hollow dot pattern
"""
DOT
"""
A solid dot pattern
"""
DOT_FILL
"""
A heart pattern
"""
HEART_FILL
"""
A friendly octocat face pattern
"""
OCTOFACE
"""
A plus sign pattern
"""
PLUS
}
Values
"""
Preconfigured gradients that may be used to style discussions pinned within a repository.
"""
enum PinnedDiscussionGradient {
"""
A gradient of blue to mint
"""
BLUE_MINT
"""
A gradient of blue to purple
"""
BLUE_PURPLE
"""
A gradient of pink to blue
"""
PINK_BLUE
"""
A gradient of purple to coral
"""
PURPLE_CORAL
"""
A gradient of red to orange
"""
RED_ORANGE
}
Implemented by the User
and Organization
types. (An Organization
will only have Discussions associated with it if it was converted from a User
.)
Fields
"""
Represents an author of discussions in repositories.
"""
interface RepositoryDiscussionAuthor {
"""
Discussions this user has started.
"""
repositoryDiscussions(
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String
"""
Filter discussions to only those that have been answered or not. Defaults to
including both answered and unanswered discussions.
"""
answered: Boolean = null
"""
Returns the elements in the list that come before the specified cursor.
"""
before: String
"""
Returns the first _n_ elements from the list.
"""
first: Int
"""
Returns the last _n_ elements from the list.
"""
last: Int
"""
Ordering options for discussions returned from the connection.
"""
orderBy: DiscussionOrder = {field: CREATED_AT, direction: DESC}
"""
Filter discussions to only those in a specific repository.
"""
repositoryId: ID
): DiscussionConnection!
}
Also implemented by the User
and Organization
types.
Fields
"""
Represents an author of discussion comments in repositories.
"""
interface RepositoryDiscussionCommentAuthor {
"""
Discussion comments this user has authored.
"""
repositoryDiscussionComments(
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String
"""
Returns the elements in the list that come before the specified cursor.
"""
before: String
"""
Returns the first _n_ elements from the list.
"""
first: Int
"""
Returns the last _n_ elements from the list.
"""
last: Int
"""
Filter discussion comments to only those that were marked as the answer
"""
onlyAnswers: Boolean = false
"""
Filter discussion comments to only those in a specific repository.
"""
repositoryId: ID
): DiscussionCommentConnection!
}
These mutations follow the same implementation pattern that other mutations in our GraphQL API do: each mutation accepts a single argument of an Input
type, named after the mutation, and returns a Payload
type containing the fields specified.
For example, here's a simple createDiscussion
mutation:
mutation {
# input type: CreateDiscussionInput
createDiscussion(input: {repositoryId: "1234", categoryId: "5678", body: "The body", title: "The title"}) {
# response type: CreateDiscussionPayload
discussion {
id
}
}
}
Input fields:
body: String!
The body of the new discussion.title: String!
The title of the new discussion.repositoryId: ID!
The ID of a repository in which to create the discussion.categoryId: ID!
The ID of aDiscussionCategory
within this repository.clientMutationId: String
A unique identifier for the client performing the mutation.
Return type fields:
clientMutationId: String
The unique identifier provided as an input.discussion: Discussion
The discussion that was created.
Input fields:
discussionId: ID!
The node ID of the discussion to update.body: String
The new contents of the discussion body.title: String
The new discussion title.categoryId: ID
The node ID of aDiscussionCategory
within the same repository to change this discussion to.clientMutationId: String
A unique identifier for the client performing the mutation.
Return type fields:
clientMutationId: String
The unique identifier provided as an input.discussion: Discussion
The discussion that was modified.
Input fields:
id: ID!
The node ID of the discussion to delete.clientMutationId: String
A unique identifier for the client performing the mutation.
Return type fields:
clientMutationId: String
The unique identifier provided as an input.discussion: Discussion
The discussion that was deleted.
Input fields:
body: String!
The contents of the comment.discussionId: ID!
The node ID of the discussion to comment on.replyToId: ID
The node ID of the discussion comment to reply to. If absent, the created comment will be a top-level comment.clientMutationId: String
A unique identifier for the client performing the mutation.
Return type fields:
clientMutationId: String
The unique identifier provided as an input.comment: DiscussionComment
The discussion comment that was created.
Input fields:
body: String!
The new contents of the comment body.commentId: ID!
The node ID of the discussion comment to update.clientMutationId: String
A unique identifier for the client performing the mutation.
Return type fields:
clientMutationId: String
The unique identifier provided as an input.comment: DiscussionComment
The discussion comment that was updated.
Input fields:
id: ID!
The node ID of the discussion comment to delete.clientMutationId: String
A unique identifier for the client performing the mutation.
Return type fields:
clientMutationId: String
The unique identifier provided as an input.comment: DiscussionComment
The discussion comment that was deleted.
Input fields:
id: ID!
The node ID of the discussion comment to mark as an answer.clientMutationId: String
A unique identifier for the client performing the mutation.
Return type fields:
clientMutationId: String
The unique identifier provided as an input.discussion: Discussion
The discussion that includes the chosen comment.
Input fields:
id: ID!
The node ID of the discussion comment to unmark as an answer.clientMutationId: String
A unique identifier for the client performing the mutation.
Return type fields:
clientMutationId: String
The unique identifier provided as an input.discussion: Discussion
The discussion that includes the unmarked comment.
Discussion
results may be returned from the top-level search
field. To do, specify a type: SearchType!
of DISCUSSION
. The SearchResultItemConnection
type has a discussionCount
field to report the number of returned Discussion objects, and the Discussion
type is added to the SearchResultItem
union.