@rxdi/graphql-client 0.7.234 → 0.7.235
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/dist/graphql.injection.d.ts +4 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -10
- package/package.json +2 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { InjectionToken } from '@rxdi/core';
|
|
2
|
-
import { ApolloClient as AC, ApolloClientOptions, DocumentNode, RequestHandler, TypedDocumentNode } from '@apollo/client/core';
|
|
2
|
+
import { ApolloClient as AC, ApolloClientOptions, DocumentNode, HttpOptions, RequestHandler, TypedDocumentNode } from '@apollo/client/core';
|
|
3
3
|
import { NormalizedCacheObject, InMemoryCache } from '@apollo/client/cache';
|
|
4
|
+
import { ClientOptions } from 'subscriptions-transport-ws';
|
|
4
5
|
export declare const ApolloClient: InjectionToken<AC<NormalizedCacheObject>>;
|
|
5
6
|
export interface ApolloClient extends AC<NormalizedCacheObject> {
|
|
6
7
|
}
|
|
@@ -18,6 +19,8 @@ export interface GraphqlModuleConfig {
|
|
|
18
19
|
cancelPendingRequests?: boolean;
|
|
19
20
|
apolloClientOptions?: ApolloClientOptions<unknown>;
|
|
20
21
|
refreshOnUnauthenticated?: boolean;
|
|
22
|
+
httpOptions?: HttpOptions;
|
|
23
|
+
pubsubOptions?: ClientOptions;
|
|
21
24
|
}
|
|
22
25
|
export declare const noopHeaders: () => Headers;
|
|
23
26
|
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, refreshOnUnauthenticated, onRequest, cache, apolloRequestHandler, cancelPendingRequests, apolloClientOptions, }?: GraphqlModuleConfig, documents?: {}): ModuleWithServices;
|
|
4
|
+
static forRoot({ uri, pubsub, refreshOnUnauthenticated, onRequest, cache, apolloRequestHandler, cancelPendingRequests, apolloClientOptions, httpOptions, pubsubOptions }?: GraphqlModuleConfig, documents?: {}): ModuleWithServices;
|
|
5
5
|
}
|
|
6
6
|
export * from './graphql.injection';
|
|
7
7
|
export * from './graphq.helpers';
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ const subscriptions_transport_ws_1 = require("subscriptions-transport-ws");
|
|
|
40
40
|
const utilities_1 = require("@apollo/client/utilities");
|
|
41
41
|
const context_1 = require("@apollo/client/link/context");
|
|
42
42
|
let GraphqlModule = GraphqlModule_1 = class GraphqlModule {
|
|
43
|
-
static forRoot({ uri, pubsub, refreshOnUnauthenticated, onRequest, cache, apolloRequestHandler, cancelPendingRequests, apolloClientOptions, } = {}, documents = {}) {
|
|
43
|
+
static forRoot({ uri, pubsub, refreshOnUnauthenticated, onRequest, cache, apolloRequestHandler, cancelPendingRequests, apolloClientOptions, httpOptions = {}, pubsubOptions = {} } = {}, documents = {}) {
|
|
44
44
|
const headers = {};
|
|
45
45
|
const connections = {};
|
|
46
46
|
return {
|
|
@@ -105,14 +105,11 @@ let GraphqlModule = GraphqlModule_1 = class GraphqlModule {
|
|
|
105
105
|
const { kind, operation } = (0, utilities_1.getMainDefinition)(query);
|
|
106
106
|
return kind === 'OperationDefinition' && operation === 'subscription';
|
|
107
107
|
}, (() => {
|
|
108
|
-
const wsLink = new ws_1.WebSocketLink(new subscriptions_transport_ws_1.SubscriptionClient(pubsub, {
|
|
109
|
-
lazy: true,
|
|
110
|
-
connectionParams: () => ({
|
|
108
|
+
const wsLink = new ws_1.WebSocketLink(new subscriptions_transport_ws_1.SubscriptionClient(pubsub, Object.assign({ lazy: true, connectionParams: () => ({
|
|
111
109
|
get authorization() {
|
|
112
110
|
return headers['authorization'];
|
|
113
111
|
},
|
|
114
|
-
}),
|
|
115
|
-
connectionCallback: (error) => {
|
|
112
|
+
}), connectionCallback: (error) => {
|
|
116
113
|
console.error('[Subscription]: ', error);
|
|
117
114
|
if ((error === null || error === void 0 ? void 0 : error['message']) === 'Unauthorized') {
|
|
118
115
|
if (refreshOnUnauthenticated) {
|
|
@@ -120,11 +117,9 @@ let GraphqlModule = GraphqlModule_1 = class GraphqlModule {
|
|
|
120
117
|
}
|
|
121
118
|
wsLink['subscriptionClient'].close(false, false);
|
|
122
119
|
}
|
|
123
|
-
},
|
|
124
|
-
reconnect: true,
|
|
125
|
-
}));
|
|
120
|
+
}, reconnect: true }, pubsubOptions)));
|
|
126
121
|
return wsLink;
|
|
127
|
-
})(), (0, core_2.createHttpLink)({ uri }))), cache: cache || new cache_1.InMemoryCache() }, apolloClientOptions)),
|
|
122
|
+
})(), (0, core_2.createHttpLink)(Object.assign({ uri }, httpOptions)))), cache: cache || new cache_1.InMemoryCache() }, apolloClientOptions)),
|
|
128
123
|
},
|
|
129
124
|
],
|
|
130
125
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxdi/graphql-client",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.235",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"author": "Kristiyan Tachev",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"subscriptions-transport-ws": "^0.9.19"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@rxdi/core": "^0.7.
|
|
20
|
+
"@rxdi/core": "^0.7.234",
|
|
21
21
|
"typescript": "^5.9.3",
|
|
22
22
|
"graphql": "^16.12.0"
|
|
23
23
|
},
|