@apollo/client 4.2.9 → 4.2.11

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 (85) hide show
  1. package/CHANGELOG.md +20 -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/readFromStore.cjs +2 -2
  7. package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
  8. package/__cjs/core/ApolloClient.cjs.map +1 -1
  9. package/__cjs/core/ApolloClient.d.cts +44 -10
  10. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  11. package/__cjs/core/ObservableQuery.d.cts +12 -1
  12. package/__cjs/core/QueryInfo.cjs +24 -1
  13. package/__cjs/core/QueryInfo.cjs.map +1 -1
  14. package/__cjs/core/QueryManager.cjs +12 -12
  15. package/__cjs/core/RefetchEventManager.cjs +3 -3
  16. package/__cjs/invariantErrorCodes.cjs +49 -30
  17. package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
  18. package/__cjs/react/hooks/useBackgroundQuery.d.cts +100 -47
  19. package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
  20. package/__cjs/react/hooks/useLazyQuery.d.cts +26 -20
  21. package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
  22. package/__cjs/react/hooks/useLoadableQuery.d.cts +23 -15
  23. package/__cjs/react/hooks/useMutation.cjs.map +1 -1
  24. package/__cjs/react/hooks/useMutation.d.cts +10 -7
  25. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  26. package/__cjs/react/hooks/useQuery.d.cts +74 -32
  27. package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
  28. package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
  29. package/__cjs/react/hooks/useSuspenseQuery.d.cts +83 -34
  30. package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
  31. package/__cjs/react/internal/types.d.cts +14 -3
  32. package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
  33. package/__cjs/react/query-preloader/createQueryPreloader.d.cts +20 -5
  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/readFromStore.js +2 -2
  41. package/cache/inmemory/writeToStore.js +4 -4
  42. package/core/ApolloClient.d.ts +44 -10
  43. package/core/ApolloClient.js.map +1 -1
  44. package/core/ObservableQuery.d.ts +12 -1
  45. package/core/ObservableQuery.js.map +1 -1
  46. package/core/QueryInfo.js +19 -0
  47. package/core/QueryInfo.js.map +1 -1
  48. package/core/QueryManager.js +12 -12
  49. package/core/QueryManager.js.map +1 -1
  50. package/core/RefetchEventManager.js +3 -3
  51. package/invariantErrorCodes.js +49 -30
  52. package/package.json +1 -1
  53. package/react/hooks/useBackgroundQuery.d.ts +100 -47
  54. package/react/hooks/useBackgroundQuery.js.map +1 -1
  55. package/react/hooks/useLazyQuery.d.ts +26 -20
  56. package/react/hooks/useLazyQuery.js.map +1 -1
  57. package/react/hooks/useLoadableQuery.d.ts +23 -15
  58. package/react/hooks/useLoadableQuery.js.map +1 -1
  59. package/react/hooks/useMutation.d.ts +10 -7
  60. package/react/hooks/useMutation.js.map +1 -1
  61. package/react/hooks/useQuery.d.ts +74 -32
  62. package/react/hooks/useQuery.js.map +1 -1
  63. package/react/hooks/useQueryRefHandlers.js.map +1 -1
  64. package/react/hooks/useSuspenseQuery.d.ts +83 -34
  65. package/react/hooks/useSuspenseQuery.js.map +1 -1
  66. package/react/hooks-compiled/useBackgroundQuery.d.ts +100 -47
  67. package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
  68. package/react/hooks-compiled/useLazyQuery.d.ts +26 -20
  69. package/react/hooks-compiled/useLazyQuery.js.map +1 -1
  70. package/react/hooks-compiled/useLoadableQuery.d.ts +23 -15
  71. package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
  72. package/react/hooks-compiled/useMutation.d.ts +10 -7
  73. package/react/hooks-compiled/useMutation.js.map +1 -1
  74. package/react/hooks-compiled/useQuery.d.ts +74 -32
  75. package/react/hooks-compiled/useQuery.js.map +1 -1
  76. package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
  77. package/react/hooks-compiled/useSuspenseQuery.d.ts +83 -34
  78. package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
  79. package/react/internal/cache/QueryReference.js.map +1 -1
  80. package/react/internal/types.d.ts +15 -4
  81. package/react/internal/types.js.map +1 -1
  82. package/react/query-preloader/createQueryPreloader.d.ts +20 -5
  83. package/react/query-preloader/createQueryPreloader.js.map +1 -1
  84. package/version.js +1 -1
  85. package/version.js.map +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @apollo/client
2
2
 
3
+ ## 4.2.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [#13398](https://github.com/apollographql/apollo-client/pull/13398) [`3dd3e9a`](https://github.com/apollographql/apollo-client/commit/3dd3e9a6f195ea5dd27a973f153a0538ccdffd20) Thanks [@phryneas](https://github.com/phryneas)! - Fix type signature of some `DocumentationTypes` to fix their display in our documentation.
8
+
9
+ - [#13392](https://github.com/apollographql/apollo-client/pull/13392) [`d4f0771`](https://github.com/apollographql/apollo-client/commit/d4f0771976766b54e0a95a3d51b708b64eb3cfe0) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add a development-only warning when a network result is written to the cache but reading the query back from the cache returns a partial result. This usually points at a `merge` or `read` function that did not repair missing fields in the cache, which prevents Apollo Client from applying the cache result to the data received by the network.
10
+
11
+ ## 4.2.10
12
+
13
+ ### Patch Changes
14
+
15
+ - [#13385](https://github.com/apollographql/apollo-client/pull/13385) [`bfb674e`](https://github.com/apollographql/apollo-client/commit/bfb674ec0ac9cd296b7ea2992d9deebf68edaea9) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix accidental widening of the `client.mutate` return type when `optimisticResponse` was present.
16
+
17
+ - [#13382](https://github.com/apollographql/apollo-client/pull/13382) [`365373e`](https://github.com/apollographql/apollo-client/commit/365373e0a0b647e89183245c3904d58499aa63e1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix result types widened when a query's variables had constant types (e.g. `TypedDocumentNode<Data, { type: "main" }>`). This caused options such as `returnPartialData` or `errorPolicy` to be reported as their widened types (e.g. `boolean`, `ErrorPolicy`) instead of the value that was passed which returned the wrong `data` and `dataState` types.
18
+
19
+ - [#13382](https://github.com/apollographql/apollo-client/pull/13382) [`365373e`](https://github.com/apollographql/apollo-client/commit/365373e0a0b647e89183245c3904d58499aa63e1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix issue where unknown options were permitted by TypeScript when passed alongside a valid option to APIs with modern signatures.
20
+
21
+ - [#13383](https://github.com/apollographql/apollo-client/pull/13383) [`5840f50`](https://github.com/apollographql/apollo-client/commit/5840f5014d0a6bb9b963801657cd68b0a1aba6c8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Update the return type of `refetch`, `fetchMore` and `useLazyQuery`'s `execute` function on the provided `errorPolicy`. Previously these APIs all used the default type which typed `data` as `TData | undefined` and `error` as `ErrorLike | undefined`.
22
+
3
23
  ## 4.2.9
4
24
 
5
25
  ### Patch Changes
@@ -140,7 +140,7 @@ class ApolloCache {
140
140
  if (environment_1.__DEV__) {
141
141
  const actualFragmentName = fragmentName || (0, internal_1.getFragmentDefinition)(fragment).name.value;
142
142
  if (id === undefined) {
143
- __DEV__ && invariant_1.invariant.warn(118, actualFragmentName);
143
+ __DEV__ && invariant_1.invariant.warn(119, actualFragmentName);
144
144
  }
145
145
  }
146
146
  return id;
@@ -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", 104);
85
+ (0, invariant_1.invariant)(typeof dataId === "string", 105);
86
86
  const merged = new internal_1.DeepMerger({
87
87
  reconciler: storeObjectReconciler,
88
88
  }).merge(existing, incoming);
@@ -184,7 +184,7 @@ class EntityStore {
184
184
  if (environment_1.__DEV__) {
185
185
  const checkReference = (ref) => {
186
186
  if (this.lookup(ref.__ref) === undefined) {
187
- __DEV__ && invariant_1.invariant.warn(105, ref);
187
+ __DEV__ && invariant_1.invariant.warn(106, ref);
188
188
  return true;
189
189
  }
190
190
  };
@@ -213,7 +213,7 @@ class EntityStore {
213
213
  }
214
214
  }
215
215
  if (seenReference && someNonReference !== undefined) {
216
- __DEV__ && invariant_1.invariant.warn(106, someNonReference);
216
+ __DEV__ && invariant_1.invariant.warn(107, someNonReference);
217
217
  break;
218
218
  }
219
219
  }
@@ -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, 107, schemaKeyPath.join("."), object);
44
+ (0, invariant_1.invariant)(extracted !== void 0, 108, schemaKeyPath.join("."), object);
45
45
  return extracted;
46
46
  }));
47
47
  return `${context.typename}:${JSON.stringify(keyObject)}`;
@@ -229,7 +229,7 @@ class Policies {
229
229
  const rootId = "ROOT_" + which.toUpperCase();
230
230
  const old = this.rootTypenamesById[rootId];
231
231
  if (typename !== old) {
232
- (0, invariant_1.invariant)(!old || old === which, 108, which);
232
+ (0, invariant_1.invariant)(!old || old === which, 109, which);
233
233
  // First, delete any old __typename associated with this rootId from
234
234
  // rootIdsByTypename.
235
235
  if (old)
@@ -372,7 +372,7 @@ class Policies {
372
372
  if (supertypeSet.has(supertype)) {
373
373
  if (!typenameSupertypeSet.has(supertype)) {
374
374
  if (checkingFuzzySubtypes) {
375
- __DEV__ && invariant_1.invariant.warn(109, typename, supertype);
375
+ __DEV__ && invariant_1.invariant.warn(110, typename, supertype);
376
376
  }
377
377
  // Record positive results for faster future lookup.
378
378
  // Unfortunately, we cannot safely cache negative results,
@@ -625,7 +625,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
625
625
  }
626
626
  }
627
627
  if (environment_1.__DEV__ && options.from === void 0) {
628
- __DEV__ && invariant_1.invariant.warn(110, (0, internal_2.stringifyForDisplay)(Array.from(readFieldArgs)));
628
+ __DEV__ && invariant_1.invariant.warn(111, (0, internal_2.stringifyForDisplay)(Array.from(readFieldArgs)));
629
629
  }
630
630
  if (void 0 === options.variables) {
631
631
  options.variables = variables;
@@ -635,7 +635,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
635
635
  function makeMergeObjectsFunction(store) {
636
636
  return function mergeObjects(existing, incoming) {
637
637
  if ((0, internal_2.isArray)(existing) || (0, internal_2.isArray)(incoming)) {
638
- throw (0, invariant_1.newInvariantError)(111);
638
+ throw (0, invariant_1.newInvariantError)(112);
639
639
  }
640
640
  // These dynamic checks are necessary because the parameters of a
641
641
  // custom merge function can easily have the any type, so the type
@@ -194,7 +194,7 @@ class StoreReader {
194
194
  else {
195
195
  const fragment = (0, internal_1.getFragmentFromSelection)(selection, context.lookupFragment);
196
196
  if (!fragment && selection.kind === graphql_1.Kind.FRAGMENT_SPREAD) {
197
- throw (0, invariant_1.newInvariantError)(112, selection.name.value);
197
+ throw (0, invariant_1.newInvariantError)(113, selection.name.value);
198
198
  }
199
199
  if (fragment && policies.fragmentMatches(fragment, typename)) {
200
200
  fragment.selectionSet.selections.forEach(workSet.add, workSet);
@@ -278,7 +278,7 @@ function assertSelectionSetForIdValue(store, field, fieldValue) {
278
278
  if ((0, internal_1.isNonNullObject)(value)) {
279
279
  (0, invariant_1.invariant)(
280
280
  !(0, utilities_1.isReference)(value),
281
- 113,
281
+ 114,
282
282
  (0, helpers_js_1.getTypenameFromStoreObject)(store, value),
283
283
  field.name.value
284
284
  );
@@ -75,7 +75,7 @@ class StoreWriter {
75
75
  path: [],
76
76
  });
77
77
  if (!(0, utilities_1.isReference)(ref)) {
78
- throw (0, invariant_1.newInvariantError)(114, result);
78
+ throw (0, invariant_1.newInvariantError)(115, result);
79
79
  }
80
80
  // So far, the store has not been modified, so now it's time to process
81
81
  // context.incomingById and merge those incoming fields into context.store.
@@ -237,7 +237,7 @@ class StoreWriter {
237
237
  // provide a default value, so its absence from the written data should
238
238
  // not be cause for alarm.
239
239
  !policies.getReadFunction(typename, field.name.value)) {
240
- invariant_1.invariant.error(115, (0, internal_1.resultKeyNameFromField)(field), result);
240
+ invariant_1.invariant.error(116, (0, internal_1.resultKeyNameFromField)(field), result);
241
241
  }
242
242
  });
243
243
  // Identify the result object, even if dataId was already provided,
@@ -385,7 +385,7 @@ class StoreWriter {
385
385
  else {
386
386
  const fragment = (0, internal_1.getFragmentFromSelection)(selection, context.lookupFragment);
387
387
  if (!fragment && selection.kind === graphql_1.Kind.FRAGMENT_SPREAD) {
388
- throw (0, invariant_1.newInvariantError)(116, selection.name.value);
388
+ throw (0, invariant_1.newInvariantError)(117, selection.name.value);
389
389
  }
390
390
  if (fragment &&
391
391
  policies.fragmentMatches(fragment, typename, result, context.variables)) {
@@ -562,7 +562,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
562
562
  }
563
563
  });
564
564
  }
565
- __DEV__ && invariant_1.invariant.warn(117, fieldName, parentType, childTypenames.length ?
565
+ __DEV__ && invariant_1.invariant.warn(118, fieldName, parentType, childTypenames.length ?
566
566
  "either ensure all objects of type " +
567
567
  childTypenames.join(" and ") +
568
568
  " have an ID or a custom merge function, or "