Introspection queries use same OAuth2 tokens (Closes #835)

This commit is contained in:
Gregory Schier committed 2018-03-28 22:32:09 -04:00
1 parent bee9973839
commit 976720c8f2
2 files changed
+10 -3

No files matched your search

+1 -2
View File
@@ -20,6 +20,5 @@
"electron-rebuild": "^1.6.0",
"jest": "^22.1.1",
"lerna": "^2.7.1"
},
"dependencies": {}
}
}
@@ -34,7 +34,15 @@ export async function getAuthHeader (
}
if (authentication.type === AUTH_OAUTH_2) {
const oAuth2Token = await getOAuth2Token(requestId, authentication);
// HACK: GraphQL requests use a child request to fetch the schema with an
// ID of "{{request_id}}.graphql". Here we are removing the .graphql suffix and
// pretending we are fetching a token for the original request. This makes sure
// the same tokens are used for schema fetching. See issue #835 on GitHub.
const tokenId = requestId.match(/\.graphql$/)
? requestId.replace(/\.graphql$/, '')
: requestId;
const oAuth2Token = await getOAuth2Token(tokenId, authentication);
if (oAuth2Token) {
const token = oAuth2Token.accessToken;
return _buildBearerHeader(token, authentication.tokenPrefix);