@rxdi/graphql-client 0.7.134 → 0.7.137
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/graphq.helpers.d.ts +13 -0
- package/dist/graphq.helpers.js +6 -1
- package/dist/graphql.injection.d.ts +2 -3
- package/dist/index.d.ts +3 -4
- package/dist/index.js +16 -19
- package/package.json +4 -9
package/dist/graphq.helpers.d.ts
CHANGED
|
@@ -1 +1,14 @@
|
|
|
1
|
+
import { PossibleTypesMap } from '@apollo/client/core';
|
|
1
2
|
export declare function importQuery<T>(search: T): any;
|
|
3
|
+
export interface IntrospectionQuery {
|
|
4
|
+
__schema: {
|
|
5
|
+
types: {
|
|
6
|
+
name: string;
|
|
7
|
+
possibleTypes: {
|
|
8
|
+
name: string;
|
|
9
|
+
}[];
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare const convertToPossibleTypes: (introspectionQuery: IntrospectionQuery) => PossibleTypesMap;
|
|
14
|
+
export declare const deepCopy: <T>(state: T) => T;
|
package/dist/graphq.helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.importQuery = void 0;
|
|
3
|
+
exports.deepCopy = exports.convertToPossibleTypes = exports.importQuery = void 0;
|
|
4
4
|
const core_1 = require("@rxdi/core");
|
|
5
5
|
function importQuery(search) {
|
|
6
6
|
let result;
|
|
@@ -17,3 +17,8 @@ function importQuery(search) {
|
|
|
17
17
|
return result;
|
|
18
18
|
}
|
|
19
19
|
exports.importQuery = importQuery;
|
|
20
|
+
const convertToPossibleTypes = (introspectionQuery) => introspectionQuery.__schema.types.reduce((acc, curr) => (Object.assign(Object.assign({}, acc), { [curr.name]: curr.possibleTypes.map((type) => type.name) })), {});
|
|
21
|
+
exports.convertToPossibleTypes = convertToPossibleTypes;
|
|
22
|
+
/* Utility function helping us to get a new object using the apollo-store */
|
|
23
|
+
const deepCopy = (state) => JSON.parse(JSON.stringify(state));
|
|
24
|
+
exports.deepCopy = deepCopy;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { InjectionToken } from '@rxdi/core';
|
|
2
|
-
import { ApolloClient as AC, ApolloClientOptions } from 'apollo
|
|
3
|
-
import { NormalizedCacheObject, InMemoryCache } from 'apollo
|
|
4
|
-
import { RequestHandler } from 'apollo-link';
|
|
2
|
+
import { ApolloClient as AC, ApolloClientOptions, RequestHandler } from '@apollo/client/core';
|
|
3
|
+
import { NormalizedCacheObject, InMemoryCache } from '@apollo/client/cache';
|
|
5
4
|
export declare const ApolloClient: InjectionToken<AC<NormalizedCacheObject>>;
|
|
6
5
|
export interface ApolloClient extends AC<NormalizedCacheObject> {
|
|
7
6
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ export declare class GraphqlModule {
|
|
|
5
5
|
}
|
|
6
6
|
export * from './graphql.injection';
|
|
7
7
|
export * from './graphq.helpers';
|
|
8
|
-
export { QueryOptions, SubscriptionOptions, MutationOptions } from 'apollo
|
|
9
|
-
export {
|
|
10
|
-
export { DataProxy } from 'apollo
|
|
11
|
-
export { GraphQLRequest } from 'apollo-link';
|
|
8
|
+
export { GraphQLRequest, QueryOptions, SubscriptionOptions, MutationOptions, PossibleTypesMap, } from '@apollo/client/core';
|
|
9
|
+
export { InMemoryCache } from '@apollo/client/cache';
|
|
10
|
+
export { DataProxy } from '@apollo/client/cache';
|
package/dist/index.js
CHANGED
|
@@ -26,17 +26,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
26
26
|
};
|
|
27
27
|
var GraphqlModule_1;
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.InMemoryCache = exports.
|
|
29
|
+
exports.InMemoryCache = exports.GraphqlModule = void 0;
|
|
30
30
|
const core_1 = require("@rxdi/core");
|
|
31
|
-
const
|
|
32
|
-
const apollo_link_http_1 = require("apollo-link-http");
|
|
31
|
+
const cache_1 = require("@apollo/client/cache");
|
|
33
32
|
const graphql_injection_1 = require("./graphql.injection");
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const apollo_link_ws_1 = require("apollo-link-ws");
|
|
33
|
+
const core_2 = require("@apollo/client/core");
|
|
34
|
+
const ws_1 = require("@apollo/client/link/ws");
|
|
37
35
|
const subscriptions_transport_ws_1 = require("subscriptions-transport-ws");
|
|
38
|
-
const
|
|
39
|
-
const
|
|
36
|
+
const utilities_1 = require("@apollo/client/utilities");
|
|
37
|
+
const context_1 = require("@apollo/client/link/context");
|
|
40
38
|
let GraphqlModule = GraphqlModule_1 = class GraphqlModule {
|
|
41
39
|
static forRoot({ uri, pubsub, onRequest, cache, apolloRequestHandler, cancelPendingRequests, apolloClientOptions, } = {}, documents = {}) {
|
|
42
40
|
const headers = {};
|
|
@@ -50,8 +48,8 @@ let GraphqlModule = GraphqlModule_1 = class GraphqlModule {
|
|
|
50
48
|
},
|
|
51
49
|
{
|
|
52
50
|
provide: graphql_injection_1.ApolloClient,
|
|
53
|
-
useFactory: () => new
|
|
54
|
-
(0,
|
|
51
|
+
useFactory: () => new core_2.ApolloClient(Object.assign({ link: (0, core_2.concat)((0, core_2.from)([
|
|
52
|
+
(0, context_1.setContext)((operation) => __awaiter(this, void 0, void 0, function* () {
|
|
55
53
|
const method = onRequest || graphql_injection_1.noopHeaders;
|
|
56
54
|
let headersMap = (yield method.call(operation)) || {};
|
|
57
55
|
headersMap.forEach((v, k) => {
|
|
@@ -61,12 +59,12 @@ let GraphqlModule = GraphqlModule_1 = class GraphqlModule {
|
|
|
61
59
|
headers,
|
|
62
60
|
};
|
|
63
61
|
})),
|
|
64
|
-
new
|
|
62
|
+
new core_2.ApolloLink(typeof apolloRequestHandler === 'function'
|
|
65
63
|
? apolloRequestHandler
|
|
66
64
|
: (operation, forward) => {
|
|
67
65
|
/* Start cancel request */
|
|
68
66
|
if (cancelPendingRequests) {
|
|
69
|
-
return new
|
|
67
|
+
return new core_2.Observable((observer) => {
|
|
70
68
|
const context = operation.getContext();
|
|
71
69
|
const connectionHandle = forward(operation).subscribe({
|
|
72
70
|
next: (...arg) => observer.next(...arg),
|
|
@@ -99,11 +97,11 @@ let GraphqlModule = GraphqlModule_1 = class GraphqlModule {
|
|
|
99
97
|
/* End cancel request */
|
|
100
98
|
return forward(operation);
|
|
101
99
|
}),
|
|
102
|
-
]), (0,
|
|
103
|
-
const { kind, operation } = (0,
|
|
100
|
+
]), (0, core_2.split)(({ query }) => {
|
|
101
|
+
const { kind, operation } = (0, utilities_1.getMainDefinition)(query);
|
|
104
102
|
return kind === 'OperationDefinition' && operation === 'subscription';
|
|
105
103
|
}, (() => {
|
|
106
|
-
const wsLink = new
|
|
104
|
+
const wsLink = new ws_1.WebSocketLink(new subscriptions_transport_ws_1.SubscriptionClient(pubsub, {
|
|
107
105
|
lazy: true,
|
|
108
106
|
connectionParams: () => ({
|
|
109
107
|
get authorization() {
|
|
@@ -119,7 +117,7 @@ let GraphqlModule = GraphqlModule_1 = class GraphqlModule {
|
|
|
119
117
|
reconnect: true,
|
|
120
118
|
}));
|
|
121
119
|
return wsLink;
|
|
122
|
-
})(), (0,
|
|
120
|
+
})(), (0, core_2.createHttpLink)({ uri }))), cache: cache || new cache_1.InMemoryCache() }, apolloClientOptions)),
|
|
123
121
|
},
|
|
124
122
|
],
|
|
125
123
|
};
|
|
@@ -131,6 +129,5 @@ GraphqlModule = GraphqlModule_1 = __decorate([
|
|
|
131
129
|
exports.GraphqlModule = GraphqlModule;
|
|
132
130
|
__exportStar(require("./graphql.injection"), exports);
|
|
133
131
|
__exportStar(require("./graphq.helpers"), exports);
|
|
134
|
-
var
|
|
135
|
-
Object.defineProperty(exports, "
|
|
136
|
-
Object.defineProperty(exports, "InMemoryCache", { enumerable: true, get: function () { return apollo_cache_inmemory_2.InMemoryCache; } });
|
|
132
|
+
var cache_2 = require("@apollo/client/cache");
|
|
133
|
+
Object.defineProperty(exports, "InMemoryCache", { enumerable: true, get: function () { return cache_2.InMemoryCache; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxdi/graphql-client",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.137",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"author": "Kristiyan Tachev",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,18 +13,13 @@
|
|
|
13
13
|
"test": "echo Test Graphql client"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"apollo
|
|
17
|
-
"
|
|
18
|
-
"apollo-link": "^1.2.12",
|
|
19
|
-
"apollo-link-context": "^1.0.18",
|
|
20
|
-
"apollo-link-http": "^1.5.15",
|
|
21
|
-
"apollo-link-ws": "^1.0.18",
|
|
22
|
-
"subscriptions-transport-ws": "^0.9.16"
|
|
16
|
+
"@apollo/client": "^3.4.16",
|
|
17
|
+
"subscriptions-transport-ws": "^0.9.19"
|
|
23
18
|
},
|
|
24
19
|
"devDependencies": {
|
|
25
20
|
"typescript": "^4.3.5",
|
|
26
21
|
"graphql": "^14.5.8",
|
|
27
|
-
"@rxdi/core": "^0.7.
|
|
22
|
+
"@rxdi/core": "^0.7.136"
|
|
28
23
|
},
|
|
29
24
|
"types": "./dist/index.d.ts",
|
|
30
25
|
"module": "./dist/index.js",
|