@apollo/client 3.9.5 → 3.9.7

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 (64) hide show
  1. package/CHANGELOG.md +35 -19
  2. package/apollo-client.cjs +106 -78
  3. package/apollo-client.cjs.map +1 -1
  4. package/apollo-client.min.cjs +1 -1
  5. package/core/LocalState.js +13 -13
  6. package/core/LocalState.js.map +1 -1
  7. package/core/QueryManager.js +7 -7
  8. package/core/QueryManager.js.map +1 -1
  9. package/core/core.cjs +21 -21
  10. package/core/core.cjs.map +1 -1
  11. package/core/core.cjs.native.js +21 -21
  12. package/dev/dev.cjs +1 -1
  13. package/dev/dev.cjs.map +1 -1
  14. package/dev/dev.cjs.native.js +1 -1
  15. package/link/http/http.cjs +11 -8
  16. package/link/http/http.cjs.map +1 -1
  17. package/link/http/http.cjs.native.js +11 -8
  18. package/link/http/parseAndCheckHttpResponse.js +11 -8
  19. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  20. package/package.json +22 -22
  21. package/react/hooks/hooks.cjs +67 -44
  22. package/react/hooks/hooks.cjs.map +1 -1
  23. package/react/hooks/hooks.cjs.native.js +67 -44
  24. package/react/hooks/internal/index.d.ts +1 -0
  25. package/react/hooks/internal/index.js +1 -0
  26. package/react/hooks/internal/index.js.map +1 -1
  27. package/react/hooks/internal/useRenderGuard.js +1 -1
  28. package/react/hooks/internal/useRenderGuard.js.map +1 -1
  29. package/react/hooks/internal/wrapHook.d.ts +56 -0
  30. package/react/hooks/internal/wrapHook.js +43 -0
  31. package/react/hooks/internal/wrapHook.js.map +1 -0
  32. package/react/hooks/useBackgroundQuery.js +4 -0
  33. package/react/hooks/useBackgroundQuery.js.map +1 -1
  34. package/react/hooks/useFragment.js +4 -1
  35. package/react/hooks/useFragment.js.map +1 -1
  36. package/react/hooks/useQuery.js +4 -0
  37. package/react/hooks/useQuery.js.map +1 -1
  38. package/react/hooks/useReadQuery.js +4 -1
  39. package/react/hooks/useReadQuery.js.map +1 -1
  40. package/react/hooks/useSuspenseQuery.js +4 -1
  41. package/react/hooks/useSuspenseQuery.js.map +1 -1
  42. package/react/internal/cache/QueryReference.js +17 -5
  43. package/react/internal/cache/QueryReference.js.map +1 -1
  44. package/react/internal/index.d.ts +1 -0
  45. package/react/internal/index.js.map +1 -1
  46. package/react/internal/internal.cjs +7 -5
  47. package/react/internal/internal.cjs.map +1 -1
  48. package/react/internal/internal.cjs.native.js +7 -5
  49. package/testing/internal/ObservableStream.js +3 -3
  50. package/testing/internal/ObservableStream.js.map +1 -1
  51. package/testing/internal/profile/profile.js +6 -6
  52. package/testing/internal/profile/profile.js.map +1 -1
  53. package/testing/internal/scenarios/index.js +1 -1
  54. package/testing/internal/scenarios/index.js.map +1 -1
  55. package/utilities/globals/globals.cjs +1 -1
  56. package/utilities/globals/globals.cjs.map +1 -1
  57. package/utilities/globals/globals.cjs.native.js +1 -1
  58. package/utilities/subscriptions/relay/relay.cjs +11 -8
  59. package/utilities/subscriptions/relay/relay.cjs.map +1 -1
  60. package/utilities/subscriptions/relay/relay.cjs.native.js +11 -8
  61. package/utilities/subscriptions/urql/urql.cjs +11 -8
  62. package/utilities/subscriptions/urql/urql.cjs.map +1 -1
  63. package/utilities/subscriptions/urql/urql.cjs.native.js +11 -8
  64. package/version.js +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @apollo/client
2
2
 
3
+ ## 3.9.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#11659](https://github.com/apollographql/apollo-client/pull/11659) [`652a61e`](https://github.com/apollographql/apollo-client/commit/652a61e96db0f0e27d0a22fafae1df388f3fdf36) Thanks [@phryneas](https://github.com/phryneas)! - Make `useRenderGuard` more resilient to changes in React internals.
8
+
9
+ - [#11594](https://github.com/apollographql/apollo-client/pull/11594) [`50b1097`](https://github.com/apollographql/apollo-client/commit/50b10970ca0efa290ae415ef801650327a89ab8e) Thanks [@alessbell](https://github.com/alessbell)! - Adds a fix for multipart subscriptions that terminate with payload: null
10
+
11
+ ## 3.9.6
12
+
13
+ ### Patch Changes
14
+
15
+ - [#11617](https://github.com/apollographql/apollo-client/pull/11617) [`f1d8bc4`](https://github.com/apollographql/apollo-client/commit/f1d8bc40c3d8e39340f721f4f1c3fd0ed77b8a6b) Thanks [@phryneas](https://github.com/phryneas)! - Allow Apollo Client instance to intercept hook functionality
16
+
17
+ - [#11638](https://github.com/apollographql/apollo-client/pull/11638) [`bf93ada`](https://github.com/apollographql/apollo-client/commit/bf93adaa0321b573db0ea8fc3a5c364e1fdfeef3) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix issue where calling `fetchMore` from a suspense-enabled hook inside `startTransition` caused an unnecessary rerender.
18
+
3
19
  ## 3.9.5
4
20
 
5
21
  ### Patch Changes
@@ -127,6 +143,25 @@
127
143
 
128
144
  - [#11412](https://github.com/apollographql/apollo-client/pull/11412) [`58db5c3`](https://github.com/apollographql/apollo-client/commit/58db5c3295b88162f91019f0898f6baa4b9cced6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add the ability to start preloading a query outside React to begin fetching as early as possible. Call `createQueryPreloader` to create a `preloadQuery` function which can be called to start fetching a query. This returns a `queryRef` which is passed to `useReadQuery` and suspended until the query is done fetching.
129
145
 
146
+ ```tsx
147
+ const preloadQuery = createQueryPreloader(client);
148
+ const queryRef = preloadQuery(QUERY, { variables, ...otherOptions });
149
+
150
+ function App() {
151
+ return {
152
+ <Suspense fallback={<div>Loading</div>}>
153
+ <MyQuery />
154
+ </Suspense>
155
+ }
156
+ }
157
+
158
+ function MyQuery() {
159
+ const { data } = useReadQuery(queryRef);
160
+
161
+ // do something with data
162
+ }
163
+ ```
164
+
130
165
  #### Testing utility improvements
131
166
 
132
167
  - [#11178](https://github.com/apollographql/apollo-client/pull/11178) [`4d64a6f`](https://github.com/apollographql/apollo-client/commit/4d64a6fa2ad5abe6f7f172c164f5e1fc2cb89829) Thanks [@sebakerckhof](https://github.com/sebakerckhof)! - Support re-using of mocks in the MockedProvider
@@ -193,25 +228,6 @@
193
228
 
194
229
  The `IGNORE` sentinel can be destructured from the second parameter in the callback function signature passed to `optimisticResponse`.
195
230
 
196
- ```tsx
197
- const preloadQuery = createQueryPreloader(client);
198
- const queryRef = preloadQuery(QUERY, { variables, ...otherOptions });
199
-
200
- function App() {
201
- return {
202
- <Suspense fallback={<div>Loading</div>}>
203
- <MyQuery />
204
- </Suspense>
205
- }
206
- }
207
-
208
- function MyQuery() {
209
- const { data } = useReadQuery(queryRef);
210
-
211
- // do something with data
212
- }
213
- ```
214
-
215
231
  #### Network adapters for multipart subscriptions usage with Relay and urql
216
232
 
217
233
  - [#11301](https://github.com/apollographql/apollo-client/pull/11301) [`46ab032`](https://github.com/apollographql/apollo-client/commit/46ab032af83a01f184bfcce5edba4b55dbb2962a) Thanks [@alessbell](https://github.com/alessbell)! - Add multipart subscription network adapters for Relay and urql
package/apollo-client.cjs CHANGED
@@ -31,7 +31,7 @@ function _interopNamespace(e) {
31
31
  var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
32
32
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
33
33
 
34
- var version = "3.9.5";
34
+ var version = "3.9.7";
35
35
 
36
36
  function maybe(thunk) {
37
37
  try {
@@ -1938,10 +1938,10 @@ var ApolloError = (function (_super) {
1938
1938
 
1939
1939
  var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
1940
1940
  function readMultipartBody(response, nextValue) {
1941
- var _a;
1942
1941
  return tslib.__awaiter(this, void 0, void 0, function () {
1943
- var decoder, contentType, delimiter, boundaryVal, boundary, buffer, iterator, running, _b, value, done, chunk, searchFrom, bi, message, i, headers, contentType_1, body, result, next;
1944
- var _c, _d;
1942
+ var decoder, contentType, delimiter, boundaryVal, boundary, buffer, iterator, running, _a, value, done, chunk, searchFrom, bi, message, i, headers, contentType_1, body, result, next;
1943
+ var _b, _c;
1944
+ var _d;
1945
1945
  return tslib.__generator(this, function (_e) {
1946
1946
  switch (_e.label) {
1947
1947
  case 0:
@@ -1949,7 +1949,7 @@ function readMultipartBody(response, nextValue) {
1949
1949
  throw new Error("TextDecoder must be defined in the environment: please import a polyfill.");
1950
1950
  }
1951
1951
  decoder = new TextDecoder("utf-8");
1952
- contentType = (_a = response.headers) === null || _a === void 0 ? void 0 : _a.get("content-type");
1952
+ contentType = (_d = response.headers) === null || _d === void 0 ? void 0 : _d.get("content-type");
1953
1953
  delimiter = "boundary=";
1954
1954
  boundaryVal = (contentType === null || contentType === void 0 ? void 0 : contentType.includes(delimiter)) ?
1955
1955
  contentType === null || contentType === void 0 ? void 0 : contentType.substring((contentType === null || contentType === void 0 ? void 0 : contentType.indexOf(delimiter)) + delimiter.length).replace(/['"]/g, "").replace(/\;(.*)/gm, "").trim()
@@ -1963,7 +1963,7 @@ function readMultipartBody(response, nextValue) {
1963
1963
  if (!running) return [3 , 3];
1964
1964
  return [4 , iterator.next()];
1965
1965
  case 2:
1966
- _b = _e.sent(), value = _b.value, done = _b.done;
1966
+ _a = _e.sent(), value = _a.value, done = _a.done;
1967
1967
  chunk = typeof value === "string" ? value : decoder.decode(value);
1968
1968
  searchFrom = buffer.length - boundary.length + 1;
1969
1969
  running = !done;
@@ -1971,10 +1971,10 @@ function readMultipartBody(response, nextValue) {
1971
1971
  bi = buffer.indexOf(boundary, searchFrom);
1972
1972
  while (bi > -1) {
1973
1973
  message = void 0;
1974
- _c = [
1974
+ _b = [
1975
1975
  buffer.slice(0, bi),
1976
1976
  buffer.slice(bi + boundary.length),
1977
- ], message = _c[0], buffer = _c[1];
1977
+ ], message = _b[0], buffer = _b[1];
1978
1978
  i = message.indexOf("\r\n\r\n");
1979
1979
  headers = parseHeaders(message.slice(0, i));
1980
1980
  contentType_1 = headers["content-type"];
@@ -1993,10 +1993,13 @@ function readMultipartBody(response, nextValue) {
1993
1993
  if (isApolloPayloadResult(result)) {
1994
1994
  next = {};
1995
1995
  if ("payload" in result) {
1996
+ if (Object.keys(result).length === 1 && result.payload === null) {
1997
+ return [2 ];
1998
+ }
1996
1999
  next = tslib.__assign({}, result.payload);
1997
2000
  }
1998
2001
  if ("errors" in result) {
1999
- next = tslib.__assign(tslib.__assign({}, next), { extensions: tslib.__assign(tslib.__assign({}, ("extensions" in next ? next.extensions : null)), (_d = {}, _d[PROTOCOL_ERRORS_SYMBOL] = result.errors, _d)) });
2002
+ next = tslib.__assign(tslib.__assign({}, next), { extensions: tslib.__assign(tslib.__assign({}, ("extensions" in next ? next.extensions : null)), (_c = {}, _c[PROTOCOL_ERRORS_SYMBOL] = result.errors, _c)) });
2000
2003
  }
2001
2004
  nextValue(next);
2002
2005
  }
@@ -5436,9 +5439,9 @@ var LocalState = (function () {
5436
5439
  return this.resolvers || {};
5437
5440
  };
5438
5441
  LocalState.prototype.runResolvers = function (_a) {
5439
- var document = _a.document, remoteResult = _a.remoteResult, context = _a.context, variables = _a.variables, _b = _a.onlyRunForcedResolvers, onlyRunForcedResolvers = _b === void 0 ? false : _b;
5440
- return tslib.__awaiter(this, void 0, void 0, function () {
5441
- return tslib.__generator(this, function (_c) {
5442
+ return tslib.__awaiter(this, arguments, void 0, function (_b) {
5443
+ var document = _b.document, remoteResult = _b.remoteResult, context = _b.context, variables = _b.variables, _c = _b.onlyRunForcedResolvers, onlyRunForcedResolvers = _c === void 0 ? false : _c;
5444
+ return tslib.__generator(this, function (_d) {
5442
5445
  if (document) {
5443
5446
  return [2 , this.resolveDocument(document, remoteResult.data, context, variables, this.fragmentMatcher, onlyRunForcedResolvers).then(function (localResult) { return (tslib.__assign(tslib.__assign({}, remoteResult), { data: localResult.result })); })];
5444
5447
  }
@@ -5470,10 +5473,10 @@ var LocalState = (function () {
5470
5473
  return cache.identify(obj);
5471
5474
  } });
5472
5475
  };
5473
- LocalState.prototype.addExportedVariables = function (document, variables, context) {
5474
- if (variables === void 0) { variables = {}; }
5475
- if (context === void 0) { context = {}; }
5476
- return tslib.__awaiter(this, void 0, void 0, function () {
5476
+ LocalState.prototype.addExportedVariables = function (document_1) {
5477
+ return tslib.__awaiter(this, arguments, void 0, function (document, variables, context) {
5478
+ if (variables === void 0) { variables = {}; }
5479
+ if (context === void 0) { context = {}; }
5477
5480
  return tslib.__generator(this, function (_a) {
5478
5481
  if (document) {
5479
5482
  return [2 , this.resolveDocument(document, this.buildRootValueFromCache(document, variables) || {}, this.prepareContext(context), variables).then(function (data) { return (tslib.__assign(tslib.__assign({}, variables), data.exportedVariables)); })];
@@ -5510,13 +5513,13 @@ var LocalState = (function () {
5510
5513
  optimistic: false,
5511
5514
  }).result;
5512
5515
  };
5513
- LocalState.prototype.resolveDocument = function (document, rootValue, context, variables, fragmentMatcher, onlyRunForcedResolvers) {
5514
- if (context === void 0) { context = {}; }
5515
- if (variables === void 0) { variables = {}; }
5516
- if (fragmentMatcher === void 0) { fragmentMatcher = function () { return true; }; }
5517
- if (onlyRunForcedResolvers === void 0) { onlyRunForcedResolvers = false; }
5518
- return tslib.__awaiter(this, void 0, void 0, function () {
5516
+ LocalState.prototype.resolveDocument = function (document_1, rootValue_1) {
5517
+ return tslib.__awaiter(this, arguments, void 0, function (document, rootValue, context, variables, fragmentMatcher, onlyRunForcedResolvers) {
5519
5518
  var mainDefinition, fragments, fragmentMap, selectionsToResolve, definitionOperation, defaultOperationType, _a, cache, client, execContext, isClientFieldDescendant;
5519
+ if (context === void 0) { context = {}; }
5520
+ if (variables === void 0) { variables = {}; }
5521
+ if (fragmentMatcher === void 0) { fragmentMatcher = function () { return true; }; }
5522
+ if (onlyRunForcedResolvers === void 0) { onlyRunForcedResolvers = false; }
5520
5523
  return tslib.__generator(this, function (_b) {
5521
5524
  mainDefinition = getMainDefinition(document);
5522
5525
  fragments = getFragmentDefinitions(document);
@@ -6044,12 +6047,12 @@ var QueryManager = (function () {
6044
6047
  this.fetchCancelFns.clear();
6045
6048
  };
6046
6049
  QueryManager.prototype.mutate = function (_a) {
6047
- var _b, _c;
6048
- var mutation = _a.mutation, variables = _a.variables, optimisticResponse = _a.optimisticResponse, updateQueries = _a.updateQueries, _d = _a.refetchQueries, refetchQueries = _d === void 0 ? [] : _d, _e = _a.awaitRefetchQueries, awaitRefetchQueries = _e === void 0 ? false : _e, updateWithProxyFn = _a.update, onQueryUpdated = _a.onQueryUpdated, _f = _a.fetchPolicy, fetchPolicy = _f === void 0 ? ((_b = this.defaultOptions.mutate) === null || _b === void 0 ? void 0 : _b.fetchPolicy) || "network-only" : _f, _g = _a.errorPolicy, errorPolicy = _g === void 0 ? ((_c = this.defaultOptions.mutate) === null || _c === void 0 ? void 0 : _c.errorPolicy) || "none" : _g, keepRootFields = _a.keepRootFields, context = _a.context;
6049
- return tslib.__awaiter(this, void 0, void 0, function () {
6050
+ return tslib.__awaiter(this, arguments, void 0, function (_b) {
6050
6051
  var mutationId, hasClientExports, mutationStoreValue, isOptimistic, self;
6051
- return tslib.__generator(this, function (_h) {
6052
- switch (_h.label) {
6052
+ var _c, _d;
6053
+ var mutation = _b.mutation, variables = _b.variables, optimisticResponse = _b.optimisticResponse, updateQueries = _b.updateQueries, _e = _b.refetchQueries, refetchQueries = _e === void 0 ? [] : _e, _f = _b.awaitRefetchQueries, awaitRefetchQueries = _f === void 0 ? false : _f, updateWithProxyFn = _b.update, onQueryUpdated = _b.onQueryUpdated, _g = _b.fetchPolicy, fetchPolicy = _g === void 0 ? ((_c = this.defaultOptions.mutate) === null || _c === void 0 ? void 0 : _c.fetchPolicy) || "network-only" : _g, _h = _b.errorPolicy, errorPolicy = _h === void 0 ? ((_d = this.defaultOptions.mutate) === null || _d === void 0 ? void 0 : _d.errorPolicy) || "none" : _h, keepRootFields = _b.keepRootFields, context = _b.context;
6054
+ return tslib.__generator(this, function (_j) {
6055
+ switch (_j.label) {
6053
6056
  case 0:
6054
6057
  invariant(mutation, 26);
6055
6058
  invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 27);
@@ -6060,8 +6063,8 @@ var QueryManager = (function () {
6060
6063
  if (!hasClientExports) return [3 , 2];
6061
6064
  return [4 , this.localState.addExportedVariables(mutation, variables, context)];
6062
6065
  case 1:
6063
- variables = (_h.sent());
6064
- _h.label = 2;
6066
+ variables = (_j.sent());
6067
+ _j.label = 2;
6065
6068
  case 2:
6066
6069
  mutationStoreValue = this.mutationStore &&
6067
6070
  (this.mutationStore[mutationId] = {
@@ -7371,9 +7374,64 @@ function verifyDocumentType(document, type) {
7371
7374
  );
7372
7375
  }
7373
7376
 
7377
+ function useDeepMemo(memoFn, deps) {
7378
+ var ref = React__namespace.useRef();
7379
+ if (!ref.current || !equal.equal(ref.current.deps, deps)) {
7380
+ ref.current = { value: memoFn(), deps: deps };
7381
+ }
7382
+ return ref.current.value;
7383
+ }
7384
+
7385
+ function getRenderDispatcher() {
7386
+ var _a, _b;
7387
+ return (_b = (_a = React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _a === void 0 ? void 0 : _a.ReactCurrentDispatcher) === null || _b === void 0 ? void 0 : _b.current;
7388
+ }
7389
+ var RenderDispatcher = null;
7390
+ function useRenderGuard() {
7391
+ RenderDispatcher = getRenderDispatcher();
7392
+ return React__namespace.useCallback(function () {
7393
+ return (RenderDispatcher != null && RenderDispatcher === getRenderDispatcher());
7394
+ }, []);
7395
+ }
7396
+
7397
+ var INIT = {};
7398
+ function useLazyRef(getInitialValue) {
7399
+ var ref = React__namespace.useRef(INIT);
7400
+ if (ref.current === INIT) {
7401
+ ref.current = getInitialValue();
7402
+ }
7403
+ return ref;
7404
+ }
7405
+
7406
+ var useKey = "use";
7407
+ var realHook = React__namespace[useKey];
7408
+ var __use = realHook ||
7409
+ function __use(promise) {
7410
+ var statefulPromise = wrapPromiseWithState(promise);
7411
+ switch (statefulPromise.status) {
7412
+ case "pending":
7413
+ throw statefulPromise;
7414
+ case "rejected":
7415
+ throw statefulPromise.reason;
7416
+ case "fulfilled":
7417
+ return statefulPromise.value;
7418
+ }
7419
+ };
7420
+
7421
+ var wrapperSymbol = Symbol.for("apollo.hook.wrappers");
7422
+ function wrapHook(hookName, useHook, clientOrObsQuery) {
7423
+ var queryManager = clientOrObsQuery["queryManager"];
7424
+ var wrappers = queryManager && queryManager[wrapperSymbol];
7425
+ var wrapper = wrappers && wrappers[hookName];
7426
+ return wrapper ? wrapper(useHook) : useHook;
7427
+ }
7428
+
7374
7429
  var hasOwnProperty = Object.prototype.hasOwnProperty;
7375
7430
  function useQuery(query, options) {
7376
7431
  if (options === void 0) { options = Object.create(null); }
7432
+ return wrapHook("useQuery", _useQuery, useApolloClient(options && options.client))(query, options);
7433
+ }
7434
+ function _useQuery(query, options) {
7377
7435
  return useInternalState(useApolloClient(options.client), query).useQuery(options);
7378
7436
  }
7379
7437
  function useInternalState(client, query) {
@@ -7978,51 +8036,10 @@ function useReactiveVar(rv) {
7978
8036
  }, [rv]), rv, rv);
7979
8037
  }
7980
8038
 
7981
- function useDeepMemo(memoFn, deps) {
7982
- var ref = React__namespace.useRef();
7983
- if (!ref.current || !equal.equal(ref.current.deps, deps)) {
7984
- ref.current = { value: memoFn(), deps: deps };
7985
- }
7986
- return ref.current.value;
7987
- }
7988
-
7989
- function getRenderDispatcher() {
7990
- var _a, _b;
7991
- return (_b = (_a = React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _a === void 0 ? void 0 : _a.ReactCurrentDispatcher) === null || _b === void 0 ? void 0 : _b.current;
7992
- }
7993
- var RenderDispatcher = null;
7994
- function useRenderGuard() {
7995
- RenderDispatcher = getRenderDispatcher();
7996
- return React__namespace.useCallback(function () {
7997
- return (RenderDispatcher !== null && RenderDispatcher === getRenderDispatcher());
7998
- }, []);
7999
- }
8000
-
8001
- var INIT = {};
8002
- function useLazyRef(getInitialValue) {
8003
- var ref = React__namespace.useRef(INIT);
8004
- if (ref.current === INIT) {
8005
- ref.current = getInitialValue();
8006
- }
8007
- return ref;
8008
- }
8009
-
8010
- var useKey = "use";
8011
- var realHook = React__namespace[useKey];
8012
- var __use = realHook ||
8013
- function __use(promise) {
8014
- var statefulPromise = wrapPromiseWithState(promise);
8015
- switch (statefulPromise.status) {
8016
- case "pending":
8017
- throw statefulPromise;
8018
- case "rejected":
8019
- throw statefulPromise.reason;
8020
- case "fulfilled":
8021
- return statefulPromise.value;
8022
- }
8023
- };
8024
-
8025
8039
  function useFragment(options) {
8040
+ return wrapHook("useFragment", _useFragment, useApolloClient(options.client))(options);
8041
+ }
8042
+ function _useFragment(options) {
8026
8043
  var cache = useApolloClient(options.client).cache;
8027
8044
  var diffOptions = useDeepMemo(function () {
8028
8045
  var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a, rest = tslib.__rest(options, ["fragment", "fragmentName", "from", "optimistic"]);
@@ -8259,11 +8276,13 @@ var InternalQueryReference = (function () {
8259
8276
  this.promise.catch(function () { });
8260
8277
  returnedPromise
8261
8278
  .then(function (result) {
8262
- var _a;
8263
- if (_this.promise.status === "pending") {
8264
- _this.result = result;
8265
- (_a = _this.resolve) === null || _a === void 0 ? void 0 : _a.call(_this, result);
8266
- }
8279
+ setTimeout(function () {
8280
+ var _a;
8281
+ if (_this.promise.status === "pending") {
8282
+ _this.result = result;
8283
+ (_a = _this.resolve) === null || _a === void 0 ? void 0 : _a.call(_this, result);
8284
+ }
8285
+ });
8267
8286
  })
8268
8287
  .catch(function () { });
8269
8288
  return returnedPromise;
@@ -8330,6 +8349,9 @@ var skipToken = Symbol.for("apollo.skipToken");
8330
8349
 
8331
8350
  function useSuspenseQuery(query, options) {
8332
8351
  if (options === void 0) { options = Object.create(null); }
8352
+ return wrapHook("useSuspenseQuery", _useSuspenseQuery, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options);
8353
+ }
8354
+ function _useSuspenseQuery(query, options) {
8333
8355
  var client = useApolloClient(options.client);
8334
8356
  var suspenseCache = getSuspenseCache(client);
8335
8357
  var watchQueryOptions = useWatchQueryOptions({
@@ -8447,6 +8469,9 @@ function useWatchQueryOptions(_a) {
8447
8469
 
8448
8470
  function useBackgroundQuery(query, options) {
8449
8471
  if (options === void 0) { options = Object.create(null); }
8472
+ return wrapHook("useBackgroundQuery", _useBackgroundQuery, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options);
8473
+ }
8474
+ function _useBackgroundQuery(query, options) {
8450
8475
  var client = useApolloClient(options.client);
8451
8476
  var suspenseCache = getSuspenseCache(client);
8452
8477
  var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
@@ -8561,6 +8586,9 @@ function useQueryRefHandlers(queryRef) {
8561
8586
  }
8562
8587
 
8563
8588
  function useReadQuery(queryRef) {
8589
+ return wrapHook("useReadQuery", _useReadQuery, unwrapQueryRef(queryRef)["observable"])(queryRef);
8590
+ }
8591
+ function _useReadQuery(queryRef) {
8564
8592
  var internalQueryRef = React__namespace.useMemo(function () { return unwrapQueryRef(queryRef); }, [queryRef]);
8565
8593
  var getPromise = React__namespace.useCallback(function () { return getWrappedPromise(queryRef); }, [queryRef]);
8566
8594
  if (internalQueryRef.disposed) {