How can I implement pagination in the entries in the following GraphQL query? #72141
-
Select Topic AreaQuestion BodyI am trying to figure out how to add pagination, like first & after for the entries. & Does this query tells all the name regardless of the number? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
{
__type(name: "Tree") {
name
fields {
name
args {
name
}
}
}
}{
"data": {
"__type": {
"name": "Tree",
"fields": [
{
"name": "abbreviatedOid",
"args": []
},
{
"name": "commitResourcePath",
"args": []
},
{
"name": "commitUrl",
"args": []
},
{
"name": "entries",
"args": []
},
{
"name": "id",
"args": []
},
{
"name": "oid",
"args": []
},
{
"name": "repository",
"args": []
}
]
}
}
}
...
{
"name": "starredRepositories",
"args": [
{
"name": "after"
},
{
"name": "before"
},
{
"name": "first"
},
{
"name": "last"
},
{
"name": "ownedByViewer"
},
{
"name": "orderBy"
}
]
},
...
Yes, it appears to return all names, but it may fail if the query takes too long. According to a talk I watched, the query will fail if it exceeds 10 seconds (mentioned at the 17-minute mark).
Here is an example of a query that will likely fail due to a timeout.
{
repository(owner: "itsnebulalol", name: "sdks") {
object(expression: "@:macOS14.0.sdk/usr/share/man") {
... on Tree {
entries {
name
object {
... on Tree {
entries {
name
}
}
}
}
}
}
}
}{
"data": null,
"errors":[
{
"message":"Something went wrong while executing your query. This may be the result of a timeout, or it could be a GitHub bug. Please include `DE86:3A75B8:15565:3FEB8:653B2DE0` when reporting this issue."
}
]
}If you need to paginate the entries field, you would need to wait for GitHub to provide this functionality. In the meantime, you can only modify the JSON response yourself. Hopefully, the query will be successful. |
Beta Was this translation helpful? Give feedback.
-
|
I have a similar query which fails regularly (seemingly due to a timeout) and I'm wondering if GitHub has made any recent improvements regarding the pagination of the entries field. My query... Assuming no, I am thinking of a simpler query to get the 1st layer and subsequent queries to get the 2nd layer (for each 1st layer element). Testing proves that it will work but at a cost of performance (700+ entries in total). Thanks in advance, Tom |
Beta Was this translation helpful? Give feedback.
GraphQL APIis introspective in your case theentriesfield on theTreeobject doesn't take any arguments{ __type(name: "Tree") { name fields { name args { name } } } }{ "data": { "__type": { "name": "Tree", "fields": [ { "name": "abbreviatedOid", "args": [] }, { "name": "commitResourcePath", "args": [] }, { "name": "commitUrl", "args": [] }, { "name": "entries", "args": [] }, { "name": "id", "args": [] }, { "name": "oid", …