-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
What would be expected to happen in the case of a query like:
octokit.graphql.paginate(
`query ($ids: [ID!]!, $cursor: String) {
nodes(ids: $ids) {
... on Repository {
nameWithOwner
defaultBranchRef {
target {
... on Commit {
history(first: 5, after: $cursor) {
totalCount
nodes {
oid
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
}
}
}
}`,
{
ids: ["R_kgDOFzp8zg"],
},
).then(console.log);
There’s a section in the docs about nested pagination being unsupported and I think you would consider this query to have nested pagination but it’s slightly different from the example provided because it only has one layer of pagination, it’s just that the pagination is nested. I guess I’m not totally sure what the docs specifically mean by “nested”.
For what it’s worth, when I run this query I get:
/Users/williammartin/workspace/octokit-playground/node_modules/@octokit/plugin-paginate-graphql/dist-node/index.js:68
throw new MissingPageInfo(responseData);
^
MissingPageInfo: No pageInfo property found in response. Please make sure to specify the pageInfo in your query. Response-Data: {
"nodes": [
{
"nameWithOwner": "samcoe/gh-triage",
"defaultBranchRef": {
"target": {
"history": {
"totalCount": 7,
"nodes": [
{
"oid": "d17b7ae2bdf9d3826ccea2b583fd850339821be4"
},
{
"oid": "f7399a6f0bcad0f28ff09ae3af60a03ac14f629d"
},
{
"oid": "8645e1e0199b306d1ed1587c01b75580f57fe170"
},
{
"oid": "003d962ebb25229d570367194bdad3d6f3296c60"
},
{
"oid": "a7c2afb0404dd0b478974998bf07e293cd73c08b"
}
],
"pageInfo": {
"hasNextPage": true,
"endCursor": "d17b7ae2bdf9d3826ccea2b583fd850339821be4 4"
}
}
}
}
}
]
}
at findPaginatedResourcePath (/Users/williammartin/workspace/octokit-playground/node_modules/@octokit/plugin-paginate-graphql/dist-node/index.js:68:11)
at extractPageInfos (/Users/williammartin/workspace/octokit-playground/node_modules/@octokit/plugin-paginate-graphql/dist-node/index.js:108:24)
at Object.next (/Users/williammartin/workspace/octokit-playground/node_modules/@octokit/plugin-paginate-graphql/dist-node/index.js:139:35)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Function.paginate (/Users/williammartin/workspace/octokit-playground/node_modules/@octokit/plugin-paginate-graphql/dist-node/index.js:189:22) {
response: {
nodes: [
{
nameWithOwner: 'samcoe/gh-triage',
defaultBranchRef: { target: { history: [Object] } }
}
]
}
}
But because I’m already on shaky ground with js and not sure from the previous question if I’m using it correctly I’m not sure if I’m “holding it wrong”.
Adding the real API responses I get from the API as a test to the merge responses functionality shows the same thing.
it("does something with nested pagination?", () => {
const response1 = {
data: {
nodes: [
{
nameWithOwner: "samcoe/gh-triage",
defaultBranchRef: {
target: {
history: {
totalCount: 7,
nodes: [
{
oid: "d17b7ae2bdf9d3826ccea2b583fd850339821be4",
},
{
oid: "f7399a6f0bcad0f28ff09ae3af60a03ac14f629d",
},
{
oid: "8645e1e0199b306d1ed1587c01b75580f57fe170",
},
{
oid: "003d962ebb25229d570367194bdad3d6f3296c60",
},
{
oid: "a7c2afb0404dd0b478974998bf07e293cd73c08b",
},
],
pageInfo: {
hasNextPage: true,
endCursor: "d17b7ae2bdf9d3826ccea2b583fd850339821be4 4",
},
},
},
},
},
],
},
};
const response2 = {
data: {
nodes: [
{
nameWithOwner: "samcoe/gh-triage",
defaultBranchRef: {
target: {
history: {
totalCount: 7,
nodes: [
{
oid: "322114e39d2cb4b0e129b66c798dfdf85baf7d48",
},
{
oid: "7c3e8342d4e4e960e013c1068bead72ec51552a2",
},
],
pageInfo: {
hasNextPage: false,
endCursor: "d17b7ae2bdf9d3826ccea2b583fd850339821be4 6",
},
},
},
},
},
],
},
};
const result = mergeResponses(response1, response2);
});
FAIL test/merge-responses.test.ts
● .mergeResponses() › does something with nested pagination?
MissingPageInfo: No pageInfo property found in response. Please make sure to specify the pageInfo in your query. Response-Data: {
"data": {
"nodes": [
{
"nameWithOwner": "samcoe/gh-triage",
"defaultBranchRef": {
"target": {
"history": {
"totalCount": 7,
"nodes": [
{
"oid": "d17b7ae2bdf9d3826ccea2b583fd850339821be4"
},
{
"oid": "f7399a6f0bcad0f28ff09ae3af60a03ac14f629d"
},
{
"oid": "8645e1e0199b306d1ed1587c01b75580f57fe170"
},
{
"oid": "003d962ebb25229d570367194bdad3d6f3296c60"
},
{
"oid": "a7c2afb0404dd0b478974998bf07e293cd73c08b"
}
],
"pageInfo": {
"hasNextPage": true,
"endCursor": "d17b7ae2bdf9d3826ccea2b583fd850339821be4 4"
}
}
}
}
}
]
}
}
10 | );
11 | if (paginatedResourcePath.length === 0) {
> 12 | throw new MissingPageInfo(responseData);
| ^
13 | }
14 | return paginatedResourcePath;
15 | }
at findPaginatedResourcePath (src/object-helpers.ts:12:11)
at mergeResponses (src/merge-responses.ts:11:41)
at Object.<anonymous> (test/merge-responses.test.ts:197:34)
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
🔥 Backlog