@apollo/client 4.0.4 → 4.1.0-alpha.0

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 (70) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/__cjs/cache/core/cache.cjs +1 -1
  3. package/__cjs/cache/inmemory/entityStore.cjs +3 -3
  4. package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
  5. package/__cjs/cache/inmemory/policies.cjs +4 -4
  6. package/__cjs/cache/inmemory/policies.cjs.map +1 -1
  7. package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
  8. package/__cjs/cache/inmemory/writeToStore.cjs +5 -5
  9. package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
  10. package/__cjs/core/ApolloClient.cjs +12 -12
  11. package/__cjs/core/ObservableQuery.cjs +157 -106
  12. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  13. package/__cjs/core/ObservableQuery.d.cts +1 -0
  14. package/__cjs/core/QueryManager.cjs +12 -12
  15. package/__cjs/incremental/handlers/defer20220824.cjs +20 -9
  16. package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
  17. package/__cjs/incremental/handlers/defer20220824.d.cts +14 -5
  18. package/__cjs/incremental/handlers/graphql17Alpha9.cjs +181 -0
  19. package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +1 -0
  20. package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +97 -0
  21. package/__cjs/incremental/handlers/notImplemented.cjs +1 -1
  22. package/__cjs/incremental/index.cjs +3 -1
  23. package/__cjs/incremental/index.cjs.map +1 -1
  24. package/__cjs/incremental/index.d.cts +1 -0
  25. package/__cjs/invariantErrorCodes.cjs +51 -45
  26. package/__cjs/react/internal/cache/QueryReference.cjs +16 -0
  27. package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
  28. package/__cjs/react/internal/cache/QueryReference.d.cts +1 -0
  29. package/__cjs/utilities/internal/DeepMerger.cjs +10 -1
  30. package/__cjs/utilities/internal/DeepMerger.cjs.map +1 -1
  31. package/__cjs/utilities/internal/DeepMerger.d.cts +14 -2
  32. package/__cjs/utilities/internal/getStoreKeyName.cjs +1 -0
  33. package/__cjs/utilities/internal/getStoreKeyName.cjs.map +1 -1
  34. package/__cjs/version.cjs +1 -1
  35. package/__cjs/version.cjs.map +1 -1
  36. package/cache/core/cache.js +1 -1
  37. package/cache/inmemory/entityStore.js +3 -3
  38. package/cache/inmemory/key-extractor.js +1 -1
  39. package/cache/inmemory/policies.js +4 -4
  40. package/cache/inmemory/policies.js.map +1 -1
  41. package/cache/inmemory/readFromStore.js +2 -2
  42. package/cache/inmemory/writeToStore.js +5 -5
  43. package/cache/inmemory/writeToStore.js.map +1 -1
  44. package/core/ApolloClient.js +12 -12
  45. package/core/ObservableQuery.d.ts +1 -0
  46. package/core/ObservableQuery.js +159 -108
  47. package/core/ObservableQuery.js.map +1 -1
  48. package/core/QueryManager.js +12 -12
  49. package/incremental/handlers/defer20220824.d.ts +14 -5
  50. package/incremental/handlers/defer20220824.js +20 -9
  51. package/incremental/handlers/defer20220824.js.map +1 -1
  52. package/incremental/handlers/graphql17Alpha9.d.ts +97 -0
  53. package/incremental/handlers/graphql17Alpha9.js +177 -0
  54. package/incremental/handlers/graphql17Alpha9.js.map +1 -0
  55. package/incremental/handlers/notImplemented.js +1 -1
  56. package/incremental/index.d.ts +1 -0
  57. package/incremental/index.js +3 -2
  58. package/incremental/index.js.map +1 -1
  59. package/invariantErrorCodes.js +51 -45
  60. package/package.json +1 -1
  61. package/react/internal/cache/QueryReference.d.ts +1 -0
  62. package/react/internal/cache/QueryReference.js +16 -0
  63. package/react/internal/cache/QueryReference.js.map +1 -1
  64. package/utilities/internal/DeepMerger.d.ts +14 -2
  65. package/utilities/internal/DeepMerger.js +10 -1
  66. package/utilities/internal/DeepMerger.js.map +1 -1
  67. package/utilities/internal/getStoreKeyName.js +1 -0
  68. package/utilities/internal/getStoreKeyName.js.map +1 -1
  69. package/version.js +1 -1
  70. package/version.js.map +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @apollo/client
2
2
 
3
+ ## 4.1.0-alpha.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#12923](https://github.com/apollographql/apollo-client/pull/12923) [`2aa31c7`](https://github.com/apollographql/apollo-client/commit/2aa31c718155e88814551afb14fd7a0035acc57d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where deferred payloads that reteurned arrays with fewer items than the original cached array would retain items from the cached array. This change includes `@stream` arrays where stream arrays replace the cached arrays.
8
+
9
+ - [#12926](https://github.com/apollographql/apollo-client/pull/12926) [`c7fba99`](https://github.com/apollographql/apollo-client/commit/c7fba99e16da522fdbc35b9c16cdb8df0dda4c2c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Support the newer incremental delivery format for the `@defer` directive implemented in `graphql@17.0.0-alpha.9`. Import the `GraphQL17Alpha9Handler` to use the newer incremental delivery format with `@defer`.
10
+
11
+ ```ts
12
+ import { GraphQL17Alpha9Handler } from "@apollo/client/incremental";
13
+
14
+ const client = new ApolloClient({
15
+ // ...
16
+ incrementalHandler: new GraphQL17Alpha9Handler(),
17
+ });
18
+ ```
19
+
20
+ > [!NOTE]
21
+ > In order to use the `GraphQL17Alpha9Handler`, the GraphQL server MUST implement the newer incremental delivery format. You may see errors or unusual behavior if you use the wrong handler. If you are using Apollo Router, continue to use the `Defer20220824Handler` because Apollo Router does not yet support the newer incremental delivery format.
22
+
23
+ - [#12918](https://github.com/apollographql/apollo-client/pull/12918) [`562e219`](https://github.com/apollographql/apollo-client/commit/562e2191a4b38e05edb3da9074e2958db3c7b6b9) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add support for the `@stream` directive on both the `Defer20220824Handler` and the `GraphQL17Alpha2Handler`.
24
+
25
+ > [!NOTE]
26
+ > The implementations of `@stream` differ in the delivery of incremental results between the different GraphQL spec versions. If you upgrading from the older format to the newer format, expect the timing of some incremental results to change.
27
+
28
+ ### Patch Changes
29
+
30
+ - [#12925](https://github.com/apollographql/apollo-client/pull/12925) [`f538a83`](https://github.com/apollographql/apollo-client/commit/f538a83621e1d110286c056dd8e91611dfd9a1d3) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where calling `fetchMore` with `@defer` or `@stream` would not rerender incremental results as they were streamed.
31
+
32
+ - [#12923](https://github.com/apollographql/apollo-client/pull/12923) [`01cace0`](https://github.com/apollographql/apollo-client/commit/01cace0a6d4faf79e8a4188b93c7d13c4b26d6d4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Improve the cache data loss warning message when `existing` or `incoming` is an array.
33
+
3
34
  ## 4.0.4
4
35
 
5
36
  ### Patch Changes
@@ -95,7 +95,7 @@ class ApolloCache {
95
95
  if (environment_1.__DEV__) {
96
96
  const actualFragmentName = fragmentName || (0, internal_1.getFragmentDefinition)(fragment).name.value;
97
97
  if (!id) {
98
- __DEV__ && invariant_1.invariant.warn(109, actualFragmentName);
98
+ __DEV__ && invariant_1.invariant.warn(110, actualFragmentName);
99
99
  }
100
100
  }
101
101
  const diffOptions = {
@@ -82,7 +82,7 @@ class EntityStore {
82
82
  // then there are no fields to be merged, so we're done.
83
83
  if (!incoming)
84
84
  return;
85
- (0, invariant_1.invariant)(typeof dataId === "string", 95);
85
+ (0, invariant_1.invariant)(typeof dataId === "string", 96);
86
86
  const merged = new internal_1.DeepMerger(storeObjectReconciler).merge(existing, incoming);
87
87
  // Even if merged === existing, existing may have come from a lower
88
88
  // layer, so we always need to set this.data[dataId] on this level.
@@ -182,7 +182,7 @@ class EntityStore {
182
182
  if (environment_1.__DEV__) {
183
183
  const checkReference = (ref) => {
184
184
  if (this.lookup(ref.__ref) === undefined) {
185
- __DEV__ && invariant_1.invariant.warn(96, ref);
185
+ __DEV__ && invariant_1.invariant.warn(97, ref);
186
186
  return true;
187
187
  }
188
188
  };
@@ -211,7 +211,7 @@ class EntityStore {
211
211
  }
212
212
  }
213
213
  if (seenReference && someNonReference !== undefined) {
214
- __DEV__ && invariant_1.invariant.warn(97, someNonReference);
214
+ __DEV__ && invariant_1.invariant.warn(98, someNonReference);
215
215
  break;
216
216
  }
217
217
  }
@@ -41,7 +41,7 @@ function keyFieldsFnFromSpecifier(specifier) {
41
41
  // context.readField for this extraction.
42
42
  extracted = extractKeyPath(object, schemaKeyPath, extractKey);
43
43
  }
44
- (0, invariant_1.invariant)(extracted !== void 0, 98, schemaKeyPath.join("."), object);
44
+ (0, invariant_1.invariant)(extracted !== void 0, 99, schemaKeyPath.join("."), object);
45
45
  return extracted;
46
46
  }));
47
47
  return `${context.typename}:${JSON.stringify(keyObject)}`;
@@ -212,7 +212,7 @@ class Policies {
212
212
  const rootId = "ROOT_" + which.toUpperCase();
213
213
  const old = this.rootTypenamesById[rootId];
214
214
  if (typename !== old) {
215
- (0, invariant_1.invariant)(!old || old === which, 99, which);
215
+ (0, invariant_1.invariant)(!old || old === which, 100, which);
216
216
  // First, delete any old __typename associated with this rootId from
217
217
  // rootIdsByTypename.
218
218
  if (old)
@@ -355,7 +355,7 @@ class Policies {
355
355
  if (supertypeSet.has(supertype)) {
356
356
  if (!typenameSupertypeSet.has(supertype)) {
357
357
  if (checkingFuzzySubtypes) {
358
- __DEV__ && invariant_1.invariant.warn(100, typename, supertype);
358
+ __DEV__ && invariant_1.invariant.warn(101, typename, supertype);
359
359
  }
360
360
  // Record positive results for faster future lookup.
361
361
  // Unfortunately, we cannot safely cache negative results,
@@ -566,7 +566,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
566
566
  }
567
567
  }
568
568
  if (environment_1.__DEV__ && options.from === void 0) {
569
- __DEV__ && invariant_1.invariant.warn(101, (0, internal_1.stringifyForDisplay)(Array.from(readFieldArgs)));
569
+ __DEV__ && invariant_1.invariant.warn(102, (0, internal_1.stringifyForDisplay)(Array.from(readFieldArgs)));
570
570
  }
571
571
  if (void 0 === options.variables) {
572
572
  options.variables = variables;
@@ -576,7 +576,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
576
576
  function makeMergeObjectsFunction(store) {
577
577
  return function mergeObjects(existing, incoming) {
578
578
  if ((0, internal_1.isArray)(existing) || (0, internal_1.isArray)(incoming)) {
579
- throw (0, invariant_1.newInvariantError)(102);
579
+ throw (0, invariant_1.newInvariantError)(103);
580
580
  }
581
581
  // These dynamic checks are necessary because the parameters of a
582
582
  // custom merge function can easily have the any type, so the type