@rxdi/graphql-client 0.7.161 → 0.7.163

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.
@@ -13,6 +13,7 @@ export interface GraphqlModuleConfig {
13
13
  apolloRequestHandler?: RequestHandler;
14
14
  cancelPendingRequests?: boolean;
15
15
  apolloClientOptions?: ApolloClientOptions<unknown>;
16
+ refreshOnUnauthenticated?: boolean;
16
17
  }
17
18
  export declare const noopHeaders: () => Headers;
18
19
  export declare const noop: () => any;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ModuleWithServices } from '@rxdi/core';
2
2
  import { GraphqlModuleConfig } from './graphql.injection';
3
3
  export declare class GraphqlModule {
4
- static forRoot({ uri, pubsub, onRequest, cache, apolloRequestHandler, cancelPendingRequests, apolloClientOptions, }?: GraphqlModuleConfig, documents?: {}): ModuleWithServices;
4
+ static forRoot({ uri, pubsub, refreshOnUnauthenticated, onRequest, cache, apolloRequestHandler, cancelPendingRequests, apolloClientOptions, }?: GraphqlModuleConfig, documents?: {}): ModuleWithServices;
5
5
  }
6
6
  export * from './graphql.injection';
7
7
  export * from './graphq.helpers';
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ const subscriptions_transport_ws_1 = require("subscriptions-transport-ws");
36
36
  const utilities_1 = require("@apollo/client/utilities");
37
37
  const context_1 = require("@apollo/client/link/context");
38
38
  let GraphqlModule = GraphqlModule_1 = class GraphqlModule {
39
- static forRoot({ uri, pubsub, onRequest, cache, apolloRequestHandler, cancelPendingRequests, apolloClientOptions, } = {}, documents = {}) {
39
+ static forRoot({ uri, pubsub, refreshOnUnauthenticated, onRequest, cache, apolloRequestHandler, cancelPendingRequests, apolloClientOptions, } = {}, documents = {}) {
40
40
  const headers = {};
41
41
  const connections = {};
42
42
  return {
@@ -111,6 +111,9 @@ let GraphqlModule = GraphqlModule_1 = class GraphqlModule {
111
111
  connectionCallback: (error) => {
112
112
  console.error('[Subscription]: ', error);
113
113
  if ((error === null || error === void 0 ? void 0 : error['message']) === 'Unauthorized') {
114
+ if (refreshOnUnauthenticated) {
115
+ location.reload();
116
+ }
114
117
  wsLink['subscriptionClient'].close(false, false);
115
118
  }
116
119
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rxdi/graphql-client",
3
- "version": "0.7.161",
3
+ "version": "0.7.163",
4
4
  "main": "./dist/index.js",
5
5
  "author": "Kristiyan Tachev",
6
6
  "license": "MIT",
@@ -19,7 +19,7 @@
19
19
  "devDependencies": {
20
20
  "typescript": "^4.3.5",
21
21
  "graphql": "^14.5.8",
22
- "@rxdi/core": "^0.7.159"
22
+ "@rxdi/core": "^0.7.162"
23
23
  },
24
24
  "types": "./dist/index.d.ts",
25
25
  "module": "./dist/index.js",