slicknode-apollo-link
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -264,13 +264,11 @@ "use strict"; | ||
if (!this.loadHeadersPromise) { | ||
const accessToken = this.options.accessToken || this.getAccessToken(); | ||
if (accessToken) { | ||
this.debug('Using valid access token'); | ||
return Promise.resolve({ | ||
Authorization: `Bearer ${accessToken}`, | ||
}); | ||
} | ||
this.loadHeadersPromise = new Promise((resolve, reject) => { | ||
const accessToken = this.options.accessToken || this.getAccessToken(); | ||
const refreshToken = this.getRefreshToken(); | ||
if (accessToken) { | ||
this.debug('Using valid access token'); | ||
resolve({ | ||
Authorization: `Bearer ${accessToken}`, | ||
}); | ||
this.loadHeadersPromise = null; | ||
return; | ||
} | ||
// We have no token, try to get it from API via next link | ||
@@ -294,2 +292,3 @@ if (!accessToken && refreshToken) { | ||
next: (result) => { | ||
this.loadHeadersPromise = null; | ||
if (result.data && result.data.refreshAuthToken) { | ||
@@ -304,3 +303,2 @@ if (!this.validateAndSetAuthTokenSet(result.data.refreshAuthToken)) { | ||
} | ||
this.loadHeadersPromise = null; | ||
resolve(this.hasAccessToken() ? { | ||
@@ -318,2 +316,5 @@ Authorization: `Bearer ${this.getAccessToken()}`, | ||
} | ||
else { | ||
this.debug('Wait for token refresh in other transaction'); | ||
} | ||
return this.loadHeadersPromise; | ||
@@ -320,0 +321,0 @@ } |
{ | ||
"name": "slicknode-apollo-link", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"repository": "https://github.com/slicknode/slicknode-apollo-link.git", | ||
@@ -5,0 +5,0 @@ "author": "Ivo Meißner <info@overtronic.com>", |
Sorry, the diff of this file is not supported yet
99527
1449