@apollo/client 4.3.3 → 4.3.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 (99) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/__cjs/cache/core/cache.cjs +1 -1
  3. package/__cjs/cache/core/cache.cjs.map +1 -1
  4. package/__cjs/cache/core/cache.d.cts +4 -1
  5. package/__cjs/cache/core/types/Cache.d.cts +5 -0
  6. package/__cjs/cache/inmemory/entityStore.cjs +4 -4
  7. package/__cjs/cache/inmemory/helpers.cjs +5 -0
  8. package/__cjs/cache/inmemory/helpers.cjs.map +1 -1
  9. package/__cjs/cache/inmemory/inMemoryCache.cjs +17 -6
  10. package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
  11. package/__cjs/cache/inmemory/inMemoryCache.d.cts +3 -1
  12. package/__cjs/cache/inmemory/key-extractor.cjs +15 -3
  13. package/__cjs/cache/inmemory/key-extractor.cjs.map +1 -1
  14. package/__cjs/cache/inmemory/policies.cjs +21 -5
  15. package/__cjs/cache/inmemory/policies.cjs.map +1 -1
  16. package/__cjs/cache/inmemory/policies.d.cts +2 -0
  17. package/__cjs/cache/inmemory/readFromStore.cjs +28 -10
  18. package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
  19. package/__cjs/cache/inmemory/types.d.cts +7 -2
  20. package/__cjs/cache/inmemory/writeToStore.cjs +32 -16
  21. package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
  22. package/__cjs/cache/inmemory/writeToStore.d.cts +5 -2
  23. package/__cjs/core/ApolloClient.cjs +14 -14
  24. package/__cjs/core/ObservableQuery.cjs +8 -8
  25. package/__cjs/core/QueryInfo.cjs +22 -33
  26. package/__cjs/core/QueryInfo.cjs.map +1 -1
  27. package/__cjs/core/QueryInfo.d.cts +1 -1
  28. package/__cjs/core/QueryManager.cjs +22 -15
  29. package/__cjs/core/QueryManager.cjs.map +1 -1
  30. package/__cjs/core/RefetchEventManager.cjs +3 -3
  31. package/__cjs/incremental/handlers/defer20220824.cjs +15 -2
  32. package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
  33. package/__cjs/incremental/handlers/defer20220824.d.cts +5 -1
  34. package/__cjs/incremental/handlers/graphql17Alpha9.cjs +58 -14
  35. package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +1 -1
  36. package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +23 -12
  37. package/__cjs/incremental/handlers/notImplemented.cjs +1 -1
  38. package/__cjs/incremental/types.d.cts +19 -1
  39. package/__cjs/invariantErrorCodes.cjs +64 -58
  40. package/__cjs/react/hooks/useFragment.cjs.map +1 -1
  41. package/__cjs/react/hooks/useFragment.d.cts +42 -43
  42. package/__cjs/utilities/internal/index.cjs.map +1 -1
  43. package/__cjs/utilities/internal/index.d.cts +0 -1
  44. package/__cjs/version.cjs +1 -1
  45. package/cache/core/cache.d.ts +4 -1
  46. package/cache/core/cache.js +1 -1
  47. package/cache/core/cache.js.map +1 -1
  48. package/cache/core/types/Cache.d.ts +5 -0
  49. package/cache/core/types/Cache.js.map +1 -1
  50. package/cache/inmemory/entityStore.js +4 -4
  51. package/cache/inmemory/helpers.js +5 -0
  52. package/cache/inmemory/helpers.js.map +1 -1
  53. package/cache/inmemory/inMemoryCache.d.ts +3 -1
  54. package/cache/inmemory/inMemoryCache.js +17 -6
  55. package/cache/inmemory/inMemoryCache.js.map +1 -1
  56. package/cache/inmemory/key-extractor.js +15 -3
  57. package/cache/inmemory/key-extractor.js.map +1 -1
  58. package/cache/inmemory/policies.d.ts +2 -0
  59. package/cache/inmemory/policies.js +22 -6
  60. package/cache/inmemory/policies.js.map +1 -1
  61. package/cache/inmemory/readFromStore.js +28 -10
  62. package/cache/inmemory/readFromStore.js.map +1 -1
  63. package/cache/inmemory/types.d.ts +7 -2
  64. package/cache/inmemory/types.js.map +1 -1
  65. package/cache/inmemory/writeToStore.d.ts +5 -2
  66. package/cache/inmemory/writeToStore.js +33 -17
  67. package/cache/inmemory/writeToStore.js.map +1 -1
  68. package/core/ApolloClient.js +14 -14
  69. package/core/ObservableQuery.js +8 -8
  70. package/core/QueryInfo.d.ts +1 -1
  71. package/core/QueryInfo.js +23 -34
  72. package/core/QueryInfo.js.map +1 -1
  73. package/core/QueryManager.js +22 -15
  74. package/core/QueryManager.js.map +1 -1
  75. package/core/RefetchEventManager.js +3 -3
  76. package/incremental/handlers/defer20220824.d.ts +5 -1
  77. package/incremental/handlers/defer20220824.js +15 -2
  78. package/incremental/handlers/defer20220824.js.map +1 -1
  79. package/incremental/handlers/graphql17Alpha9.d.ts +23 -12
  80. package/incremental/handlers/graphql17Alpha9.js +58 -14
  81. package/incremental/handlers/graphql17Alpha9.js.map +1 -1
  82. package/incremental/handlers/notImplemented.js +1 -1
  83. package/incremental/types.d.ts +19 -1
  84. package/incremental/types.js.map +1 -1
  85. package/invariantErrorCodes.js +64 -58
  86. package/package.json +1 -1
  87. package/react/hooks/useFragment.d.ts +42 -43
  88. package/react/hooks/useFragment.js.map +1 -1
  89. package/react/hooks-compiled/useFragment.d.ts +42 -43
  90. package/react/hooks-compiled/useFragment.js.map +1 -1
  91. package/utilities/internal/index.d.ts +0 -1
  92. package/utilities/internal/index.js.map +1 -1
  93. package/version.js +1 -1
  94. package/__cjs/utilities/internal/types/DeferInfo.cjs +0 -3
  95. package/__cjs/utilities/internal/types/DeferInfo.cjs.map +0 -1
  96. package/__cjs/utilities/internal/types/DeferInfo.d.cts +0 -10
  97. package/utilities/internal/types/DeferInfo.d.ts +0 -10
  98. package/utilities/internal/types/DeferInfo.js +0 -2
  99. package/utilities/internal/types/DeferInfo.js.map +0 -1
@@ -73,7 +73,8 @@ export class InMemoryCache extends ApolloCache {
73
73
  // currently using a data store that can track cache dependencies.
74
74
  const store = c.optimistic ? this.optimisticData : this.data;
75
75
  if (supportsResultCaching(store)) {
76
- const { optimistic, id, variables } = c;
76
+ const { optimistic, id } = c;
77
+ const variables = this.serializeVariables(c.query, c.variables);
77
78
  return store.makeCacheKey(c.query,
78
79
  // Different watches can have the same query, optimistic
79
80
  // status, rootId, and variables, but if their callbacks are
@@ -129,7 +130,7 @@ export class InMemoryCache extends ApolloCache {
129
130
  return this.serializeInputArray(value, variableTypes, match[1], coordinate);
130
131
  }
131
132
  else if (__DEV__) {
132
- __DEV__ && invariant.warn(112, coordinate, scalarType, unwrapScalarType(scalarType));
133
+ __DEV__ && invariant.warn(113, coordinate, scalarType, unwrapScalarType(scalarType));
133
134
  }
134
135
  }
135
136
  const scalar = this.getScalar(unwrapScalarType(scalarType));
@@ -271,10 +272,7 @@ export class InMemoryCache extends ApolloCache {
271
272
  recallCache(this);
272
273
  }
273
274
  this.watches.add(watch);
274
- if (watch.immediate) {
275
- this.maybeBroadcastWatch(watch);
276
- }
277
- return () => {
275
+ const removeWatch = () => {
278
276
  // Once we remove the last watch from this.watches, cache.broadcastWatches
279
277
  // no longer does anything, so we preemptively tell the reactive variable
280
278
  // system to exclude this cache from future broadcasts.
@@ -286,6 +284,19 @@ export class InMemoryCache extends ApolloCache {
286
284
  // leaks involving the closure of watch.callback.
287
285
  this.maybeBroadcastWatch.forget(watch);
288
286
  };
287
+ if (watch.immediate) {
288
+ try {
289
+ this.maybeBroadcastWatch(watch);
290
+ }
291
+ catch (error) {
292
+ // The caller never receives removeWatch when this throws, so without
293
+ // this the watch would stay registered with nothing able to remove it,
294
+ // and every later broadcast would run into the same failing read.
295
+ removeWatch();
296
+ throw error;
297
+ }
298
+ }
299
+ return removeWatch;
289
300
  }
290
301
  gc(options) {
291
302
  canonicalStringify.reset();