@khanacademy/wonder-blocks-data 10.1.0 → 10.1.2

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 (180) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/components/data.d.ts +52 -0
  3. package/dist/components/data.js.flow +63 -0
  4. package/dist/components/gql-router.d.ts +24 -0
  5. package/dist/components/gql-router.js.flow +33 -0
  6. package/dist/components/intercept-context.d.ts +10 -0
  7. package/dist/components/intercept-context.js.flow +19 -0
  8. package/dist/components/intercept-requests.d.ts +42 -0
  9. package/dist/components/intercept-requests.js.flow +51 -0
  10. package/dist/components/track-data.d.ts +11 -0
  11. package/dist/components/track-data.js.flow +18 -0
  12. package/dist/es/index.js +184 -212
  13. package/dist/hooks/use-cached-effect.d.ts +70 -0
  14. package/dist/hooks/use-cached-effect.js.flow +85 -0
  15. package/dist/hooks/use-gql-router-context.d.ts +5 -0
  16. package/dist/hooks/use-gql-router-context.js.flow +15 -0
  17. package/dist/hooks/use-gql.d.ts +12 -0
  18. package/dist/hooks/use-gql.js.flow +29 -0
  19. package/dist/hooks/use-hydratable-effect.d.ts +102 -0
  20. package/dist/hooks/use-hydratable-effect.js.flow +125 -0
  21. package/dist/hooks/use-request-interception.d.ts +14 -0
  22. package/dist/hooks/use-request-interception.js.flow +25 -0
  23. package/dist/hooks/use-server-effect.d.ts +39 -0
  24. package/dist/hooks/use-server-effect.js.flow +51 -0
  25. package/dist/hooks/use-shared-cache.d.ts +32 -0
  26. package/dist/hooks/use-shared-cache.js.flow +43 -0
  27. package/dist/index.d.ts +24 -0
  28. package/dist/index.js +186 -217
  29. package/dist/index.js.flow +48 -2
  30. package/dist/util/data-error.d.ts +45 -0
  31. package/dist/util/data-error.js.flow +64 -0
  32. package/dist/util/get-gql-data-from-response.d.ts +4 -0
  33. package/dist/util/get-gql-data-from-response.js.flow +13 -0
  34. package/dist/util/get-gql-request-id.d.ts +5 -0
  35. package/dist/util/get-gql-request-id.js.flow +20 -0
  36. package/dist/util/gql-error.d.ts +28 -0
  37. package/dist/util/gql-error.js.flow +43 -0
  38. package/dist/util/gql-router-context.d.ts +3 -0
  39. package/dist/util/gql-router-context.js.flow +10 -0
  40. package/dist/util/gql-types.d.ts +34 -0
  41. package/dist/util/gql-types.js.flow +53 -0
  42. package/dist/util/graphql-document-node-parser.d.ts +18 -0
  43. package/dist/util/graphql-document-node-parser.js.flow +31 -0
  44. package/dist/util/graphql-types.d.ts +19 -0
  45. package/dist/util/graphql-types.js.flow +30 -0
  46. package/dist/util/hydration-cache-api.d.ts +17 -0
  47. package/dist/util/hydration-cache-api.js.flow +30 -0
  48. package/dist/util/merge-gql-context.d.ts +8 -0
  49. package/dist/util/merge-gql-context.js.flow +19 -0
  50. package/dist/util/purge-caches.d.ts +8 -0
  51. package/dist/util/purge-caches.js.flow +15 -0
  52. package/dist/util/request-api.d.ts +28 -0
  53. package/dist/util/request-api.js.flow +34 -0
  54. package/dist/util/request-fulfillment.d.ts +37 -0
  55. package/dist/util/request-fulfillment.js.flow +50 -0
  56. package/dist/util/request-tracking.d.ts +62 -0
  57. package/dist/util/request-tracking.js.flow +81 -0
  58. package/dist/util/result-from-cache-response.d.ts +5 -0
  59. package/dist/util/result-from-cache-response.js.flow +15 -0
  60. package/dist/util/scoped-in-memory-cache.d.ts +38 -0
  61. package/dist/util/scoped-in-memory-cache.js.flow +57 -0
  62. package/dist/util/serializable-in-memory-cache.d.ts +16 -0
  63. package/dist/util/serializable-in-memory-cache.js.flow +26 -0
  64. package/dist/util/ssr-cache.d.ts +51 -0
  65. package/dist/util/ssr-cache.js.flow +87 -0
  66. package/dist/util/status.d.ts +10 -0
  67. package/dist/util/status.js.flow +19 -0
  68. package/dist/util/to-gql-operation.d.ts +32 -0
  69. package/dist/util/to-gql-operation.js.flow +45 -0
  70. package/dist/util/types.d.ts +111 -0
  71. package/dist/util/types.js.flow +151 -0
  72. package/package.json +5 -6
  73. package/src/components/__tests__/{data.test.js → data.test.tsx} +42 -2
  74. package/src/components/__tests__/{gql-router.test.js → gql-router.test.tsx} +4 -5
  75. package/src/components/__tests__/{intercept-requests.test.js → intercept-requests.test.tsx} +2 -3
  76. package/src/components/__tests__/{track-data.test.js → track-data.test.tsx} +2 -3
  77. package/src/components/{data.js → data.ts} +11 -15
  78. package/src/components/{gql-router.js → gql-router.tsx} +12 -14
  79. package/src/components/{intercept-context.js → intercept-context.ts} +4 -3
  80. package/src/components/{intercept-requests.js → intercept-requests.tsx} +7 -8
  81. package/src/components/{track-data.js → track-data.tsx} +4 -5
  82. package/src/hooks/__tests__/{use-cached-effect.test.js → use-cached-effect.test.tsx} +55 -50
  83. package/src/hooks/__tests__/{use-gql-router-context.test.js → use-gql-router-context.test.tsx} +7 -7
  84. package/src/hooks/__tests__/{use-gql.test.js → use-gql.test.tsx} +20 -21
  85. package/src/hooks/__tests__/{use-hydratable-effect.test.js → use-hydratable-effect.test.ts} +42 -37
  86. package/src/hooks/__tests__/{use-request-interception.test.js → use-request-interception.test.tsx} +5 -3
  87. package/src/hooks/__tests__/{use-server-effect.test.js → use-server-effect.test.ts} +8 -2
  88. package/src/hooks/__tests__/{use-shared-cache.test.js → use-shared-cache.test.ts} +12 -12
  89. package/src/hooks/{use-cached-effect.js → use-cached-effect.ts} +27 -20
  90. package/src/hooks/{use-gql-router-context.js → use-gql-router-context.ts} +2 -3
  91. package/src/hooks/{use-gql.js → use-gql.ts} +5 -5
  92. package/src/hooks/{use-hydratable-effect.js → use-hydratable-effect.ts} +53 -58
  93. package/src/hooks/{use-request-interception.js → use-request-interception.ts} +4 -4
  94. package/src/hooks/{use-server-effect.js → use-server-effect.ts} +7 -9
  95. package/src/hooks/{use-shared-cache.js → use-shared-cache.ts} +13 -8
  96. package/src/{index.js → index.ts} +0 -1
  97. package/src/util/__tests__/{get-gql-data-from-response.test.js → get-gql-data-from-response.test.ts} +0 -1
  98. package/src/util/__tests__/{get-gql-request-id.test.js → get-gql-request-id.test.ts} +9 -11
  99. package/src/util/__tests__/{graphql-document-node-parser.test.js → graphql-document-node-parser.test.ts} +11 -12
  100. package/src/util/__tests__/{hydration-cache-api.test.js → hydration-cache-api.test.ts} +1 -2
  101. package/src/util/__tests__/{merge-gql-context.test.js → merge-gql-context.test.ts} +4 -5
  102. package/src/util/__tests__/{purge-caches.test.js → purge-caches.test.ts} +0 -1
  103. package/src/util/__tests__/{request-api.test.js → request-api.test.ts} +2 -2
  104. package/src/util/__tests__/{request-fulfillment.test.js → request-fulfillment.test.ts} +0 -1
  105. package/src/util/__tests__/{request-tracking.test.js → request-tracking.test.tsx} +13 -6
  106. package/src/util/__tests__/{result-from-cache-response.test.js → result-from-cache-response.test.ts} +2 -4
  107. package/src/util/__tests__/{scoped-in-memory-cache.test.js → scoped-in-memory-cache.test.ts} +4 -5
  108. package/src/util/__tests__/{serializable-in-memory-cache.test.js → serializable-in-memory-cache.test.ts} +7 -7
  109. package/src/util/__tests__/{ssr-cache.test.js → ssr-cache.test.ts} +3 -2
  110. package/src/util/__tests__/{to-gql-operation.test.js → to-gql-operation.test.ts} +2 -1
  111. package/src/util/{data-error.js → data-error.ts} +2 -3
  112. package/src/util/{get-gql-data-from-response.js → get-gql-data-from-response.ts} +1 -6
  113. package/src/util/{get-gql-request-id.js → get-gql-request-id.ts} +12 -16
  114. package/src/util/{gql-error.js → gql-error.ts} +2 -3
  115. package/src/util/gql-router-context.ts +6 -0
  116. package/src/util/{gql-types.js → gql-types.ts} +27 -23
  117. package/src/util/{graphql-document-node-parser.js → graphql-document-node-parser.ts} +6 -7
  118. package/src/util/graphql-types.ts +27 -0
  119. package/src/util/{hydration-cache-api.js → hydration-cache-api.ts} +4 -2
  120. package/src/util/{merge-gql-context.js → merge-gql-context.ts} +2 -2
  121. package/src/util/{purge-caches.js → purge-caches.ts} +0 -1
  122. package/src/util/{request-api.js → request-api.ts} +0 -1
  123. package/src/util/{request-fulfillment.js → request-fulfillment.ts} +13 -12
  124. package/src/util/{request-tracking.js → request-tracking.ts} +12 -13
  125. package/src/util/{result-from-cache-response.js → result-from-cache-response.ts} +3 -4
  126. package/src/util/{scoped-in-memory-cache.js → scoped-in-memory-cache.ts} +1 -2
  127. package/src/util/{serializable-in-memory-cache.js → serializable-in-memory-cache.ts} +2 -3
  128. package/src/util/{ssr-cache.js → ssr-cache.ts} +19 -18
  129. package/src/util/{status.js → status.ts} +4 -5
  130. package/src/util/{to-gql-operation.js → to-gql-operation.ts} +1 -2
  131. package/src/util/{types.js → types.ts} +39 -48
  132. package/tsconfig.json +11 -0
  133. package/tsconfig.tsbuildinfo +1 -0
  134. package/src/__docs__/_overview_.stories.mdx +0 -18
  135. package/src/__docs__/_overview_graphql.stories.mdx +0 -35
  136. package/src/__docs__/_overview_ssr_.stories.mdx +0 -185
  137. package/src/__docs__/_overview_testing_.stories.mdx +0 -123
  138. package/src/__docs__/exports.abort-inflight-requests.stories.mdx +0 -20
  139. package/src/__docs__/exports.data-error.stories.mdx +0 -23
  140. package/src/__docs__/exports.data-errors.stories.mdx +0 -23
  141. package/src/__docs__/exports.data.stories.mdx +0 -146
  142. package/src/__docs__/exports.fetch-tracked-requests.stories.mdx +0 -24
  143. package/src/__docs__/exports.get-gql-request-id.stories.mdx +0 -24
  144. package/src/__docs__/exports.gql-error.stories.mdx +0 -23
  145. package/src/__docs__/exports.gql-errors.stories.mdx +0 -20
  146. package/src/__docs__/exports.gql-router.stories.mdx +0 -29
  147. package/src/__docs__/exports.has-tracked-requests-to-be-fetched.stories.mdx +0 -20
  148. package/src/__docs__/exports.intercept-requests.stories.mdx +0 -69
  149. package/src/__docs__/exports.intialize-hydration-cache.stories.mdx +0 -29
  150. package/src/__docs__/exports.purge-caches.stories.mdx +0 -23
  151. package/src/__docs__/exports.purge-hydration-cache.stories.mdx +0 -24
  152. package/src/__docs__/exports.scoped-in-memory-cache.stories.mdx +0 -92
  153. package/src/__docs__/exports.serializable-in-memory-cache.stories.mdx +0 -112
  154. package/src/__docs__/exports.shared-cache.stories.mdx +0 -16
  155. package/src/__docs__/exports.status.stories.mdx +0 -31
  156. package/src/__docs__/exports.track-data.stories.mdx +0 -209
  157. package/src/__docs__/exports.use-cached-effect.stories.mdx +0 -44
  158. package/src/__docs__/exports.use-gql.stories.mdx +0 -41
  159. package/src/__docs__/exports.use-hydratable-effect.stories.mdx +0 -43
  160. package/src/__docs__/exports.use-server-effect.stories.mdx +0 -50
  161. package/src/__docs__/exports.use-shared-cache.stories.mdx +0 -30
  162. package/src/__docs__/exports.when-client-side.stories.mdx +0 -33
  163. package/src/__docs__/types.cached-response.stories.mdx +0 -29
  164. package/src/__docs__/types.error-options.stories.mdx +0 -21
  165. package/src/__docs__/types.fetch-policy.stories.mdx +0 -44
  166. package/src/__docs__/types.gql-context.stories.mdx +0 -20
  167. package/src/__docs__/types.gql-fetch-fn.stories.mdx +0 -24
  168. package/src/__docs__/types.gql-fetch-options.stories.mdx +0 -24
  169. package/src/__docs__/types.gql-operation-type.stories.mdx +0 -24
  170. package/src/__docs__/types.gql-operation.stories.mdx +0 -67
  171. package/src/__docs__/types.raw-scoped-cache.stories.mdx +0 -27
  172. package/src/__docs__/types.response-cache.stories.mdx +0 -33
  173. package/src/__docs__/types.result.stories.mdx +0 -39
  174. package/src/__docs__/types.scoped-cache.stories.mdx +0 -114
  175. package/src/__docs__/types.valid-cache-data.stories.mdx +0 -23
  176. package/src/util/gql-router-context.js +0 -6
  177. package/src/util/graphql-types.js +0 -30
  178. /package/src/hooks/__tests__/__snapshots__/{use-shared-cache.test.js.snap → use-shared-cache.test.ts.snap} +0 -0
  179. /package/src/util/__tests__/__snapshots__/{scoped-in-memory-cache.test.js.snap → scoped-in-memory-cache.test.ts.snap} +0 -0
  180. /package/src/util/__tests__/__snapshots__/{serializable-in-memory-cache.test.js.snap → serializable-in-memory-cache.test.ts.snap} +0 -0
package/dist/index.js CHANGED
@@ -4,11 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var wonderBlocksCore = require('@khanacademy/wonder-blocks-core');
6
6
  var wonderStuffCore = require('@khanacademy/wonder-stuff-core');
7
- var _extends = require('@babel/runtime/helpers/extends');
8
7
  var React = require('react');
9
8
 
10
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
-
12
9
  function _interopNamespace(e) {
13
10
  if (e && e.__esModule) return e;
14
11
  var n = Object.create(null);
@@ -27,7 +24,6 @@ function _interopNamespace(e) {
27
24
  return Object.freeze(n);
28
25
  }
29
26
 
30
- var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
31
27
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
32
28
 
33
29
  const FetchPolicy = {
@@ -37,6 +33,64 @@ const FetchPolicy = {
37
33
  NetworkOnly: "NetworkOnly"
38
34
  };
39
35
 
36
+ function _typeof(obj) {
37
+ "@babel/helpers - typeof";
38
+
39
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
40
+ return typeof obj;
41
+ } : function (obj) {
42
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
43
+ }, _typeof(obj);
44
+ }
45
+
46
+ function _toPrimitive(input, hint) {
47
+ if (_typeof(input) !== "object" || input === null) return input;
48
+ var prim = input[Symbol.toPrimitive];
49
+ if (prim !== undefined) {
50
+ var res = prim.call(input, hint || "default");
51
+ if (_typeof(res) !== "object") return res;
52
+ throw new TypeError("@@toPrimitive must return a primitive value.");
53
+ }
54
+ return (hint === "string" ? String : Number)(input);
55
+ }
56
+
57
+ function _toPropertyKey(arg) {
58
+ var key = _toPrimitive(arg, "string");
59
+ return _typeof(key) === "symbol" ? key : String(key);
60
+ }
61
+
62
+ function _defineProperties(target, props) {
63
+ for (var i = 0; i < props.length; i++) {
64
+ var descriptor = props[i];
65
+ descriptor.enumerable = descriptor.enumerable || false;
66
+ descriptor.configurable = true;
67
+ if ("value" in descriptor) descriptor.writable = true;
68
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
69
+ }
70
+ }
71
+ function _createClass(Constructor, protoProps, staticProps) {
72
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
73
+ if (staticProps) _defineProperties(Constructor, staticProps);
74
+ Object.defineProperty(Constructor, "prototype", {
75
+ writable: false
76
+ });
77
+ return Constructor;
78
+ }
79
+
80
+ function _setPrototypeOf(o, p) {
81
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
82
+ o.__proto__ = p;
83
+ return o;
84
+ };
85
+ return _setPrototypeOf(o, p);
86
+ }
87
+
88
+ function _inheritsLoose(subClass, superClass) {
89
+ subClass.prototype = Object.create(superClass.prototype);
90
+ subClass.prototype.constructor = subClass;
91
+ _setPrototypeOf(subClass, superClass);
92
+ }
93
+
40
94
  const DataErrors = Object.freeze({
41
95
  Unknown: "Unknown",
42
96
  Internal: "Internal",
@@ -46,116 +100,106 @@ const DataErrors = Object.freeze({
46
100
  Parse: "Parse",
47
101
  Hydrated: "Hydrated"
48
102
  });
49
- class DataError extends wonderStuffCore.KindError {
50
- constructor(message, kind, {
103
+ let DataError = function (_KindError) {
104
+ _inheritsLoose(DataError, _KindError);
105
+ function DataError(message, kind, {
51
106
  metadata,
52
107
  cause
53
108
  } = {}) {
54
- super(message, kind, {
109
+ return _KindError.call(this, message, kind, {
55
110
  metadata,
56
111
  cause,
57
112
  name: "Data"
58
- });
113
+ }) || this;
59
114
  }
115
+ return DataError;
116
+ }(wonderStuffCore.KindError);
60
117
 
61
- }
62
-
63
- class ScopedInMemoryCache {
64
- constructor(initialCache = {}) {
118
+ let ScopedInMemoryCache = function () {
119
+ function ScopedInMemoryCache(initialCache = {}) {
120
+ this._cache = void 0;
65
121
  this._cache = initialCache;
66
122
  }
67
-
68
- get inUse() {
69
- return Object.keys(this._cache).length > 0;
70
- }
71
-
72
- set(scope, id, value) {
123
+ var _proto = ScopedInMemoryCache.prototype;
124
+ _proto.set = function set(scope, id, value) {
73
125
  var _this$_cache$scope;
74
-
75
126
  if (!id || typeof id !== "string") {
76
127
  throw new DataError("id must be non-empty string", DataErrors.InvalidInput);
77
128
  }
78
-
79
129
  if (!scope || typeof scope !== "string") {
80
130
  throw new DataError("scope must be non-empty string", DataErrors.InvalidInput);
81
131
  }
82
-
83
132
  if (typeof value === "function") {
84
133
  throw new DataError("value must be a non-function value", DataErrors.InvalidInput);
85
134
  }
86
-
87
135
  this._cache[scope] = (_this$_cache$scope = this._cache[scope]) != null ? _this$_cache$scope : {};
88
136
  this._cache[scope][id] = value;
89
- }
90
-
91
- get(scope, id) {
137
+ };
138
+ _proto.get = function get(scope, id) {
92
139
  var _this$_cache$scope$id, _this$_cache$scope2;
93
-
94
140
  return (_this$_cache$scope$id = (_this$_cache$scope2 = this._cache[scope]) == null ? void 0 : _this$_cache$scope2[id]) != null ? _this$_cache$scope$id : null;
95
- }
96
-
97
- purge(scope, id) {
141
+ };
142
+ _proto.purge = function purge(scope, id) {
98
143
  var _this$_cache$scope3;
99
-
100
144
  if (!((_this$_cache$scope3 = this._cache[scope]) != null && _this$_cache$scope3[id])) {
101
145
  return;
102
146
  }
103
-
104
147
  delete this._cache[scope][id];
105
-
106
148
  if (Object.keys(this._cache[scope]).length === 0) {
107
149
  delete this._cache[scope];
108
150
  }
109
- }
110
-
111
- purgeScope(scope, predicate) {
151
+ };
152
+ _proto.purgeScope = function purgeScope(scope, predicate) {
112
153
  if (!this._cache[scope]) {
113
154
  return;
114
155
  }
115
-
116
156
  if (predicate == null) {
117
157
  delete this._cache[scope];
118
158
  return;
119
159
  }
120
-
121
160
  for (const key of Object.keys(this._cache[scope])) {
122
161
  if (predicate(key, this._cache[scope][key])) {
123
162
  delete this._cache[scope][key];
124
163
  }
125
164
  }
126
-
127
165
  if (Object.keys(this._cache[scope]).length === 0) {
128
166
  delete this._cache[scope];
129
167
  }
130
- }
131
-
132
- purgeAll(predicate) {
168
+ };
169
+ _proto.purgeAll = function purgeAll(predicate) {
133
170
  if (predicate == null) {
134
171
  this._cache = {};
135
172
  return;
136
173
  }
137
-
138
174
  for (const scope of Object.keys(this._cache)) {
139
175
  this.purgeScope(scope, (id, value) => predicate(scope, id, value));
140
176
  }
141
- }
142
-
143
- }
144
-
145
- class SerializableInMemoryCache extends ScopedInMemoryCache {
146
- constructor(initialCache = {}) {
177
+ };
178
+ _createClass(ScopedInMemoryCache, [{
179
+ key: "inUse",
180
+ get: function () {
181
+ return Object.keys(this._cache).length > 0;
182
+ }
183
+ }]);
184
+ return ScopedInMemoryCache;
185
+ }();
186
+
187
+ let SerializableInMemoryCache = function (_ScopedInMemoryCache) {
188
+ _inheritsLoose(SerializableInMemoryCache, _ScopedInMemoryCache);
189
+ function SerializableInMemoryCache(initialCache = {}) {
190
+ var _this;
147
191
  try {
148
- super(wonderStuffCore.clone(initialCache));
192
+ _this = _ScopedInMemoryCache.call(this, wonderStuffCore.clone(initialCache)) || this;
149
193
  } catch (e) {
150
194
  throw new DataError(`An error occurred trying to initialize from a response cache snapshot: ${e}`, DataErrors.InvalidInput);
151
195
  }
196
+ return _this;
152
197
  }
153
-
154
- set(scope, id, value) {
155
- super.set(scope, id, Object.freeze(wonderStuffCore.clone(value)));
156
- }
157
-
158
- clone() {
198
+ var _proto = SerializableInMemoryCache.prototype;
199
+ _proto.set = function set(scope, id, value) {
200
+ _ScopedInMemoryCache.prototype.set.call(this, scope, id, Object.freeze(wonderStuffCore.clone(value)));
201
+ };
202
+ _proto.clone = function clone() {
159
203
  try {
160
204
  return wonderStuffCore.clone(this._cache);
161
205
  } catch (e) {
@@ -163,79 +207,57 @@ class SerializableInMemoryCache extends ScopedInMemoryCache {
163
207
  cause: e
164
208
  });
165
209
  }
166
- }
167
-
168
- }
210
+ };
211
+ return SerializableInMemoryCache;
212
+ }(ScopedInMemoryCache);
169
213
 
170
214
  const DefaultScope$2 = "default";
171
-
172
215
  let _default$2;
173
-
174
- class SsrCache {
175
- static get Default() {
176
- if (!_default$2) {
177
- _default$2 = new SsrCache();
178
- }
179
-
180
- return _default$2;
181
- }
182
-
183
- constructor(hydrationCache = null, ssrOnlyCache = null) {
216
+ let SsrCache = function () {
217
+ function SsrCache(hydrationCache = null, ssrOnlyCache = null) {
218
+ this._hydrationCache = void 0;
219
+ this._ssrOnlyCache = void 0;
184
220
  this.initialize = source => {
185
221
  if (this._hydrationCache.inUse) {
186
222
  throw new Error("Cannot initialize data response cache more than once");
187
223
  }
188
-
189
224
  this._hydrationCache = new SerializableInMemoryCache({
190
225
  [DefaultScope$2]: source
191
226
  });
192
227
  };
193
-
194
228
  this.cacheData = (id, data, hydrate) => this._setCachedResponse(id, {
195
229
  data
196
230
  }, hydrate);
197
-
198
231
  this.cacheError = (id, error, hydrate) => {
199
232
  const errorMessage = typeof error === "string" ? error : error.message;
200
233
  return this._setCachedResponse(id, {
201
234
  error: errorMessage
202
235
  }, hydrate);
203
236
  };
204
-
205
237
  this.getEntry = id => {
206
238
  const ssrEntry = wonderBlocksCore.Server.isServerSide() ? this._ssrOnlyCache.get(DefaultScope$2, id) : null;
207
239
  const internalEntry = ssrEntry != null ? ssrEntry : this._hydrationCache.get(DefaultScope$2, id);
208
-
209
240
  if (!wonderBlocksCore.Server.isServerSide() && internalEntry != null) {
210
241
  this._hydrationCache.purge(DefaultScope$2, id);
211
242
  }
212
-
213
243
  return internalEntry;
214
244
  };
215
-
216
245
  this.purgeData = predicate => {
217
246
  const realPredicate = predicate ? (_, key, cachedEntry) => predicate(key, cachedEntry) : undefined;
218
-
219
247
  this._hydrationCache.purgeAll(realPredicate);
220
-
221
248
  this._ssrOnlyCache.purgeAll(realPredicate);
222
249
  };
223
-
224
250
  this.cloneHydratableData = () => {
225
251
  var _cache$DefaultScope;
226
-
227
252
  const cache = this._hydrationCache.clone();
228
-
229
253
  return (_cache$DefaultScope = cache[DefaultScope$2]) != null ? _cache$DefaultScope : {};
230
254
  };
231
-
232
255
  this._ssrOnlyCache = ssrOnlyCache || new SerializableInMemoryCache();
233
256
  this._hydrationCache = hydrationCache || new SerializableInMemoryCache();
234
257
  }
235
-
236
- _setCachedResponse(id, entry, hydrate) {
258
+ var _proto = SsrCache.prototype;
259
+ _proto._setCachedResponse = function _setCachedResponse(id, entry, hydrate) {
237
260
  const frozenEntry = Object.freeze(entry);
238
-
239
261
  if (wonderBlocksCore.Server.isServerSide()) {
240
262
  if (hydrate) {
241
263
  this._hydrationCache.set(DefaultScope$2, id, frozenEntry);
@@ -243,31 +265,50 @@ class SsrCache {
243
265
  this._ssrOnlyCache.set(DefaultScope$2, id, frozenEntry);
244
266
  }
245
267
  }
246
-
247
268
  return frozenEntry;
248
- }
249
-
250
- }
269
+ };
270
+ _createClass(SsrCache, null, [{
271
+ key: "Default",
272
+ get: function () {
273
+ if (!_default$2) {
274
+ _default$2 = new SsrCache();
275
+ }
276
+ return _default$2;
277
+ }
278
+ }]);
279
+ return SsrCache;
280
+ }();
251
281
 
252
282
  const initializeHydrationCache = source => SsrCache.Default.initialize(source);
253
283
  const purgeHydrationCache = predicate => SsrCache.Default.purgeData(predicate);
254
284
 
255
- let _default$1;
285
+ function _extends() {
286
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
287
+ for (var i = 1; i < arguments.length; i++) {
288
+ var source = arguments[i];
289
+ for (var key in source) {
290
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
291
+ target[key] = source[key];
292
+ }
293
+ }
294
+ }
295
+ return target;
296
+ };
297
+ return _extends.apply(this, arguments);
298
+ }
256
299
 
257
- class RequestFulfillment {
258
- constructor() {
300
+ let _default$1;
301
+ let RequestFulfillment = function () {
302
+ function RequestFulfillment() {
259
303
  this._requests = {};
260
-
261
304
  this.fulfill = (id, {
262
305
  handler,
263
306
  hydrate: _hydrate = true
264
307
  }) => {
265
308
  const inflight = this._requests[id];
266
-
267
309
  if (inflight) {
268
310
  return inflight;
269
311
  }
270
-
271
312
  const request = handler().then(data => ({
272
313
  status: "success",
273
314
  data
@@ -277,13 +318,11 @@ class RequestFulfillment {
277
318
  unexpectedError: error
278
319
  }
279
320
  }) : error;
280
-
281
321
  if (actualError.name === "AbortError") {
282
322
  return {
283
323
  status: "aborted"
284
324
  };
285
325
  }
286
-
287
326
  return {
288
327
  status: "error",
289
328
  error: actualError
@@ -294,42 +333,32 @@ class RequestFulfillment {
294
333
  this._requests[id] = request;
295
334
  return request;
296
335
  };
297
-
298
336
  this.abort = id => {
299
337
  delete this._requests[id];
300
338
  };
301
-
302
339
  this.abortAll = () => {
303
340
  Object.keys(this._requests).forEach(id => this.abort(id));
304
341
  };
305
342
  }
306
-
307
- static get Default() {
308
- if (!_default$1) {
309
- _default$1 = new RequestFulfillment();
343
+ _createClass(RequestFulfillment, null, [{
344
+ key: "Default",
345
+ get: function () {
346
+ if (!_default$1) {
347
+ _default$1 = new RequestFulfillment();
348
+ }
349
+ return _default$1;
310
350
  }
311
-
312
- return _default$1;
313
- }
314
-
315
- }
351
+ }]);
352
+ return RequestFulfillment;
353
+ }();
316
354
 
317
355
  const TrackerContext = React__namespace.createContext(null);
318
-
319
356
  let _default;
320
-
321
- class RequestTracker {
322
- static get Default() {
323
- if (!_default) {
324
- _default = new RequestTracker();
325
- }
326
-
327
- return _default;
328
- }
329
-
330
- constructor(responseCache = undefined) {
357
+ let RequestTracker = function () {
358
+ function RequestTracker(responseCache = undefined) {
331
359
  this._trackedRequests = {};
332
-
360
+ this._responseCache = void 0;
361
+ this._requestFulfillment = void 0;
333
362
  this.trackDataRequest = (id, handler, hydrate) => {
334
363
  if (this._trackedRequests[id] == null) {
335
364
  this._trackedRequests[id] = {
@@ -338,82 +367,78 @@ class RequestTracker {
338
367
  };
339
368
  }
340
369
  };
341
-
342
370
  this.reset = () => {
343
371
  this._trackedRequests = {};
344
372
  };
345
-
346
373
  this.fulfillTrackedRequests = () => {
347
374
  const promises = [];
348
375
  const {
349
376
  cacheData,
350
377
  cacheError
351
378
  } = this._responseCache;
352
-
353
379
  for (const requestKey of Object.keys(this._trackedRequests)) {
354
380
  const options = this._trackedRequests[requestKey];
355
-
356
381
  try {
357
- promises.push(this._requestFulfillment.fulfill(requestKey, _extends__default["default"]({}, options)).then(result => {
382
+ promises.push(this._requestFulfillment.fulfill(requestKey, _extends({}, options)).then(result => {
358
383
  switch (result.status) {
359
384
  case "success":
360
385
  cacheData(requestKey, result.data, options.hydrate);
361
386
  break;
362
-
363
387
  case "error":
364
388
  cacheError(requestKey, result.error, options.hydrate);
365
389
  break;
366
390
  }
367
-
368
391
  return;
369
392
  }));
370
393
  } catch (e) {
371
394
  promises.push(Promise.resolve(cacheError(requestKey, e, options.hydrate)));
372
395
  }
373
396
  }
374
-
375
397
  this.reset();
376
398
  return Promise.all(promises).then(() => this._responseCache.cloneHydratableData());
377
399
  };
378
-
379
400
  this._responseCache = responseCache || SsrCache.Default;
380
401
  this._requestFulfillment = new RequestFulfillment();
381
402
  }
382
-
383
- get hasUnfulfilledRequests() {
384
- return Object.keys(this._trackedRequests).length > 0;
385
- }
386
-
387
- }
403
+ _createClass(RequestTracker, [{
404
+ key: "hasUnfulfilledRequests",
405
+ get: function () {
406
+ return Object.keys(this._trackedRequests).length > 0;
407
+ }
408
+ }], [{
409
+ key: "Default",
410
+ get: function () {
411
+ if (!_default) {
412
+ _default = new RequestTracker();
413
+ }
414
+ return _default;
415
+ }
416
+ }]);
417
+ return RequestTracker;
418
+ }();
388
419
 
389
420
  const SSRCheck = () => {
390
421
  if (wonderBlocksCore.Server.isServerSide()) {
391
422
  return null;
392
423
  }
393
-
394
424
  if (process.env.NODE_ENV === "production") {
395
425
  return new DataError("No CSR tracking", DataErrors.NotAllowed);
396
426
  } else {
397
427
  return new DataError("Data requests are not tracked for fulfillment when when client-side", DataErrors.NotAllowed);
398
428
  }
399
429
  };
400
-
401
430
  const fetchTrackedRequests = () => {
402
431
  const ssrCheck = SSRCheck();
403
-
404
432
  if (ssrCheck != null) {
405
433
  return Promise.reject(ssrCheck);
406
434
  }
407
-
408
435
  return RequestTracker.Default.fulfillTrackedRequests();
409
436
  };
410
437
  const hasTrackedRequestsToBeFetched = () => {
411
438
  const ssrCheck = SSRCheck();
412
-
413
439
  if (ssrCheck != null) {
414
440
  throw ssrCheck;
415
441
  }
416
-
417
442
  return RequestTracker.Default.hasUnfulfilledRequests;
418
443
  };
419
444
  const abortInflightRequests = () => {
@@ -426,23 +451,18 @@ const useSharedCache = (id, scope, initialValue) => {
426
451
  if (!id || typeof id !== "string") {
427
452
  throw new DataError("id must be a non-empty string", DataErrors.InvalidInput);
428
453
  }
429
-
430
454
  if (!scope || typeof scope !== "string") {
431
455
  throw new DataError("scope must be a non-empty string", DataErrors.InvalidInput);
432
456
  }
433
-
434
457
  const cacheValue = React__namespace.useCallback(value => value == null ? cache$1.purge(scope, id) : cache$1.set(scope, id, value), [id, scope]);
435
458
  let currentValue = cache$1.get(scope, id);
436
-
437
459
  if (currentValue == null && initialValue !== undefined) {
438
460
  const value = typeof initialValue === "function" ? initialValue() : initialValue;
439
-
440
461
  if (value != null) {
441
462
  cacheValue(value);
442
463
  currentValue = value;
443
464
  }
444
465
  }
445
-
446
466
  return [currentValue, cacheValue];
447
467
  };
448
468
 
@@ -451,18 +471,22 @@ const purgeCaches = () => {
451
471
  purgeHydrationCache();
452
472
  };
453
473
 
454
- class TrackData extends React__namespace.Component {
455
- render() {
474
+ let TrackData = function (_React$Component) {
475
+ _inheritsLoose(TrackData, _React$Component);
476
+ function TrackData() {
477
+ return _React$Component.apply(this, arguments) || this;
478
+ }
479
+ var _proto = TrackData.prototype;
480
+ _proto.render = function render() {
456
481
  if (!wonderBlocksCore.Server.isServerSide()) {
457
482
  throw new Error("This component is not for use during client-side rendering");
458
483
  }
459
-
460
484
  return React__namespace.createElement(TrackerContext.Provider, {
461
485
  value: RequestTracker.Default.trackDataRequest
462
486
  }, this.props.children);
463
- }
464
-
465
- }
487
+ };
488
+ return TrackData;
489
+ }(React__namespace.Component);
466
490
 
467
491
  const loadingStatus = Object.freeze({
468
492
  status: "loading"
@@ -487,20 +511,16 @@ const resultFromCachedResponse = cacheEntry => {
487
511
  if (cacheEntry == null) {
488
512
  return null;
489
513
  }
490
-
491
514
  const {
492
515
  data,
493
516
  error
494
517
  } = cacheEntry;
495
-
496
518
  if (error != null) {
497
519
  return Status.error(new DataError(error, DataErrors.Hydrated));
498
520
  }
499
-
500
521
  if (data != null) {
501
522
  return Status.success(data);
502
523
  }
503
-
504
524
  return Status.aborted();
505
525
  };
506
526
 
@@ -513,7 +533,6 @@ const useRequestInterception = (requestId, handler) => {
513
533
  if (prev != null) {
514
534
  return prev;
515
535
  }
516
-
517
536
  return interceptor(requestId);
518
537
  }, null);
519
538
  return interceptResponse != null ? interceptResponse : handler();
@@ -529,18 +548,15 @@ const useServerEffect = (requestId, handler, options = {}) => {
529
548
  const interceptedHandler = useRequestInterception(requestId, handler);
530
549
  const cachedResult = SsrCache.Default.getEntry(requestId);
531
550
  const maybeTrack = React.useContext(TrackerContext);
532
-
533
551
  if (!skip && cachedResult == null && wonderBlocksCore.Server.isServerSide()) {
534
552
  maybeTrack == null ? void 0 : maybeTrack(requestId, interceptedHandler, hydrate);
535
553
  }
536
-
537
554
  return cachedResult == null ? null : resultFromCachedResponse(cachedResult);
538
555
  };
539
556
 
540
557
  const DefaultScope$1 = "useCachedEffect";
541
558
  const useCachedEffect = (requestId, handler, options = {}) => {
542
559
  var _ref;
543
-
544
560
  const {
545
561
  fetchPolicy = FetchPolicy.CacheBeforeNetwork,
546
562
  skip: hardSkip = false,
@@ -555,73 +571,57 @@ const useCachedEffect = (requestId, handler, options = {}) => {
555
571
  const currentRequestRef = React__namespace.useRef();
556
572
  const fetchRequest = React__namespace.useMemo(() => {
557
573
  var _currentRequestRef$cu;
558
-
559
574
  (_currentRequestRef$cu = currentRequestRef.current) == null ? void 0 : _currentRequestRef$cu.cancel();
560
575
  currentRequestRef.current = null;
561
576
  networkResultRef.current = null;
562
-
563
577
  const fetchFn = () => {
564
578
  var _currentRequestRef$cu2, _currentRequestRef$cu3;
565
-
566
579
  if (fetchPolicy === FetchPolicy.CacheOnly) {
567
580
  throw new DataError("Cannot fetch with CacheOnly policy", DataErrors.NotAllowed);
568
581
  }
569
-
570
582
  const request = RequestFulfillment.Default.fulfill(`${requestId}|${scope}`, {
571
583
  handler: interceptedHandler
572
584
  });
573
-
574
585
  if (request === ((_currentRequestRef$cu2 = currentRequestRef.current) == null ? void 0 : _currentRequestRef$cu2.request)) {
575
586
  return;
576
587
  }
577
-
578
588
  networkResultRef.current = null;
579
589
  (_currentRequestRef$cu3 = currentRequestRef.current) == null ? void 0 : _currentRequestRef$cu3.cancel();
580
590
  let cancel = false;
581
591
  request.then(result => {
582
592
  currentRequestRef.current = null;
583
-
584
593
  if (cancel) {
585
594
  return;
586
595
  }
587
-
588
596
  setMostRecentResult(result);
589
597
  networkResultRef.current = result;
590
-
591
598
  if (onResultChanged != null) {
592
599
  onResultChanged(result);
593
600
  } else {
594
601
  forceUpdate();
595
602
  }
596
-
597
603
  return;
598
604
  });
599
605
  currentRequestRef.current = {
600
606
  requestId,
601
607
  request,
602
-
603
608
  cancel() {
604
609
  cancel = true;
605
610
  RequestFulfillment.Default.abort(requestId);
606
611
  }
607
-
608
612
  };
609
613
  };
610
-
611
614
  return fetchFn;
612
615
  }, [requestId, onResultChanged, forceUpdate, setMostRecentResult, fetchPolicy]);
613
616
  const shouldFetch = React__namespace.useMemo(() => {
614
617
  if (hardSkip) {
615
618
  return false;
616
619
  }
617
-
618
620
  switch (fetchPolicy) {
619
621
  case FetchPolicy.CacheOnly:
620
622
  return false;
621
-
622
623
  case FetchPolicy.CacheBeforeNetwork:
623
624
  return mostRecentResult == null;
624
-
625
625
  case FetchPolicy.CacheAndNetwork:
626
626
  case FetchPolicy.NetworkOnly:
627
627
  return networkResultRef.current == null;
@@ -631,11 +631,9 @@ const useCachedEffect = (requestId, handler, options = {}) => {
631
631
  if (!shouldFetch) {
632
632
  return;
633
633
  }
634
-
635
634
  fetchRequest();
636
635
  return () => {
637
636
  var _currentRequestRef$cu4;
638
-
639
637
  (_currentRequestRef$cu4 = currentRequestRef.current) == null ? void 0 : _currentRequestRef$cu4.cancel();
640
638
  currentRequestRef.current = null;
641
639
  };
@@ -671,15 +669,12 @@ const useHydratableEffect = (requestId, handler, options = {}) => {
671
669
  case WhenClientSide.DoNotHydrate:
672
670
  case WhenClientSide.AlwaysExecute:
673
671
  return null;
674
-
675
672
  case WhenClientSide.ExecuteWhenNoResult:
676
673
  return serverResult;
677
-
678
674
  case WhenClientSide.ExecuteWhenNoSuccessResult:
679
675
  if ((serverResult == null ? void 0 : serverResult.status) === "success") {
680
676
  return serverResult;
681
677
  }
682
-
683
678
  return null;
684
679
  }
685
680
  }, [serverResult]);
@@ -721,11 +716,9 @@ const InterceptRequests = ({
721
716
 
722
717
  const toString = value => {
723
718
  var _JSON$stringify;
724
-
725
719
  if (typeof value === "string") {
726
720
  return value;
727
721
  }
728
-
729
722
  if (typeof value === "object" && value != null) {
730
723
  if (value instanceof Date) {
731
724
  return value.toISOString();
@@ -733,14 +726,11 @@ const toString = value => {
733
726
  return value.toString();
734
727
  }
735
728
  }
736
-
737
729
  return (_JSON$stringify = JSON.stringify(value)) != null ? _JSON$stringify : "";
738
730
  };
739
-
740
731
  const toStringifiedVariables = (acc, key, value) => {
741
732
  if (typeof value === "object" && value !== null) {
742
733
  const subValues = wonderStuffCore.entries(value);
743
-
744
734
  if (subValues.length !== 0) {
745
735
  return subValues.reduce((innerAcc, [i, v]) => {
746
736
  const subKey = `${key}.${i}`;
@@ -748,18 +738,15 @@ const toStringifiedVariables = (acc, key, value) => {
748
738
  }, acc);
749
739
  }
750
740
  }
751
-
752
741
  acc[key] = toString(value);
753
742
  return acc;
754
743
  };
755
-
756
744
  const getGqlRequestId = (operation, variables, context) => {
757
745
  const parts = [];
758
746
  const sortableContext = new URLSearchParams(context);
759
747
  sortableContext.sort();
760
748
  parts.push(sortableContext.toString());
761
749
  parts.push(operation.id);
762
-
763
750
  if (variables != null) {
764
751
  const stringifiedVariables = Object.keys(variables).reduce((acc, key) => {
765
752
  const value = variables[key];
@@ -769,7 +756,6 @@ const getGqlRequestId = (operation, variables, context) => {
769
756
  sortableVariables.sort();
770
757
  parts.push(sortableVariables.toString());
771
758
  }
772
-
773
759
  return parts.join("|");
774
760
  };
775
761
 
@@ -778,24 +764,24 @@ const GqlErrors = Object.freeze({
778
764
  BadResponse: "BadResponse",
779
765
  ErrorResult: "ErrorResult"
780
766
  });
781
- class GqlError extends wonderStuffCore.KindError {
782
- constructor(message, kind, {
767
+ let GqlError = function (_KindError) {
768
+ _inheritsLoose(GqlError, _KindError);
769
+ function GqlError(message, kind, {
783
770
  metadata,
784
771
  cause
785
772
  } = {}) {
786
- super(message, kind, {
773
+ return _KindError.call(this, message, kind, {
787
774
  metadata,
788
775
  cause,
789
776
  name: "Gql"
790
- });
777
+ }) || this;
791
778
  }
792
-
793
- }
779
+ return GqlError;
780
+ }(wonderStuffCore.KindError);
794
781
 
795
782
  const getGqlDataFromResponse = async response => {
796
783
  const bodyText = await response.text();
797
784
  let result;
798
-
799
785
  try {
800
786
  result = JSON.parse(bodyText);
801
787
  } catch (e) {
@@ -807,7 +793,6 @@ const getGqlDataFromResponse = async response => {
807
793
  cause: e
808
794
  });
809
795
  }
810
-
811
796
  if (response.status >= 300) {
812
797
  throw new DataError("Response unsuccessful", DataErrors.Network, {
813
798
  metadata: {
@@ -816,7 +801,6 @@ const getGqlDataFromResponse = async response => {
816
801
  }
817
802
  });
818
803
  }
819
-
820
804
  if (!Object.prototype.hasOwnProperty.call(result, "data") && !Object.prototype.hasOwnProperty.call(result, "errors")) {
821
805
  throw new GqlError("Server response missing", GqlErrors.BadResponse, {
822
806
  metadata: {
@@ -825,7 +809,6 @@ const getGqlDataFromResponse = async response => {
825
809
  }
826
810
  });
827
811
  }
828
-
829
812
  if (result.errors != null && Array.isArray(result.errors) && result.errors.length > 0) {
830
813
  throw new GqlError("GraphQL errors", GqlErrors.ErrorResult, {
831
814
  metadata: {
@@ -834,7 +817,6 @@ const getGqlDataFromResponse = async response => {
834
817
  }
835
818
  });
836
819
  }
837
-
838
820
  return result.data;
839
821
  };
840
822
 
@@ -845,13 +827,10 @@ const DocumentTypes = Object.freeze({
845
827
  const cache = new Map();
846
828
  function graphQLDocumentNodeParser(document) {
847
829
  var _definition$name;
848
-
849
830
  const cached = cache.get(document);
850
-
851
831
  if (cached) {
852
832
  return cached;
853
833
  }
854
-
855
834
  if (!(document != null && document.kind)) {
856
835
  if (process.env.NODE_ENV === "production") {
857
836
  throw new DataError("Bad DocumentNode", DataErrors.InvalidInput);
@@ -859,12 +838,10 @@ function graphQLDocumentNodeParser(document) {
859
838
  throw new DataError(`Argument of ${JSON.stringify(document)} passed to parser was not a valid GraphQL ` + `DocumentNode. You may need to use 'graphql-tag' or another method ` + `to convert your operation into a document`, DataErrors.InvalidInput);
860
839
  }
861
840
  }
862
-
863
841
  const fragments = document.definitions.filter(x => x.kind === "FragmentDefinition");
864
842
  const queries = document.definitions.filter(x => x.kind === "OperationDefinition" && x.operation === "query");
865
843
  const mutations = document.definitions.filter(x => x.kind === "OperationDefinition" && x.operation === "mutation");
866
844
  const subscriptions = document.definitions.filter(x => x.kind === "OperationDefinition" && x.operation === "subscription");
867
-
868
845
  if (fragments.length && !queries.length && !mutations.length) {
869
846
  if (process.env.NODE_ENV === "production") {
870
847
  throw new DataError("Fragment only", DataErrors.InvalidInput);
@@ -872,7 +849,6 @@ function graphQLDocumentNodeParser(document) {
872
849
  throw new DataError(`Passing only a fragment to 'graphql' is not supported. ` + `You must include a query or mutation as well`, DataErrors.InvalidInput);
873
850
  }
874
851
  }
875
-
876
852
  if (subscriptions.length) {
877
853
  if (process.env.NODE_ENV === "production") {
878
854
  throw new DataError("No subscriptions", DataErrors.InvalidInput);
@@ -880,7 +856,6 @@ function graphQLDocumentNodeParser(document) {
880
856
  throw new DataError(`We do not support subscriptions. ` + `${JSON.stringify(document)} had ${subscriptions.length} subscriptions`, DataErrors.InvalidInput);
881
857
  }
882
858
  }
883
-
884
859
  if (queries.length + mutations.length > 1) {
885
860
  if (process.env.NODE_ENV === "production") {
886
861
  throw new DataError("Too many ops", DataErrors.InvalidInput);
@@ -888,7 +863,6 @@ function graphQLDocumentNodeParser(document) {
888
863
  throw new DataError(`We only support one query or mutation per component. ` + `${JSON.stringify(document)} had ${queries.length} queries and ` + `${mutations.length} mutations. `, DataErrors.InvalidInput);
889
864
  }
890
865
  }
891
-
892
866
  const type = queries.length ? DocumentTypes.query : DocumentTypes.mutation;
893
867
  const definitions = queries.length ? queries : mutations;
894
868
  const definition = definitions[0];
@@ -937,18 +911,15 @@ const mergeGqlContext = (defaultContext, overrides) => {
937
911
  acc[key] = overrides[key];
938
912
  }
939
913
  }
940
-
941
914
  return acc;
942
- }, _extends__default["default"]({}, defaultContext));
915
+ }, _extends({}, defaultContext));
943
916
  };
944
917
 
945
918
  const useGqlRouterContext = (contextOverrides = {}) => {
946
919
  const gqlRouterContext = React.useContext(GqlRouterContext);
947
-
948
920
  if (gqlRouterContext == null) {
949
921
  throw new GqlError("No GqlRouter", GqlErrors.Internal);
950
922
  }
951
-
952
923
  const {
953
924
  fetch,
954
925
  defaultContext
@@ -958,11 +929,9 @@ const useGqlRouterContext = (contextOverrides = {}) => {
958
929
  const refKeys = Object.keys(contextRef.current);
959
930
  const mergedKeys = Object.keys(mergedContext);
960
931
  const shouldWeUpdateRef = refKeys.length !== mergedKeys.length || mergedKeys.every(key => contextRef.current[key] !== mergedContext[key]);
961
-
962
932
  if (shouldWeUpdateRef) {
963
933
  contextRef.current = mergedContext;
964
934
  }
965
-
966
935
  const finalContext = contextRef.current;
967
936
  const finalRouterContext = React.useMemo(() => ({
968
937
  fetch,