Replies: 2 comments 1 reply
|
The REST API does not currently expose a 1:1 equivalent of the Issues API for repository Discussions. For querying Discussions, the supported API is the GraphQL API. In particular, you can query a repository's discussions connection and use GraphQL pagination with first/after. For example: query($owner: String!, $repo: String!, $cursor: String) {
repository(owner: $owner, name: $repo) {
discussions(first: 100, after: $cursor) {
nodes {
number
title
state
category {
name
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}Then use endCursor as the after value for the next request. This is also why the REST endpoint does not behave like /issues: Discussions were exposed through GraphQL first, while the REST API has a more limited surface for them. So if you need things like pagination, filtering, categories, or richer discussion metadata, GraphQL is currently the better API to use. |
|
The Discussions API is exposed through GitHub's GraphQL API rather than the REST Issues-style endpoint. The current GraphQL schema supports both cursor-based pagination and filtering directly on query($owner: String!, $repo: String!, $cursor: String) {
repository(owner: $owner, name: $repo) {
discussions(
first: 100
after: $cursor
answered: false
states: [OPEN]
orderBy: { field: CREATED_AT, direction: DESC }
) {
nodes {
number
title
createdAt
category {
name
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}For pagination, pass You can also use So if the goal is to retrieve unanswered/open discussions, there is no need to fetch everything and filter it afterward in JavaScript. The GraphQL API supports |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I need to query discussions, and whilst
https://api.github.com/repos/org/repo/discussionsendpoint is working, it doesn't seem to accept the same parameters asissuesendpoint. E.g., it doesn't do paging or filter by state.Where can I find the docs?
All reactions