@apollo/client 3.6.2 → 3.6.5

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.
Files changed (84) hide show
  1. package/apollo-client.cjs +164 -105
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/cache/cache.cjs +9 -10
  5. package/cache/cache.cjs.map +1 -1
  6. package/cache/cache.cjs.native.js +2288 -0
  7. package/cache/inmemory/readFromStore.d.ts.map +1 -1
  8. package/cache/inmemory/readFromStore.js +10 -11
  9. package/cache/inmemory/readFromStore.js.map +1 -1
  10. package/core/ApolloClient.d.ts.map +1 -1
  11. package/core/ApolloClient.js.map +1 -1
  12. package/core/ObservableQuery.d.ts.map +1 -1
  13. package/core/ObservableQuery.js +5 -3
  14. package/core/ObservableQuery.js.map +1 -1
  15. package/core/core.cjs +5 -3
  16. package/core/core.cjs.map +1 -1
  17. package/core/core.cjs.native.js +2141 -0
  18. package/errors/errors.cjs.native.js +48 -0
  19. package/invariantErrorCodes.js +1 -1
  20. package/link/batch/batch.cjs.native.js +161 -0
  21. package/link/batch-http/batch-http.cjs.native.js +127 -0
  22. package/link/context/context.cjs.native.js +38 -0
  23. package/link/core/core.cjs.native.js +121 -0
  24. package/link/error/error.cjs.native.js +90 -0
  25. package/link/http/http.cjs.native.js +320 -0
  26. package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
  27. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  28. package/link/persisted-queries/persisted-queries.cjs.native.js +174 -0
  29. package/link/retry/retry.cjs.native.js +170 -0
  30. package/link/schema/schema.cjs.native.js +56 -0
  31. package/link/subscriptions/subscriptions.cjs.native.js +45 -0
  32. package/link/utils/utils.cjs.native.js +115 -0
  33. package/link/ws/ws.cjs.native.js +28 -0
  34. package/main.cjs.native.js +16 -0
  35. package/package.json +16 -17
  36. package/react/components/components.cjs.native.js +79 -0
  37. package/react/context/context.cjs.native.js +67 -0
  38. package/react/hoc/hoc.cjs.native.js +325 -0
  39. package/react/hooks/hooks.cjs +168 -99
  40. package/react/hooks/hooks.cjs.map +1 -1
  41. package/react/hooks/hooks.cjs.native.js +612 -0
  42. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  43. package/react/hooks/useLazyQuery.js +12 -23
  44. package/react/hooks/useLazyQuery.js.map +1 -1
  45. package/react/hooks/useMutation.js +7 -7
  46. package/react/hooks/useMutation.js.map +1 -1
  47. package/react/hooks/useQuery.d.ts +6 -2
  48. package/react/hooks/useQuery.d.ts.map +1 -1
  49. package/react/hooks/useQuery.js +52 -40
  50. package/react/hooks/useQuery.js.map +1 -1
  51. package/react/hooks/useSubscription.d.ts.map +1 -1
  52. package/react/hooks/useSubscription.js +17 -7
  53. package/react/hooks/useSubscription.js.map +1 -1
  54. package/react/hooks/useSyncExternalStore.d.ts +4 -0
  55. package/react/hooks/useSyncExternalStore.d.ts.map +1 -0
  56. package/react/hooks/useSyncExternalStore.js +48 -0
  57. package/react/hooks/useSyncExternalStore.js.map +1 -0
  58. package/react/parser/parser.cjs.native.js +103 -0
  59. package/react/react.cjs.native.js +22 -0
  60. package/react/ssr/ssr.cjs.native.js +150 -0
  61. package/testing/core/core.cjs.native.js +288 -0
  62. package/testing/testing.cjs.native.js +58 -0
  63. package/utilities/common/canUse.d.ts +2 -0
  64. package/utilities/common/canUse.d.ts.map +1 -1
  65. package/utilities/common/canUse.js +6 -2
  66. package/utilities/common/canUse.js.map +1 -1
  67. package/utilities/common/mergeDeep.d.ts.map +1 -1
  68. package/utilities/common/mergeDeep.js +8 -11
  69. package/utilities/common/mergeDeep.js.map +1 -1
  70. package/utilities/common/mergeOptions.d.ts +1 -1
  71. package/utilities/common/mergeOptions.d.ts.map +1 -1
  72. package/utilities/common/mergeOptions.js +1 -1
  73. package/utilities/common/mergeOptions.js.map +1 -1
  74. package/utilities/globals/globals.cjs.native.js +56 -0
  75. package/utilities/observables/Concast.d.ts.map +1 -1
  76. package/utilities/observables/Concast.js +5 -2
  77. package/utilities/observables/Concast.js.map +1 -1
  78. package/utilities/policies/pagination.d.ts.map +1 -1
  79. package/utilities/policies/pagination.js +9 -7
  80. package/utilities/policies/pagination.js.map +1 -1
  81. package/utilities/utilities.cjs +30 -23
  82. package/utilities/utilities.cjs.map +1 -1
  83. package/utilities/utilities.cjs.native.js +1281 -0
  84. package/version.js +1 -1
@@ -0,0 +1,170 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var core = require('../core');
7
+ var utilities = require('../../utilities');
8
+
9
+ function buildDelayFunction(delayOptions) {
10
+ var _a = delayOptions || {}, _b = _a.initial, initial = _b === void 0 ? 300 : _b, _c = _a.jitter, jitter = _c === void 0 ? true : _c, _d = _a.max, max = _d === void 0 ? Infinity : _d;
11
+ var baseDelay = jitter ? initial : initial / 2;
12
+ return function delayFunction(count) {
13
+ var delay = Math.min(max, baseDelay * Math.pow(2, count));
14
+ if (jitter) {
15
+ delay = Math.random() * delay;
16
+ }
17
+ return delay;
18
+ };
19
+ }
20
+
21
+ function buildRetryFunction(retryOptions) {
22
+ var _a = retryOptions || {}, retryIf = _a.retryIf, _b = _a.max, max = _b === void 0 ? 5 : _b;
23
+ return function retryFunction(count, operation, error) {
24
+ if (count >= max)
25
+ return false;
26
+ return retryIf ? retryIf(error, operation) : !!error;
27
+ };
28
+ }
29
+
30
+ var RetryableOperation = (function () {
31
+ function RetryableOperation(operation, nextLink, delayFor, retryIf) {
32
+ var _this = this;
33
+ this.operation = operation;
34
+ this.nextLink = nextLink;
35
+ this.delayFor = delayFor;
36
+ this.retryIf = retryIf;
37
+ this.retryCount = 0;
38
+ this.values = [];
39
+ this.complete = false;
40
+ this.canceled = false;
41
+ this.observers = [];
42
+ this.currentSubscription = null;
43
+ this.onNext = function (value) {
44
+ _this.values.push(value);
45
+ for (var _i = 0, _a = _this.observers; _i < _a.length; _i++) {
46
+ var observer = _a[_i];
47
+ if (!observer)
48
+ continue;
49
+ observer.next(value);
50
+ }
51
+ };
52
+ this.onComplete = function () {
53
+ _this.complete = true;
54
+ for (var _i = 0, _a = _this.observers; _i < _a.length; _i++) {
55
+ var observer = _a[_i];
56
+ if (!observer)
57
+ continue;
58
+ observer.complete();
59
+ }
60
+ };
61
+ this.onError = function (error) { return tslib.__awaiter(_this, void 0, void 0, function () {
62
+ var shouldRetry, _i, _a, observer;
63
+ return tslib.__generator(this, function (_b) {
64
+ switch (_b.label) {
65
+ case 0:
66
+ this.retryCount += 1;
67
+ return [4, this.retryIf(this.retryCount, this.operation, error)];
68
+ case 1:
69
+ shouldRetry = _b.sent();
70
+ if (shouldRetry) {
71
+ this.scheduleRetry(this.delayFor(this.retryCount, this.operation, error));
72
+ return [2];
73
+ }
74
+ this.error = error;
75
+ for (_i = 0, _a = this.observers; _i < _a.length; _i++) {
76
+ observer = _a[_i];
77
+ if (!observer)
78
+ continue;
79
+ observer.error(error);
80
+ }
81
+ return [2];
82
+ }
83
+ });
84
+ }); };
85
+ }
86
+ RetryableOperation.prototype.subscribe = function (observer) {
87
+ if (this.canceled) {
88
+ throw new Error("Subscribing to a retryable link that was canceled is not supported");
89
+ }
90
+ this.observers.push(observer);
91
+ for (var _i = 0, _a = this.values; _i < _a.length; _i++) {
92
+ var value = _a[_i];
93
+ observer.next(value);
94
+ }
95
+ if (this.complete) {
96
+ observer.complete();
97
+ }
98
+ else if (this.error) {
99
+ observer.error(this.error);
100
+ }
101
+ };
102
+ RetryableOperation.prototype.unsubscribe = function (observer) {
103
+ var index = this.observers.indexOf(observer);
104
+ if (index < 0) {
105
+ throw new Error("RetryLink BUG! Attempting to unsubscribe unknown observer!");
106
+ }
107
+ this.observers[index] = null;
108
+ if (this.observers.every(function (o) { return o === null; })) {
109
+ this.cancel();
110
+ }
111
+ };
112
+ RetryableOperation.prototype.start = function () {
113
+ if (this.currentSubscription)
114
+ return;
115
+ this.try();
116
+ };
117
+ RetryableOperation.prototype.cancel = function () {
118
+ if (this.currentSubscription) {
119
+ this.currentSubscription.unsubscribe();
120
+ }
121
+ clearTimeout(this.timerId);
122
+ this.timerId = undefined;
123
+ this.currentSubscription = null;
124
+ this.canceled = true;
125
+ };
126
+ RetryableOperation.prototype.try = function () {
127
+ this.currentSubscription = this.nextLink(this.operation).subscribe({
128
+ next: this.onNext,
129
+ error: this.onError,
130
+ complete: this.onComplete,
131
+ });
132
+ };
133
+ RetryableOperation.prototype.scheduleRetry = function (delay) {
134
+ var _this = this;
135
+ if (this.timerId) {
136
+ throw new Error("RetryLink BUG! Encountered overlapping retries");
137
+ }
138
+ this.timerId = setTimeout(function () {
139
+ _this.timerId = undefined;
140
+ _this.try();
141
+ }, delay);
142
+ };
143
+ return RetryableOperation;
144
+ }());
145
+ var RetryLink = (function (_super) {
146
+ tslib.__extends(RetryLink, _super);
147
+ function RetryLink(options) {
148
+ var _this = _super.call(this) || this;
149
+ var _a = options || {}, attempts = _a.attempts, delay = _a.delay;
150
+ _this.delayFor =
151
+ typeof delay === 'function' ? delay : buildDelayFunction(delay);
152
+ _this.retryIf =
153
+ typeof attempts === 'function' ? attempts : buildRetryFunction(attempts);
154
+ return _this;
155
+ }
156
+ RetryLink.prototype.request = function (operation, nextLink) {
157
+ var retryable = new RetryableOperation(operation, nextLink, this.delayFor, this.retryIf);
158
+ retryable.start();
159
+ return new utilities.Observable(function (observer) {
160
+ retryable.subscribe(observer);
161
+ return function () {
162
+ retryable.unsubscribe(observer);
163
+ };
164
+ });
165
+ };
166
+ return RetryLink;
167
+ }(core.ApolloLink));
168
+
169
+ exports.RetryLink = RetryLink;
170
+ //# sourceMappingURL=retry.cjs.map
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var graphql = require('graphql');
7
+ var core = require('../core');
8
+ var utilities = require('../../utilities');
9
+
10
+ var SchemaLink = (function (_super) {
11
+ tslib.__extends(SchemaLink, _super);
12
+ function SchemaLink(options) {
13
+ var _this = _super.call(this) || this;
14
+ _this.schema = options.schema;
15
+ _this.rootValue = options.rootValue;
16
+ _this.context = options.context;
17
+ _this.validate = !!options.validate;
18
+ return _this;
19
+ }
20
+ SchemaLink.prototype.request = function (operation) {
21
+ var _this = this;
22
+ return new utilities.Observable(function (observer) {
23
+ new Promise(function (resolve) { return resolve(typeof _this.context === 'function'
24
+ ? _this.context(operation)
25
+ : _this.context); }).then(function (context) {
26
+ if (_this.validate) {
27
+ var validationErrors = graphql.validate(_this.schema, operation.query);
28
+ if (validationErrors.length > 0) {
29
+ return { errors: validationErrors };
30
+ }
31
+ }
32
+ return graphql.execute({
33
+ schema: _this.schema,
34
+ document: operation.query,
35
+ rootValue: _this.rootValue,
36
+ contextValue: context,
37
+ variableValues: operation.variables,
38
+ operationName: operation.operationName,
39
+ });
40
+ }).then(function (data) {
41
+ if (!observer.closed) {
42
+ observer.next(data);
43
+ observer.complete();
44
+ }
45
+ }).catch(function (error) {
46
+ if (!observer.closed) {
47
+ observer.error(error);
48
+ }
49
+ });
50
+ });
51
+ };
52
+ return SchemaLink;
53
+ }(core.ApolloLink));
54
+
55
+ exports.SchemaLink = SchemaLink;
56
+ //# sourceMappingURL=schema.cjs.map
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var graphql = require('graphql');
7
+ var core = require('../core');
8
+ var utilities = require('../../utilities');
9
+ var errors = require('../../errors');
10
+
11
+ function isLikeCloseEvent(val) {
12
+ return utilities.isNonNullObject(val) && 'code' in val && 'reason' in val;
13
+ }
14
+ var GraphQLWsLink = (function (_super) {
15
+ tslib.__extends(GraphQLWsLink, _super);
16
+ function GraphQLWsLink(client) {
17
+ var _this = _super.call(this) || this;
18
+ _this.client = client;
19
+ return _this;
20
+ }
21
+ GraphQLWsLink.prototype.request = function (operation) {
22
+ var _this = this;
23
+ return new utilities.Observable(function (observer) {
24
+ return _this.client.subscribe(tslib.__assign(tslib.__assign({}, operation), { query: graphql.print(operation.query) }), {
25
+ next: observer.next.bind(observer),
26
+ complete: observer.complete.bind(observer),
27
+ error: function (err) {
28
+ if (err instanceof Error) {
29
+ return observer.error(err);
30
+ }
31
+ if (isLikeCloseEvent(err)) {
32
+ return observer.error(new Error("Socket closed with event ".concat(err.code, " ").concat(err.reason || "")));
33
+ }
34
+ return observer.error(new errors.ApolloError({
35
+ graphQLErrors: Array.isArray(err) ? err : [err],
36
+ }));
37
+ },
38
+ });
39
+ });
40
+ };
41
+ return GraphQLWsLink;
42
+ }(core.ApolloLink));
43
+
44
+ exports.GraphQLWsLink = GraphQLWsLink;
45
+ //# sourceMappingURL=subscriptions.cjs.map
@@ -0,0 +1,115 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var globals = require('../../utilities/globals');
6
+ var utilities = require('../../utilities');
7
+ var tslib = require('tslib');
8
+
9
+ function fromError(errorValue) {
10
+ return new utilities.Observable(function (observer) {
11
+ observer.error(errorValue);
12
+ });
13
+ }
14
+
15
+ function toPromise(observable) {
16
+ var completed = false;
17
+ return new Promise(function (resolve, reject) {
18
+ observable.subscribe({
19
+ next: function (data) {
20
+ if (completed) {
21
+ __DEV__ && globals.invariant.warn("Promise Wrapper does not support multiple results from Observable");
22
+ }
23
+ else {
24
+ completed = true;
25
+ resolve(data);
26
+ }
27
+ },
28
+ error: reject,
29
+ });
30
+ });
31
+ }
32
+
33
+ function fromPromise(promise) {
34
+ return new utilities.Observable(function (observer) {
35
+ promise
36
+ .then(function (value) {
37
+ observer.next(value);
38
+ observer.complete();
39
+ })
40
+ .catch(observer.error.bind(observer));
41
+ });
42
+ }
43
+
44
+ var throwServerError = function (response, result, message) {
45
+ var error = new Error(message);
46
+ error.name = 'ServerError';
47
+ error.response = response;
48
+ error.statusCode = response.status;
49
+ error.result = result;
50
+ throw error;
51
+ };
52
+
53
+ function validateOperation(operation) {
54
+ var OPERATION_FIELDS = [
55
+ 'query',
56
+ 'operationName',
57
+ 'variables',
58
+ 'extensions',
59
+ 'context',
60
+ ];
61
+ for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
62
+ var key = _a[_i];
63
+ if (OPERATION_FIELDS.indexOf(key) < 0) {
64
+ throw __DEV__ ? new globals.InvariantError("illegal argument: ".concat(key)) : new globals.InvariantError(24);
65
+ }
66
+ }
67
+ return operation;
68
+ }
69
+
70
+ function createOperation(starting, operation) {
71
+ var context = tslib.__assign({}, starting);
72
+ var setContext = function (next) {
73
+ if (typeof next === 'function') {
74
+ context = tslib.__assign(tslib.__assign({}, context), next(context));
75
+ }
76
+ else {
77
+ context = tslib.__assign(tslib.__assign({}, context), next);
78
+ }
79
+ };
80
+ var getContext = function () { return (tslib.__assign({}, context)); };
81
+ Object.defineProperty(operation, 'setContext', {
82
+ enumerable: false,
83
+ value: setContext,
84
+ });
85
+ Object.defineProperty(operation, 'getContext', {
86
+ enumerable: false,
87
+ value: getContext,
88
+ });
89
+ return operation;
90
+ }
91
+
92
+ function transformOperation(operation) {
93
+ var transformedOperation = {
94
+ variables: operation.variables || {},
95
+ extensions: operation.extensions || {},
96
+ operationName: operation.operationName,
97
+ query: operation.query,
98
+ };
99
+ if (!transformedOperation.operationName) {
100
+ transformedOperation.operationName =
101
+ typeof transformedOperation.query !== 'string'
102
+ ? utilities.getOperationName(transformedOperation.query) || undefined
103
+ : '';
104
+ }
105
+ return transformedOperation;
106
+ }
107
+
108
+ exports.createOperation = createOperation;
109
+ exports.fromError = fromError;
110
+ exports.fromPromise = fromPromise;
111
+ exports.throwServerError = throwServerError;
112
+ exports.toPromise = toPromise;
113
+ exports.transformOperation = transformOperation;
114
+ exports.validateOperation = validateOperation;
115
+ //# sourceMappingURL=utils.cjs.map
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var subscriptionsTransportWs = require('subscriptions-transport-ws');
7
+ var core = require('../core');
8
+
9
+ var WebSocketLink = (function (_super) {
10
+ tslib.__extends(WebSocketLink, _super);
11
+ function WebSocketLink(paramsOrClient) {
12
+ var _this = _super.call(this) || this;
13
+ if (paramsOrClient instanceof subscriptionsTransportWs.SubscriptionClient) {
14
+ _this.subscriptionClient = paramsOrClient;
15
+ }
16
+ else {
17
+ _this.subscriptionClient = new subscriptionsTransportWs.SubscriptionClient(paramsOrClient.uri, paramsOrClient.options, paramsOrClient.webSocketImpl);
18
+ }
19
+ return _this;
20
+ }
21
+ WebSocketLink.prototype.request = function (operation) {
22
+ return this.subscriptionClient.request(operation);
23
+ };
24
+ return WebSocketLink;
25
+ }(core.ApolloLink));
26
+
27
+ exports.WebSocketLink = WebSocketLink;
28
+ //# sourceMappingURL=ws.cjs.map
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('./core');
6
+ var react = require('./react');
7
+
8
+
9
+
10
+ for (var k in core) {
11
+ if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = core[k];
12
+ }
13
+ for (var k in react) {
14
+ if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = react[k];
15
+ }
16
+ //# sourceMappingURL=main.cjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollo/client",
3
- "version": "3.6.2",
3
+ "version": "3.6.5",
4
4
  "description": "A fully-featured caching GraphQL client.",
5
5
  "private": false,
6
6
  "keywords": [
@@ -55,14 +55,13 @@
55
55
  "optimism": "^0.16.1",
56
56
  "prop-types": "^15.7.2",
57
57
  "symbol-observable": "^4.0.0",
58
- "ts-invariant": "^0.10.0",
58
+ "ts-invariant": "^0.10.3",
59
59
  "tslib": "^2.3.0",
60
- "use-sync-external-store": "^1.0.0",
61
- "zen-observable-ts": "^1.2.0"
60
+ "zen-observable-ts": "^1.2.5"
62
61
  },
63
62
  "devDependencies": {
64
- "@babel/parser": "7.17.10",
65
- "@graphql-tools/schema": "8.3.10",
63
+ "@babel/parser": "7.18.0",
64
+ "@graphql-tools/schema": "8.3.13",
66
65
  "@rollup/plugin-node-resolve": "11.2.1",
67
66
  "@testing-library/react": "12.1.5",
68
67
  "@testing-library/react-hooks": "8.0.0",
@@ -70,20 +69,20 @@
70
69
  "@types/fetch-mock": "7.3.5",
71
70
  "@types/glob": "7.2.0",
72
71
  "@types/hoist-non-react-statics": "3.3.1",
73
- "@types/jest": "27.4.1",
72
+ "@types/jest": "27.5.1",
74
73
  "@types/lodash": "4.14.182",
75
- "@types/node": "16.11.33",
76
- "@types/react": "17.0.44",
77
- "@types/react-dom": "17.0.16",
78
- "@types/use-sync-external-store": "0.0.3",
74
+ "@types/node": "16.11.36",
75
+ "@types/react": "17.0.45",
76
+ "@types/react-dom": "17.0.17",
77
+ "@types/use-sync-external-store": "^0.0.3",
79
78
  "acorn": "8.7.1",
80
79
  "bundlesize": "0.18.1",
81
80
  "cross-fetch": "3.1.5",
82
81
  "crypto-hash": "1.3.0",
83
82
  "fetch-mock": "9.11.0",
84
- "glob": "8.0.1",
85
- "graphql": "16.4.0",
86
- "graphql-ws": "5.8.1",
83
+ "glob": "8.0.3",
84
+ "graphql": "16.5.0",
85
+ "graphql-ws": "5.8.2",
87
86
  "jest": "27.5.1",
88
87
  "jest-fetch-mock": "3.0.3",
89
88
  "jest-junit": "13.2.0",
@@ -93,13 +92,13 @@
93
92
  "recast": "0.21.1",
94
93
  "resolve": "1.22.0",
95
94
  "rimraf": "3.0.2",
96
- "rollup": "2.71.1",
95
+ "rollup": "2.74.1",
97
96
  "rollup-plugin-terser": "7.0.2",
98
97
  "rxjs": "7.5.5",
99
98
  "subscriptions-transport-ws": "0.11.0",
100
99
  "terser": "5.13.1",
101
- "ts-jest": "27.1.4",
102
- "ts-node": "10.7.0",
100
+ "ts-jest": "27.1.5",
101
+ "ts-node": "10.8.0",
103
102
  "typescript": "4.6.4",
104
103
  "wait-for-observables": "1.0.3",
105
104
  "whatwg-fetch": "3.6.2"
@@ -0,0 +1,79 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var PropTypes = require('prop-types');
7
+ var hooks = require('../hooks');
8
+
9
+ function _interopNamespace(e) {
10
+ if (e && e.__esModule) return e;
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ for (var k in e) {
14
+ n[k] = e[k];
15
+ }
16
+ }
17
+ n["default"] = e;
18
+ return Object.freeze(n);
19
+ }
20
+
21
+ var PropTypes__namespace = /*#__PURE__*/_interopNamespace(PropTypes);
22
+
23
+ function Query(props) {
24
+ var children = props.children, query = props.query, options = tslib.__rest(props, ["children", "query"]);
25
+ var result = hooks.useQuery(query, options);
26
+ return result ? children(result) : null;
27
+ }
28
+ Query.propTypes = {
29
+ client: PropTypes__namespace.object,
30
+ children: PropTypes__namespace.func.isRequired,
31
+ fetchPolicy: PropTypes__namespace.string,
32
+ notifyOnNetworkStatusChange: PropTypes__namespace.bool,
33
+ onCompleted: PropTypes__namespace.func,
34
+ onError: PropTypes__namespace.func,
35
+ pollInterval: PropTypes__namespace.number,
36
+ query: PropTypes__namespace.object.isRequired,
37
+ variables: PropTypes__namespace.object,
38
+ ssr: PropTypes__namespace.bool,
39
+ partialRefetch: PropTypes__namespace.bool,
40
+ returnPartialData: PropTypes__namespace.bool
41
+ };
42
+
43
+ function Mutation(props) {
44
+ var _a = hooks.useMutation(props.mutation, props), runMutation = _a[0], result = _a[1];
45
+ return props.children ? props.children(runMutation, result) : null;
46
+ }
47
+ Mutation.propTypes = {
48
+ mutation: PropTypes__namespace.object.isRequired,
49
+ variables: PropTypes__namespace.object,
50
+ optimisticResponse: PropTypes__namespace.oneOfType([PropTypes__namespace.object, PropTypes__namespace.func]),
51
+ refetchQueries: PropTypes__namespace.oneOfType([
52
+ PropTypes__namespace.arrayOf(PropTypes__namespace.oneOfType([PropTypes__namespace.string, PropTypes__namespace.object])),
53
+ PropTypes__namespace.func
54
+ ]),
55
+ awaitRefetchQueries: PropTypes__namespace.bool,
56
+ update: PropTypes__namespace.func,
57
+ children: PropTypes__namespace.func.isRequired,
58
+ onCompleted: PropTypes__namespace.func,
59
+ onError: PropTypes__namespace.func,
60
+ fetchPolicy: PropTypes__namespace.string,
61
+ };
62
+
63
+ function Subscription(props) {
64
+ var result = hooks.useSubscription(props.subscription, props);
65
+ return props.children && result ? props.children(result) : null;
66
+ }
67
+ Subscription.propTypes = {
68
+ subscription: PropTypes__namespace.object.isRequired,
69
+ variables: PropTypes__namespace.object,
70
+ children: PropTypes__namespace.func,
71
+ onSubscriptionData: PropTypes__namespace.func,
72
+ onSubscriptionComplete: PropTypes__namespace.func,
73
+ shouldResubscribe: PropTypes__namespace.oneOfType([PropTypes__namespace.func, PropTypes__namespace.bool])
74
+ };
75
+
76
+ exports.Mutation = Mutation;
77
+ exports.Query = Query;
78
+ exports.Subscription = Subscription;
79
+ //# sourceMappingURL=components.cjs.map
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var globals = require('../../utilities/globals');
6
+ var React = require('react');
7
+ var utilities = require('../../utilities');
8
+
9
+ function _interopNamespace(e) {
10
+ if (e && e.__esModule) return e;
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ for (var k in e) {
14
+ n[k] = e[k];
15
+ }
16
+ }
17
+ n["default"] = e;
18
+ return Object.freeze(n);
19
+ }
20
+
21
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
22
+
23
+ var contextKey = utilities.canUseSymbol
24
+ ? Symbol.for('__APOLLO_CONTEXT__')
25
+ : '__APOLLO_CONTEXT__';
26
+ function getApolloContext() {
27
+ var context = React__namespace.createContext[contextKey];
28
+ if (!context) {
29
+ Object.defineProperty(React__namespace.createContext, contextKey, {
30
+ value: context = React__namespace.createContext({}),
31
+ enumerable: false,
32
+ writable: false,
33
+ configurable: true,
34
+ });
35
+ context.displayName = 'ApolloContext';
36
+ }
37
+ return context;
38
+ }
39
+
40
+ var ApolloConsumer = function (props) {
41
+ var ApolloContext = getApolloContext();
42
+ return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
43
+ __DEV__ ? globals.invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
44
+ 'Wrap the root component in an <ApolloProvider>.') : globals.invariant(context && context.client, 25);
45
+ return props.children(context.client);
46
+ }));
47
+ };
48
+
49
+ var ApolloProvider = function (_a) {
50
+ var client = _a.client, children = _a.children;
51
+ var ApolloContext = getApolloContext();
52
+ return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
53
+ if (context === void 0) { context = {}; }
54
+ if (client && context.client !== client) {
55
+ context = Object.assign({}, context, { client: client });
56
+ }
57
+ __DEV__ ? globals.invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
58
+ 'sure you pass in your client via the "client" prop.') : globals.invariant(context.client, 26);
59
+ return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
60
+ }));
61
+ };
62
+
63
+ exports.ApolloConsumer = ApolloConsumer;
64
+ exports.ApolloProvider = ApolloProvider;
65
+ exports.getApolloContext = getApolloContext;
66
+ exports.resetApolloContext = getApolloContext;
67
+ //# sourceMappingURL=context.cjs.map