@ikas/storefront 2.0.0-alpha.19 → 2.0.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/api/apollo.js +1 -1
- package/build/ikas.js +1 -1
- package/package.json +1 -1
package/build/api/apollo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as o}from'../ext/tslib/tslib.es6.js';import{onError as e}from'../ext/@apollo/client/link/error/index.js';import{setContext as n}from'../ext/@apollo/client/link/context/index.js';import{IkasStorefrontConfig as t}from"../storefront/index.js";import{createHttpLink as r}from'../ext/@apollo/client/link/http/createHttpLink.js';import{ApolloClient as i}from'../ext/@apollo/client/core/ApolloClient.js';import{InMemoryCache as c}from'../ext/@apollo/client/cache/inmemory/inMemoryCache.js';var l=new function l(){var a=this;this.createApolloClient=function(d){var s=e((function(o){var e=o.graphQLErrors,n=(o.networkError,o.operation);e&&console.log(e);var t=null==e?void 0:e.some((function(o){var e;return"UNAUTHORIZED"===(null===(e=o.extensions)||void 0===e?void 0:e.code)}));t&&"undefined"!=typeof window&&"refreshToken"!==n.operationName&&(window.location.href="/account/login?redirect="+encodeURIComponent(window.location.pathname))})),p=n((function(e,n){var r=n.headers,i=o(o({},r),{"x-api-key":d||t.config.apiKey,"x-sfid":t.storefrontId,"x-sfrid":t.storefrontRoutingId});return l.customerToken&&(i.Authorization="Bearer "+l.customerToken),{headers:i}})),
|
|
1
|
+
import{__assign as o}from'../ext/tslib/tslib.es6.js';import{onError as e}from'../ext/@apollo/client/link/error/index.js';import{setContext as n}from'../ext/@apollo/client/link/context/index.js';import{IkasStorefrontConfig as t}from"../storefront/index.js";import{createHttpLink as r}from'../ext/@apollo/client/link/http/createHttpLink.js';import{ApolloClient as i}from'../ext/@apollo/client/core/ApolloClient.js';import{InMemoryCache as c}from'../ext/@apollo/client/cache/inmemory/inMemoryCache.js';var l=new function l(){var a=this;this.createApolloClient=function(d){var s=e((function(o){var e=o.graphQLErrors,n=(o.networkError,o.operation);e&&console.log(e);var t=null==e?void 0:e.some((function(o){var e;return"UNAUTHORIZED"===(null===(e=o.extensions)||void 0===e?void 0:e.code)}));t&&"undefined"!=typeof window&&"refreshToken"!==n.operationName&&(window.location.href="/account/login?redirect="+encodeURIComponent(window.location.pathname))})),p=n((function(e,n){var r=n.headers,i=o(o({},r),{"x-api-key":d||t.config.apiKey,"x-sfid":t.storefrontId,"x-sfrid":t.storefrontRoutingId});return l.customerToken&&(i.Authorization="Bearer "+l.customerToken),{headers:i}})),f=r({uri:t.apiUrlOverride||process.env.NEXT_PUBLIC_GQL_URL,fetch:function(o,e){var n=JSON.parse(e.body).operationName;return fetch("".concat(o,"?op=").concat(n),e)}});a._client=new i({link:p.concat(s).concat(f),cache:new c({addTypename:!1}),defaultOptions:{watchQuery:{fetchPolicy:"no-cache",errorPolicy:"ignore"},query:{fetchPolicy:"no-cache",errorPolicy:"all"}}})},this.setCustomerToken=function(o){l.customerToken=o,a._client&&a.createApolloClient("undefined"!=typeof window?window.editorApiKey:void 0)},this.getClient=function(){return a._client||a.createApolloClient("undefined"!=typeof window?window.editorApiKey:void 0),a._client}};export{l as apollo};
|