diff --git a/lib/platform/github/__fixtures__/graphql/pullrequest-1.json b/lib/platform/github/__fixtures__/graphql/pullrequest-1.json index 501a296e0d5e0251be6f8cbc7ae179621168288e..3c678555efd7fc7821a39ace59cb128d15e52d20 100644 --- a/lib/platform/github/__fixtures__/graphql/pullrequest-1.json +++ b/lib/platform/github/__fixtures__/graphql/pullrequest-1.json @@ -2,6 +2,7 @@ "data": { "repository": { "pullRequests": { + "pageInfo": {}, "nodes": [ { "number": 2433, diff --git a/lib/platform/github/__fixtures__/graphql/pullrequests-closed.json b/lib/platform/github/__fixtures__/graphql/pullrequests-closed.json index 497c086abce6eba81a4d8241875415483dec430b..1f5747f745c65da7660c35a424f890cf44509f98 100644 --- a/lib/platform/github/__fixtures__/graphql/pullrequests-closed.json +++ b/lib/platform/github/__fixtures__/graphql/pullrequests-closed.json @@ -2,6 +2,7 @@ "data": { "repository": { "pullRequests": { + "pageInfo": {}, "nodes": [ { "number": 2500, diff --git a/lib/platform/github/__snapshots__/index.spec.ts.snap b/lib/platform/github/__snapshots__/index.spec.ts.snap index faba36141056d6bde17d460fc42d0ea2275d66b5..546b1ed1204c758228e07896b7be34b3e4dde1c9 100644 --- a/lib/platform/github/__snapshots__/index.spec.ts.snap +++ b/lib/platform/github/__snapshots__/index.spec.ts.snap @@ -441,6 +441,10 @@ Array [ "state": null, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -449,7 +453,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "513", + "content-length": "604", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -549,6 +553,10 @@ Array [ "state": null, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -557,7 +565,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "513", + "content-length": "604", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -657,6 +665,10 @@ Array [ "state": null, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -665,7 +677,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "513", + "content-length": "604", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -754,6 +766,10 @@ Array [ "state": null, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -762,7 +778,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "513", + "content-length": "604", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -848,6 +864,10 @@ Array [ "state": null, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -856,7 +876,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "513", + "content-length": "604", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -942,6 +962,10 @@ Array [ "state": null, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -950,7 +974,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "513", + "content-length": "604", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -1047,6 +1071,10 @@ Array [ "state": null, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -1055,7 +1083,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "513", + "content-length": "604", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -2037,6 +2065,10 @@ Array [ }, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -2045,7 +2077,7 @@ Array [ "accept": "application/vnd.github.merge-info-preview+json, application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "1413", + "content-length": "1504", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -2080,6 +2112,10 @@ Array [ "state": null, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -2088,7 +2124,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "513", + "content-length": "604", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -2287,6 +2323,10 @@ Array [ }, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -2295,7 +2335,7 @@ Array [ "accept": "application/vnd.github.merge-info-preview+json, application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "1413", + "content-length": "1504", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -2330,6 +2370,10 @@ Array [ "state": null, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -2338,7 +2382,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "513", + "content-length": "604", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -3145,6 +3189,10 @@ Array [ }, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -3153,7 +3201,7 @@ Array [ "accept": "application/vnd.github.merge-info-preview+json, application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "1413", + "content-length": "1504", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -3188,6 +3236,10 @@ Array [ "state": null, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -3196,7 +3248,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "513", + "content-length": "604", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -3329,6 +3381,10 @@ Array [ }, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -3337,7 +3393,7 @@ Array [ "accept": "application/vnd.github.merge-info-preview+json, application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "1413", + "content-length": "1504", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -3467,6 +3523,10 @@ Array [ }, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -3475,7 +3535,7 @@ Array [ "accept": "application/vnd.github.merge-info-preview+json, application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "1413", + "content-length": "1504", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -3510,6 +3570,10 @@ Array [ "state": null, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -3518,7 +3582,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "513", + "content-length": "604", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -3664,6 +3728,10 @@ Array [ }, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -3672,7 +3740,7 @@ Array [ "accept": "application/vnd.github.merge-info-preview+json, application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "1413", + "content-length": "1504", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -3707,6 +3775,10 @@ Array [ "state": null, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -3715,7 +3787,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "513", + "content-length": "604", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -3859,6 +3931,10 @@ Array [ }, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -3867,7 +3943,7 @@ Array [ "accept": "application/vnd.github.merge-info-preview+json, application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "1413", + "content-length": "1504", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -3902,6 +3978,10 @@ Array [ "state": null, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -3910,7 +3990,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "513", + "content-length": "604", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -4038,6 +4118,10 @@ Array [ }, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -4046,7 +4130,7 @@ Array [ "accept": "application/vnd.github.merge-info-preview+json, application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "1413", + "content-length": "1504", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -4081,6 +4165,10 @@ Array [ "state": null, "title": null, }, + "pageInfo": Object { + "endCursor": null, + "hasNextPage": null, + }, }, }, }, @@ -4089,7 +4177,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "513", + "content-length": "604", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", diff --git a/lib/platform/github/index.spec.ts b/lib/platform/github/index.spec.ts index 9e706fd5a7038587cc7d801c1e8abca69bd91c29..7b6c125d4fb2d1aca7873db17d038ffc29d50a30 100644 --- a/lib/platform/github/index.spec.ts +++ b/lib/platform/github/index.spec.ts @@ -460,8 +460,10 @@ describe('platform/github', () => { initRepoMock(scope, 'some/repo'); scope .post('/graphql') - .twice() - .reply(200, {}) + .twice() // getOpenPrs() and getClosedPrs() + .reply(200, { + data: { repository: { pullRequests: { pageInfo: {} } } }, + }) .get('/repos/some/repo/pulls?per_page=100&state=all') .reply(200, [ { @@ -500,8 +502,10 @@ describe('platform/github', () => { forkInitRepoMock(scope, 'some/repo', 'forked/repo'); scope .post('/graphql') - .twice() - .reply(200, {}) + .twice() // getOpenPrs() and getClosedPrs() + .reply(200, { + data: { repository: { pullRequests: { pageInfo: {} } } }, + }) .get('/repos/some/repo/pulls?per_page=100&state=all') .reply(200, [ { @@ -1359,7 +1363,9 @@ describe('platform/github', () => { initRepoMock(scope, 'some/repo'); scope .post('/graphql') - .reply(200, {}) + .reply(200, { + data: { repository: { pullRequests: { pageInfo: {} } } }, + }) .get('/repos/some/repo/issues/42/comments?per_page=100') .reply(200, []) .post('/repos/some/repo/issues/42/comments') @@ -1398,7 +1404,9 @@ describe('platform/github', () => { initRepoMock(scope, 'some/repo'); scope .post('/graphql') - .reply(200, {}) + .reply(200, { + data: { repository: { pullRequests: { pageInfo: {} } } }, + }) .get('/repos/some/repo/issues/42/comments?per_page=100') .reply(200, [{ id: 1234, body: '### some-subject\n\nblablabla' }]) .patch('/repos/some/repo/issues/comments/1234') @@ -1418,7 +1426,9 @@ describe('platform/github', () => { initRepoMock(scope, 'some/repo'); scope .post('/graphql') - .reply(200, {}) + .reply(200, { + data: { repository: { pullRequests: { pageInfo: {} } } }, + }) .get('/repos/some/repo/issues/42/comments?per_page=100') .reply(200, [{ id: 1234, body: '### some-subject\n\nsome\ncontent' }]); await github.initRepo({ @@ -1436,7 +1446,9 @@ describe('platform/github', () => { initRepoMock(scope, 'some/repo'); scope .post('/graphql') - .reply(200, {}) + .reply(200, { + data: { repository: { pullRequests: { pageInfo: {} } } }, + }) .get('/repos/some/repo/issues/42/comments?per_page=100') .reply(200, [{ id: 1234, body: '!merge' }]); await github.initRepo({ @@ -1456,7 +1468,9 @@ describe('platform/github', () => { initRepoMock(scope, 'some/repo'); scope .post('/graphql') - .reply(200, {}) + .reply(200, { + data: { repository: { pullRequests: { pageInfo: {} } } }, + }) .get('/repos/some/repo/issues/42/comments?per_page=100') .reply(200, [{ id: 1234, body: '### some-subject\n\nblablabla' }]) .delete('/repos/some/repo/issues/comments/1234') @@ -1470,7 +1484,9 @@ describe('platform/github', () => { initRepoMock(scope, 'some/repo'); scope .post('/graphql') - .reply(200, {}) + .reply(200, { + data: { repository: { pullRequests: { pageInfo: {} } } }, + }) .get('/repos/some/repo/issues/42/comments?per_page=100') .reply(200, [{ id: 1234, body: 'some-content' }]) .delete('/repos/some/repo/issues/comments/1234') diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index ea9ef1d76c20b378fc7d11ee7b83917dfea94209..cfe193aa7c4fb89ed92dac1935ecf7d547277c01 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -432,7 +432,11 @@ async function getClosedPrs(): Promise<PrList> { query = ` query { repository(owner: "${config.repositoryOwner}", name: "${config.repositoryName}") { - pullRequests(states: [CLOSED, MERGED], first: 100, orderBy: {field: UPDATED_AT, direction: DESC}) { + pullRequests(states: [CLOSED, MERGED], orderBy: {field: UPDATED_AT, direction: DESC}) { + pageInfo { + endCursor + hasNextPage + } nodes { number state @@ -451,10 +455,7 @@ async function getClosedPrs(): Promise<PrList> { `; const nodes = await githubApi.queryRepoField<GhGraphQlPr>( query, - 'pullRequests', - { - paginate: false, - } + 'pullRequests' ); const prNumbers: number[] = []; // istanbul ignore if @@ -495,7 +496,11 @@ async function getOpenPrs(): Promise<PrList> { query = ` query { repository(owner: "${config.repositoryOwner}", name: "${config.repositoryName}") { - pullRequests(states: [OPEN], first: 100, orderBy: {field: UPDATED_AT, direction: DESC}) { + pullRequests(states: [OPEN], orderBy: {field: UPDATED_AT, direction: DESC}) { + pageInfo { + endCursor + hasNextPage + } nodes { number headRefName @@ -549,7 +554,6 @@ async function getOpenPrs(): Promise<PrList> { query, 'pullRequests', { - paginate: false, acceptHeader: 'application/vnd.github.merge-info-preview+json', } );