mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
GitHub - fix regression in getOctokitGraphql() (#249355)
This commit is contained in:
@@ -61,28 +61,24 @@ let _octokitGraphql: Promise<graphql> | undefined;
|
||||
|
||||
export async function getOctokitGraphql(): Promise<graphql> {
|
||||
if (!_octokitGraphql) {
|
||||
try {
|
||||
const session = await authentication.getSession('github', scopes, { silent: true });
|
||||
_octokitGraphql = getSession()
|
||||
.then(async session => {
|
||||
const token = session.accessToken;
|
||||
const agent = getAgent();
|
||||
|
||||
if (!session) {
|
||||
throw new AuthenticationError('No GitHub authentication session available.');
|
||||
}
|
||||
|
||||
const token = session.accessToken;
|
||||
const { graphql } = await import('@octokit/graphql');
|
||||
|
||||
return graphql.defaults({
|
||||
headers: {
|
||||
authorization: `token ${token}`
|
||||
},
|
||||
request: {
|
||||
agent: getAgent()
|
||||
}
|
||||
const { graphql } = await import('@octokit/graphql');
|
||||
return graphql.defaults({
|
||||
headers: {
|
||||
authorization: `token ${token}`,
|
||||
'user-agent': 'GitHub VSCode'
|
||||
},
|
||||
request: { agent }
|
||||
});
|
||||
})
|
||||
.then(null, async err => {
|
||||
_octokitGraphql = undefined;
|
||||
throw err;
|
||||
});
|
||||
} catch (err) {
|
||||
_octokitGraphql = undefined;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
return _octokitGraphql;
|
||||
|
||||
Reference in New Issue
Block a user