How could I paginate GraphQL calls? #1479
-
Hi all, Here's my code: query = <<-GRAPHQL
{
repository(name: "octokit.rb", owner: "octokit") {
discussions(orderBy: {field: UPDATED_AT, direction: ASC}, first: 1) {
edges {
node {
id
author {
login
}
title
number
comments(first: 1) {
nodes {
author {
login
}
}
}
}
}
pageInfo {
startCursor
hasNextPage
endCursor
}
totalCount
}
}
}
GRAPHQL
_client.post('/graphql', { query: query }.to_json) Any feedback is welcome. If this is not easily possible with the library, I will have to fabricate something myself. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
👋🏻 Hi @Brend-Smits! We don't have any functionality built into Octokit.rb for GraphQL or especially GraphQL pagination. As you've spotted, you can make a GraphQL request from Octokit, but it doesn't really go any further than that. I don't have any sample code for that - but in principle, you need to take the I hope that helps! Happy to assist if you run into any issues, and it would be fantastic if you could share any code you wrote. |
Beta Was this translation helpful? Give feedback.
👋🏻 Hi @Brend-Smits! We don't have any functionality built into Octokit.rb for GraphQL or especially GraphQL pagination. As you've spotted, you can make a GraphQL request from Octokit, but it doesn't really go any further than that.
I don't have any sample code for that - but in principle, you need to take the
endCursor
returned and pass it in to thediscussions
connection using theafter
param - and just keep looping untilhasNextPage
isfalse
.I hope that helps! Happy to assist if you run into any issues, and it would be fantastic if you could share any code you wrote.