From a69e0317c9d60c47c3f8952422d1b97fc74e0bcd Mon Sep 17 00:00:00 2001 From: glo82145 Date: Thu, 17 Aug 2023 18:30:22 +0530 Subject: [PATCH 01/21] PWA-3154::Dont Merge --- packages/peregrine/lib/Apollo/links/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/peregrine/lib/Apollo/links/index.js b/packages/peregrine/lib/Apollo/links/index.js index 1a6bf48b1e..c1447583c8 100644 --- a/packages/peregrine/lib/Apollo/links/index.js +++ b/packages/peregrine/lib/Apollo/links/index.js @@ -51,6 +51,7 @@ const getLinks = apiBase => { // preserve this array order, it's important // as the terminating link, `httpLink` must be last + const links = new Map() .set('MUTATION_QUEUE', mutationQueueLink) .set('RETRY', retryLink) From 1ab61aaf6ff2daaddcca7f60b172ab9328df5caa Mon Sep 17 00:00:00 2001 From: glo82145 Date: Thu, 17 Aug 2023 18:58:25 +0530 Subject: [PATCH 02/21] PWA-3154::Dont Merge --- packages/peregrine/lib/Apollo/links/gqlCacheLink.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/peregrine/lib/Apollo/links/gqlCacheLink.js b/packages/peregrine/lib/Apollo/links/gqlCacheLink.js index 48710234a6..697b144912 100644 --- a/packages/peregrine/lib/Apollo/links/gqlCacheLink.js +++ b/packages/peregrine/lib/Apollo/links/gqlCacheLink.js @@ -42,10 +42,10 @@ export class MagentoGQLCacheLink extends ApolloLink { const updateCacheId = data => { const context = operation.getContext(); const { response } = context; - + const responseCacheId = response.headers.get(CACHE_ID_HEADER); - if (responseCacheId) { + if (responseCacheId && response.headers.get('X-Cache') == 'HIT, HIT') { this.setCacheId(responseCacheId); } From be27c3573ca6c42de67ecfcd8bfae7f35963df2b Mon Sep 17 00:00:00 2001 From: glo82145 Date: Thu, 17 Aug 2023 19:23:11 +0530 Subject: [PATCH 03/21] PWA-3154::Dont Merge --- packages/peregrine/lib/Apollo/links/index.js | 27 ++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/packages/peregrine/lib/Apollo/links/index.js b/packages/peregrine/lib/Apollo/links/index.js index c1447583c8..a8a7ad6995 100644 --- a/packages/peregrine/lib/Apollo/links/index.js +++ b/packages/peregrine/lib/Apollo/links/index.js @@ -51,16 +51,23 @@ const getLinks = apiBase => { // preserve this array order, it's important // as the terminating link, `httpLink` must be last - - const links = new Map() - .set('MUTATION_QUEUE', mutationQueueLink) - .set('RETRY', retryLink) - .set('AUTH', authLink) - .set('GQL_CACHE', gqlCacheLink) - .set('STORE', storeLink) - .set('ERROR', errorLink) - .set('HTTP', httpLink); - + if(gqlCacheLink) { + const links = new Map() + .set('MUTATION_QUEUE', mutationQueueLink) + .set('RETRY', retryLink) + .set('GQL_CACHE', gqlCacheLink) + .set('STORE', storeLink) + .set('ERROR', errorLink) + .set('HTTP', httpLink); + } else { + const links = new Map() + .set('MUTATION_QUEUE', mutationQueueLink) + .set('RETRY', retryLink) + .set('AUTH', authLink) + .set('STORE', storeLink) + .set('ERROR', errorLink) + .set('HTTP', httpLink); + } return links; }; From 2975d33be5ce7936d48c65b081096e6485736bb8 Mon Sep 17 00:00:00 2001 From: glo82145 Date: Fri, 18 Aug 2023 14:47:10 +0530 Subject: [PATCH 04/21] PWA-3154::Dont Merge --- packages/peregrine/lib/Apollo/links/index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/peregrine/lib/Apollo/links/index.js b/packages/peregrine/lib/Apollo/links/index.js index a8a7ad6995..b119e230dd 100644 --- a/packages/peregrine/lib/Apollo/links/index.js +++ b/packages/peregrine/lib/Apollo/links/index.js @@ -51,7 +51,7 @@ const getLinks = apiBase => { // preserve this array order, it's important // as the terminating link, `httpLink` must be last - if(gqlCacheLink) { + if (gqlCacheLink) { const links = new Map() .set('MUTATION_QUEUE', mutationQueueLink) .set('RETRY', retryLink) @@ -59,7 +59,9 @@ const getLinks = apiBase => { .set('STORE', storeLink) .set('ERROR', errorLink) .set('HTTP', httpLink); - } else { + + return links; + } else { console.log('fffds'); const links = new Map() .set('MUTATION_QUEUE', mutationQueueLink) .set('RETRY', retryLink) @@ -67,8 +69,9 @@ const getLinks = apiBase => { .set('STORE', storeLink) .set('ERROR', errorLink) .set('HTTP', httpLink); + return links; } - return links; + }; export default getLinks; From 669e9ce267e3e654886986b0b1c78b1629d96421 Mon Sep 17 00:00:00 2001 From: glo82145 Date: Fri, 18 Aug 2023 17:09:23 +0530 Subject: [PATCH 05/21] PWA-3154::Dont Merge --- packages/peregrine/lib/Apollo/links/gqlCacheLink.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/peregrine/lib/Apollo/links/gqlCacheLink.js b/packages/peregrine/lib/Apollo/links/gqlCacheLink.js index 697b144912..3bb442d532 100644 --- a/packages/peregrine/lib/Apollo/links/gqlCacheLink.js +++ b/packages/peregrine/lib/Apollo/links/gqlCacheLink.js @@ -45,7 +45,7 @@ export class MagentoGQLCacheLink extends ApolloLink { const responseCacheId = response.headers.get(CACHE_ID_HEADER); - if (responseCacheId && response.headers.get('X-Cache') == 'HIT, HIT') { + if (responseCacheId && response.headers.get('X-Cache') != 'MISS, MISS') { this.setCacheId(responseCacheId); } From 666bcac20e7ae5f86c418125f5e2a5265093d775 Mon Sep 17 00:00:00 2001 From: glo82145 Date: Fri, 18 Aug 2023 17:40:30 +0530 Subject: [PATCH 06/21] PWA-3154::Dont Merge --- packages/peregrine/lib/Apollo/links/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/peregrine/lib/Apollo/links/index.js b/packages/peregrine/lib/Apollo/links/index.js index b119e230dd..22e0d0e242 100644 --- a/packages/peregrine/lib/Apollo/links/index.js +++ b/packages/peregrine/lib/Apollo/links/index.js @@ -51,21 +51,21 @@ const getLinks = apiBase => { // preserve this array order, it's important // as the terminating link, `httpLink` must be last - if (gqlCacheLink) { + if ( !gqlCacheLink ) { const links = new Map() .set('MUTATION_QUEUE', mutationQueueLink) .set('RETRY', retryLink) - .set('GQL_CACHE', gqlCacheLink) + .set('AUTH', authLink) .set('STORE', storeLink) .set('ERROR', errorLink) .set('HTTP', httpLink); return links; - } else { console.log('fffds'); + } else { const links = new Map() .set('MUTATION_QUEUE', mutationQueueLink) .set('RETRY', retryLink) - .set('AUTH', authLink) + .set('GQL_CACHE', gqlCacheLink) .set('STORE', storeLink) .set('ERROR', errorLink) .set('HTTP', httpLink); From 94cb7de798c0736a02f0785bb414884c561b794c Mon Sep 17 00:00:00 2001 From: glo82145 Date: Mon, 21 Aug 2023 13:43:17 +0530 Subject: [PATCH 07/21] PWA-3154::Dont Merge --- packages/peregrine/lib/Apollo/links/authLink.js | 6 ++++-- packages/peregrine/lib/Apollo/links/gqlCacheLink.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/peregrine/lib/Apollo/links/authLink.js b/packages/peregrine/lib/Apollo/links/authLink.js index bb6be29d93..af3613510e 100644 --- a/packages/peregrine/lib/Apollo/links/authLink.js +++ b/packages/peregrine/lib/Apollo/links/authLink.js @@ -2,9 +2,11 @@ import { setContext } from '@apollo/client/link/context'; import { BrowserPersistence } from '@magento/peregrine/lib/util'; const storage = new BrowserPersistence(); - +const LOCAL_STORAGE_KEY = 'magento_cache_id'; export default function createAuthLink() { - return setContext((_, { headers }) => { + return setContext((_, { headers }) => { + const dd = storage.getItem(LOCAL_STORAGE_KEY); + console.log(dd + 'sad'); // get the authentication token from local storage if it exists. const token = storage.getItem('signin_token'); diff --git a/packages/peregrine/lib/Apollo/links/gqlCacheLink.js b/packages/peregrine/lib/Apollo/links/gqlCacheLink.js index 3bb442d532..a31832d25f 100644 --- a/packages/peregrine/lib/Apollo/links/gqlCacheLink.js +++ b/packages/peregrine/lib/Apollo/links/gqlCacheLink.js @@ -23,7 +23,7 @@ export class MagentoGQLCacheLink extends ApolloLink { storage.setItem(LOCAL_STORAGE_KEY, value); } - request(operation, forward) { + request(operation, forward) { console.log(this.#cacheId); // Attach the cache header to each outgoing request. operation.setContext(previousContext => { const { headers } = previousContext; @@ -42,7 +42,7 @@ export class MagentoGQLCacheLink extends ApolloLink { const updateCacheId = data => { const context = operation.getContext(); const { response } = context; - + const responseCacheId = response.headers.get(CACHE_ID_HEADER); if (responseCacheId && response.headers.get('X-Cache') != 'MISS, MISS') { From ab4290bd200d344cb08596a814ada8993d258c20 Mon Sep 17 00:00:00 2001 From: glo82145 Date: Mon, 21 Aug 2023 14:08:04 +0530 Subject: [PATCH 08/21] PWA-3154::Dont Merge --- packages/peregrine/lib/Apollo/links/authLink.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/peregrine/lib/Apollo/links/authLink.js b/packages/peregrine/lib/Apollo/links/authLink.js index af3613510e..adb5ed75f2 100644 --- a/packages/peregrine/lib/Apollo/links/authLink.js +++ b/packages/peregrine/lib/Apollo/links/authLink.js @@ -6,9 +6,10 @@ const LOCAL_STORAGE_KEY = 'magento_cache_id'; export default function createAuthLink() { return setContext((_, { headers }) => { const dd = storage.getItem(LOCAL_STORAGE_KEY); - console.log(dd + 'sad'); + const token = ''; + if( dd != null) { // get the authentication token from local storage if it exists. - const token = storage.getItem('signin_token'); + token = storage.getItem('signin_token'); } // return the headers to the context so httpLink can read them return { From e440f4aea43d499576b3a882f4c2bc9a7c01bb4a Mon Sep 17 00:00:00 2001 From: glo82145 Date: Mon, 21 Aug 2023 15:16:22 +0530 Subject: [PATCH 09/21] PWA-3154::Dont Merge --- packages/peregrine/lib/Apollo/links/index.js | 31 +++++++------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/packages/peregrine/lib/Apollo/links/index.js b/packages/peregrine/lib/Apollo/links/index.js index 22e0d0e242..1a6bf48b1e 100644 --- a/packages/peregrine/lib/Apollo/links/index.js +++ b/packages/peregrine/lib/Apollo/links/index.js @@ -51,27 +51,16 @@ const getLinks = apiBase => { // preserve this array order, it's important // as the terminating link, `httpLink` must be last - if ( !gqlCacheLink ) { - const links = new Map() - .set('MUTATION_QUEUE', mutationQueueLink) - .set('RETRY', retryLink) - .set('AUTH', authLink) - .set('STORE', storeLink) - .set('ERROR', errorLink) - .set('HTTP', httpLink); - - return links; - } else { - const links = new Map() - .set('MUTATION_QUEUE', mutationQueueLink) - .set('RETRY', retryLink) - .set('GQL_CACHE', gqlCacheLink) - .set('STORE', storeLink) - .set('ERROR', errorLink) - .set('HTTP', httpLink); - return links; - } - + const links = new Map() + .set('MUTATION_QUEUE', mutationQueueLink) + .set('RETRY', retryLink) + .set('AUTH', authLink) + .set('GQL_CACHE', gqlCacheLink) + .set('STORE', storeLink) + .set('ERROR', errorLink) + .set('HTTP', httpLink); + + return links; }; export default getLinks; From 47c604e8c8185733bce10ac82763488f6cdf5eae Mon Sep 17 00:00:00 2001 From: glo82145 Date: Mon, 21 Aug 2023 20:27:53 +0530 Subject: [PATCH 10/21] PWA-3154::Dont Merge --- .../peregrine/lib/Apollo/links/authLink.js | 58 ++++++++++++++----- .../lib/Apollo/links/gqlCacheLink.js | 4 +- 2 files changed, 44 insertions(+), 18 deletions(-) diff --git a/packages/peregrine/lib/Apollo/links/authLink.js b/packages/peregrine/lib/Apollo/links/authLink.js index adb5ed75f2..d9e99986ea 100644 --- a/packages/peregrine/lib/Apollo/links/authLink.js +++ b/packages/peregrine/lib/Apollo/links/authLink.js @@ -1,22 +1,48 @@ -import { setContext } from '@apollo/client/link/context'; +import { ApolloLink } from '@apollo/client'; import { BrowserPersistence } from '@magento/peregrine/lib/util'; const storage = new BrowserPersistence(); -const LOCAL_STORAGE_KEY = 'magento_cache_id'; -export default function createAuthLink() { - return setContext((_, { headers }) => { - const dd = storage.getItem(LOCAL_STORAGE_KEY); - const token = ''; - if( dd != null) { - // get the authentication token from local storage if it exists. - token = storage.getItem('signin_token'); } - - // return the headers to the context so httpLink can read them - return { - headers: { - ...headers, - authorization: token ? `Bearer ${token}` : '' + +export class MagentoGQLCacheLink extends ApolloLink { + // The token get reinstantiated on refresh. + // If we have an existing token value from a previous browsing session, use it. + token = storage.getItem('signin_token') || null; + + // reset token + settoken(value) { + this.token = value; + } + + request(operation, forward) { + operation.setContext(previousContext => { + const { headers } = previousContext; + // return the headers to the context so httpLink can read them + return { + headers: { + ...headers, + authorization: this.token ? `Bearer ${this.token}` : '' + } + }; + }); + + // Update the token from each response. + const updateToken = data => { + const context = operation.getContext(); + const { response } = context; + + if (response.headers.get('Pragma') == 'no-cache') { + this.settoken(null); } + + // Purposefully don't modify the result, + // no other link needs to know about the cache id. + return data; }; - }); + + return forward(operation).map(updateToken); + } +} + +export default function createAuthLink() { + return new MagentoGQLCacheLink(); } diff --git a/packages/peregrine/lib/Apollo/links/gqlCacheLink.js b/packages/peregrine/lib/Apollo/links/gqlCacheLink.js index a31832d25f..48710234a6 100644 --- a/packages/peregrine/lib/Apollo/links/gqlCacheLink.js +++ b/packages/peregrine/lib/Apollo/links/gqlCacheLink.js @@ -23,7 +23,7 @@ export class MagentoGQLCacheLink extends ApolloLink { storage.setItem(LOCAL_STORAGE_KEY, value); } - request(operation, forward) { console.log(this.#cacheId); + request(operation, forward) { // Attach the cache header to each outgoing request. operation.setContext(previousContext => { const { headers } = previousContext; @@ -45,7 +45,7 @@ export class MagentoGQLCacheLink extends ApolloLink { const responseCacheId = response.headers.get(CACHE_ID_HEADER); - if (responseCacheId && response.headers.get('X-Cache') != 'MISS, MISS') { + if (responseCacheId) { this.setCacheId(responseCacheId); } From 766d6d498ed131f9e9be707be6006974edd9753f Mon Sep 17 00:00:00 2001 From: glo82145 Date: Mon, 21 Aug 2023 20:32:09 +0530 Subject: [PATCH 11/21] PWA-3154::Dont Merge --- packages/peregrine/lib/Apollo/links/authLink.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/peregrine/lib/Apollo/links/authLink.js b/packages/peregrine/lib/Apollo/links/authLink.js index d9e99986ea..0ab3c8df38 100644 --- a/packages/peregrine/lib/Apollo/links/authLink.js +++ b/packages/peregrine/lib/Apollo/links/authLink.js @@ -30,7 +30,7 @@ export class MagentoGQLCacheLink extends ApolloLink { const context = operation.getContext(); const { response } = context; - if (response.headers.get('Pragma') == 'no-cache') { + if (response.headers.get('Pragma') == 'cache') { this.settoken(null); } From 3f12bd14c6acc7800b6f8ac3c4bdbbf9153c5a14 Mon Sep 17 00:00:00 2001 From: glo82145 Date: Mon, 21 Aug 2023 21:00:38 +0530 Subject: [PATCH 12/21] PWA-3154::Dont Merge --- packages/peregrine/lib/Apollo/links/authLink.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/peregrine/lib/Apollo/links/authLink.js b/packages/peregrine/lib/Apollo/links/authLink.js index 0ab3c8df38..e71219c94d 100644 --- a/packages/peregrine/lib/Apollo/links/authLink.js +++ b/packages/peregrine/lib/Apollo/links/authLink.js @@ -9,7 +9,7 @@ export class MagentoGQLCacheLink extends ApolloLink { token = storage.getItem('signin_token') || null; // reset token - settoken(value) { + settoken(value) { this.token = value; } @@ -31,7 +31,7 @@ export class MagentoGQLCacheLink extends ApolloLink { const { response } = context; if (response.headers.get('Pragma') == 'cache') { - this.settoken(null); + this.settoken(''); } // Purposefully don't modify the result, From e50762db00770ccfc71bdb3ad50e17beb3f2e6e6 Mon Sep 17 00:00:00 2001 From: glo82145 Date: Mon, 21 Aug 2023 21:23:09 +0530 Subject: [PATCH 13/21] PWA-3154::Dont Merge --- packages/peregrine/lib/Apollo/links/authLink.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/peregrine/lib/Apollo/links/authLink.js b/packages/peregrine/lib/Apollo/links/authLink.js index e71219c94d..9c95c4ea12 100644 --- a/packages/peregrine/lib/Apollo/links/authLink.js +++ b/packages/peregrine/lib/Apollo/links/authLink.js @@ -2,15 +2,15 @@ import { ApolloLink } from '@apollo/client'; import { BrowserPersistence } from '@magento/peregrine/lib/util'; const storage = new BrowserPersistence(); - +const token = storage.getItem('signin_token') || null; export class MagentoGQLCacheLink extends ApolloLink { // The token get reinstantiated on refresh. // If we have an existing token value from a previous browsing session, use it. - token = storage.getItem('signin_token') || null; + // reset token settoken(value) { - this.token = value; + token = value; } request(operation, forward) { @@ -20,18 +20,18 @@ export class MagentoGQLCacheLink extends ApolloLink { return { headers: { ...headers, - authorization: this.token ? `Bearer ${this.token}` : '' + authorization: token ? `Bearer ${token}` : '' } }; }); // Update the token from each response. - const updateToken = data => { + const updateToken = data => { console.log(token); const context = operation.getContext(); const { response } = context; - if (response.headers.get('Pragma') == 'cache') { - this.settoken(''); + if (response.headers.get('Pragma') != 'no-cache') { + this.settoken(null); } // Purposefully don't modify the result, From c0106f1ce14ef08b2e62df2d72d25d096acf45e1 Mon Sep 17 00:00:00 2001 From: glo82145 Date: Mon, 4 Sep 2023 18:22:18 +0530 Subject: [PATCH 14/21] PWA-3154 --- .../peregrine/lib/Apollo/links/authLink.js | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/peregrine/lib/Apollo/links/authLink.js b/packages/peregrine/lib/Apollo/links/authLink.js index 9c95c4ea12..29c6a810e7 100644 --- a/packages/peregrine/lib/Apollo/links/authLink.js +++ b/packages/peregrine/lib/Apollo/links/authLink.js @@ -2,21 +2,17 @@ import { ApolloLink } from '@apollo/client'; import { BrowserPersistence } from '@magento/peregrine/lib/util'; const storage = new BrowserPersistence(); -const token = storage.getItem('signin_token') || null; +var token = storage.getItem('signin_token') || null; export class MagentoGQLCacheLink extends ApolloLink { // The token get reinstantiated on refresh. // If we have an existing token value from a previous browsing session, use it. - - - // reset token - settoken(value) { - token = value; - } - + request(operation, forward) { operation.setContext(previousContext => { const { headers } = previousContext; // return the headers to the context so httpLink can read them + // console.log(token); + return { headers: { ...headers, @@ -26,14 +22,14 @@ export class MagentoGQLCacheLink extends ApolloLink { }); // Update the token from each response. - const updateToken = data => { console.log(token); + const updateToken = data => { const context = operation.getContext(); const { response } = context; - if (response.headers.get('Pragma') != 'no-cache') { - this.settoken(null); + + if (response.headers.get('Pragma') == 'cache') { + token = null; } - // Purposefully don't modify the result, // no other link needs to know about the cache id. return data; @@ -45,4 +41,4 @@ export class MagentoGQLCacheLink extends ApolloLink { export default function createAuthLink() { return new MagentoGQLCacheLink(); -} +} \ No newline at end of file From f719c6aa52a323be513dd59131f9423fb0c159e0 Mon Sep 17 00:00:00 2001 From: glo82145 Date: Wed, 6 Sep 2023 13:42:39 +0530 Subject: [PATCH 15/21] PWA-3154 --- packages/peregrine/lib/Apollo/links/authLink.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/peregrine/lib/Apollo/links/authLink.js b/packages/peregrine/lib/Apollo/links/authLink.js index 29c6a810e7..580d021412 100644 --- a/packages/peregrine/lib/Apollo/links/authLink.js +++ b/packages/peregrine/lib/Apollo/links/authLink.js @@ -27,9 +27,10 @@ export class MagentoGQLCacheLink extends ApolloLink { const { response } = context; - if (response.headers.get('Pragma') == 'cache') { + if (response.headers.get('Pragma') == 'cache') { console.log('cache'); token = null; } + console.log(token); // Purposefully don't modify the result, // no other link needs to know about the cache id. return data; From bb747cff486bacbeb7aa5201d2c8e684169d6ddf Mon Sep 17 00:00:00 2001 From: glo82145 Date: Wed, 6 Sep 2023 14:55:23 +0530 Subject: [PATCH 16/21] PWA-3154 --- packages/peregrine/lib/Apollo/links/authLink.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/peregrine/lib/Apollo/links/authLink.js b/packages/peregrine/lib/Apollo/links/authLink.js index 580d021412..c0b73e97e2 100644 --- a/packages/peregrine/lib/Apollo/links/authLink.js +++ b/packages/peregrine/lib/Apollo/links/authLink.js @@ -16,7 +16,8 @@ export class MagentoGQLCacheLink extends ApolloLink { return { headers: { ...headers, - authorization: token ? `Bearer ${token}` : '' + authorization: token ? `Bearer ${token}` : '', + TTd: token } }; }); From 4c7361f99d36dece0be725304cd98c5b4b17a01c Mon Sep 17 00:00:00 2001 From: glo82145 Date: Wed, 6 Sep 2023 17:29:05 +0530 Subject: [PATCH 17/21] PWA-3154 --- packages/peregrine/lib/Apollo/links/authLink.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/peregrine/lib/Apollo/links/authLink.js b/packages/peregrine/lib/Apollo/links/authLink.js index c0b73e97e2..02ccc63945 100644 --- a/packages/peregrine/lib/Apollo/links/authLink.js +++ b/packages/peregrine/lib/Apollo/links/authLink.js @@ -3,6 +3,7 @@ import { BrowserPersistence } from '@magento/peregrine/lib/util'; const storage = new BrowserPersistence(); var token = storage.getItem('signin_token') || null; +var gg = 'dd'; export class MagentoGQLCacheLink extends ApolloLink { // The token get reinstantiated on refresh. // If we have an existing token value from a previous browsing session, use it. @@ -17,7 +18,7 @@ export class MagentoGQLCacheLink extends ApolloLink { headers: { ...headers, authorization: token ? `Bearer ${token}` : '', - TTd: token + TTd: gg } }; }); @@ -30,7 +31,9 @@ export class MagentoGQLCacheLink extends ApolloLink { if (response.headers.get('Pragma') == 'cache') { console.log('cache'); token = null; + gg = 'dff'; } + gg = response.headers.get('Pragma'); console.log(token); // Purposefully don't modify the result, // no other link needs to know about the cache id. From c482832c7cd599b747a0120be3ba4f3366c3ada0 Mon Sep 17 00:00:00 2001 From: glo82145 Date: Wed, 6 Sep 2023 18:26:36 +0530 Subject: [PATCH 18/21] PWA-3154 --- packages/peregrine/lib/Apollo/links/authLink.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/peregrine/lib/Apollo/links/authLink.js b/packages/peregrine/lib/Apollo/links/authLink.js index 02ccc63945..a859b9dcc7 100644 --- a/packages/peregrine/lib/Apollo/links/authLink.js +++ b/packages/peregrine/lib/Apollo/links/authLink.js @@ -33,7 +33,7 @@ export class MagentoGQLCacheLink extends ApolloLink { token = null; gg = 'dff'; } - gg = response.headers.get('Pragma'); + gg = response.headers.get('X-Cache'); console.log(token); // Purposefully don't modify the result, // no other link needs to know about the cache id. From d086cf8c7d7f0db3ee3fdf9c456794ecf20687d0 Mon Sep 17 00:00:00 2001 From: glo82145 Date: Thu, 7 Sep 2023 13:12:26 +0530 Subject: [PATCH 19/21] PWA-3154 --- packages/peregrine/lib/Apollo/links/authLink.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/peregrine/lib/Apollo/links/authLink.js b/packages/peregrine/lib/Apollo/links/authLink.js index a859b9dcc7..8dd0c2693c 100644 --- a/packages/peregrine/lib/Apollo/links/authLink.js +++ b/packages/peregrine/lib/Apollo/links/authLink.js @@ -29,7 +29,7 @@ export class MagentoGQLCacheLink extends ApolloLink { const { response } = context; - if (response.headers.get('Pragma') == 'cache') { console.log('cache'); + if (response.headers.get('X-Cache') == 'HIT, HIT') { console.log('cache'); token = null; gg = 'dff'; } From 9ec785f5d5dea56085f86dcbd0e724fce20749dd Mon Sep 17 00:00:00 2001 From: glo82145 Date: Fri, 8 Sep 2023 15:15:31 +0530 Subject: [PATCH 20/21] PWA-3154 --- packages/peregrine/lib/Apollo/links/authLink.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/peregrine/lib/Apollo/links/authLink.js b/packages/peregrine/lib/Apollo/links/authLink.js index 8dd0c2693c..a7bbb4a183 100644 --- a/packages/peregrine/lib/Apollo/links/authLink.js +++ b/packages/peregrine/lib/Apollo/links/authLink.js @@ -12,8 +12,8 @@ export class MagentoGQLCacheLink extends ApolloLink { operation.setContext(previousContext => { const { headers } = previousContext; // return the headers to the context so httpLink can read them - // console.log(token); - + console.log(headers+'sdfsd'); + console.log('kjhg'); return { headers: { ...headers, @@ -27,13 +27,13 @@ export class MagentoGQLCacheLink extends ApolloLink { const updateToken = data => { const context = operation.getContext(); const { response } = context; - + // console.log(string.indexOf(substring) !== -1); // true if (response.headers.get('X-Cache') == 'HIT, HIT') { console.log('cache'); - token = null; - gg = 'dff'; + this.token = null; + this.gg = 'dff'; } - gg = response.headers.get('X-Cache'); + this.gg = response.headers.get('X-Cache'); console.log(token); // Purposefully don't modify the result, // no other link needs to know about the cache id. From 9be733ac23caa3c417aa18bc08ec1e367b9516ea Mon Sep 17 00:00:00 2001 From: Aanchal Pawar <97873570+glo82145@users.noreply.github.com> Date: Mon, 18 Sep 2023 11:10:27 +0530 Subject: [PATCH 21/21] Update authLink.js --- packages/peregrine/lib/Apollo/links/authLink.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/peregrine/lib/Apollo/links/authLink.js b/packages/peregrine/lib/Apollo/links/authLink.js index a7bbb4a183..1516d0842c 100644 --- a/packages/peregrine/lib/Apollo/links/authLink.js +++ b/packages/peregrine/lib/Apollo/links/authLink.js @@ -7,6 +7,7 @@ var gg = 'dd'; export class MagentoGQLCacheLink extends ApolloLink { // The token get reinstantiated on refresh. // If we have an existing token value from a previous browsing session, use it. + request(operation, forward) { operation.setContext(previousContext => { @@ -46,4 +47,4 @@ export class MagentoGQLCacheLink extends ApolloLink { export default function createAuthLink() { return new MagentoGQLCacheLink(); -} \ No newline at end of file +}