@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.
@@ -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;
@@ -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-client';
3
- import { NormalizedCacheObject, InMemoryCache } from 'apollo-cache-inmemory';
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-client';
9
- export { IntrospectionFragmentMatcher, InMemoryCache } from 'apollo-cache-inmemory';
10
- export { DataProxy } from 'apollo-cache';
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.IntrospectionFragmentMatcher = exports.GraphqlModule = void 0;
29
+ exports.InMemoryCache = exports.GraphqlModule = void 0;
30
30
  const core_1 = require("@rxdi/core");
31
- const apollo_cache_inmemory_1 = require("apollo-cache-inmemory");
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 apollo_client_1 = require("apollo-client");
35
- const apollo_link_1 = require("apollo-link");
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 apollo_utilities_1 = require("apollo-utilities");
39
- const apollo_link_context_1 = require("apollo-link-context");
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 apollo_client_1.ApolloClient(Object.assign({ link: (0, apollo_link_1.concat)((0, apollo_link_1.from)([
54
- (0, apollo_link_context_1.setContext)((operation) => __awaiter(this, void 0, void 0, function* () {
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 apollo_link_1.ApolloLink(typeof apolloRequestHandler === 'function'
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 apollo_link_1.Observable((observer) => {
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, apollo_link_1.split)(({ query }) => {
103
- const { kind, operation } = (0, apollo_utilities_1.getMainDefinition)(query);
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 apollo_link_ws_1.WebSocketLink(new subscriptions_transport_ws_1.SubscriptionClient(pubsub, {
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, apollo_link_http_1.createHttpLink)({ uri }))), cache: cache || new apollo_cache_inmemory_1.InMemoryCache() }, apolloClientOptions)),
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 apollo_cache_inmemory_2 = require("apollo-cache-inmemory");
135
- Object.defineProperty(exports, "IntrospectionFragmentMatcher", { enumerable: true, get: function () { return apollo_cache_inmemory_2.IntrospectionFragmentMatcher; } });
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.134",
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-cache-inmemory": "^1.6.2",
17
- "apollo-client": "^2.6.3",
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.133"
22
+ "@rxdi/core": "^0.7.136"
28
23
  },
29
24
  "types": "./dist/index.d.ts",
30
25
  "module": "./dist/index.js",