mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-03 15:01:57 +01:00
GitHub - refactor branch protection (#181880)
* GitHub - rewrite to use GraphQL instead of REST * Add paging
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
import { AuthenticationSession, authentication, window } from 'vscode';
|
||||
import { Agent, globalAgent } from 'https';
|
||||
import { graphql } from '@octokit/graphql/dist-types/types';
|
||||
import { Octokit } from '@octokit/rest';
|
||||
import { httpsOverHttp } from 'tunnel';
|
||||
import { URL } from 'url';
|
||||
@@ -53,3 +54,29 @@ export function getOctokit(): Promise<Octokit> {
|
||||
|
||||
return _octokit;
|
||||
}
|
||||
|
||||
let _octokitGraphql: Promise<graphql> | undefined;
|
||||
|
||||
export function getOctokitGraphql(): Promise<graphql> {
|
||||
if (!_octokitGraphql) {
|
||||
_octokitGraphql = getSession()
|
||||
.then(async session => {
|
||||
const token = session.accessToken;
|
||||
const { graphql } = await import('@octokit/graphql');
|
||||
|
||||
return graphql.defaults({
|
||||
headers: {
|
||||
authorization: `token ${token}`
|
||||
},
|
||||
request: {
|
||||
agent: getAgent()
|
||||
}
|
||||
});
|
||||
}).then(null, async err => {
|
||||
_octokitGraphql = undefined;
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
return _octokitGraphql;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user