GitHub - fix regression in getOctokitGraphql() (#249355)

This commit is contained in:
Ladislau Szomoru
2025-05-20 14:43:20 +00:00
committed by GitHub
parent 70107d1562
commit 3381c264e1

View File

@@ -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;