@apollo/client 4.1.0-alpha.8 → 4.1.0-alpha.9

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 (124) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/__cjs/cache/core/cache.cjs +64 -24
  3. package/__cjs/cache/core/cache.cjs.map +1 -1
  4. package/__cjs/cache/core/cache.d.cts +47 -0
  5. package/__cjs/cache/core/types/Cache.d.cts +38 -0
  6. package/__cjs/cache/inmemory/entityStore.cjs +3 -3
  7. package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
  8. package/__cjs/cache/inmemory/inMemoryCache.cjs +47 -0
  9. package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
  10. package/__cjs/cache/inmemory/inMemoryCache.d.cts +47 -0
  11. package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
  12. package/__cjs/cache/inmemory/policies.cjs +14 -5
  13. package/__cjs/cache/inmemory/policies.cjs.map +1 -1
  14. package/__cjs/cache/inmemory/policies.d.cts +5 -0
  15. package/__cjs/cache/inmemory/readFromStore.cjs +3 -3
  16. package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
  17. package/__cjs/cache/inmemory/types.d.cts +1 -0
  18. package/__cjs/cache/inmemory/writeToStore.cjs +6 -5
  19. package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
  20. package/__cjs/cache/inmemory/writeToStore.d.cts +2 -1
  21. package/__cjs/core/ApolloClient.cjs +14 -14
  22. package/__cjs/core/ApolloClient.cjs.map +1 -1
  23. package/__cjs/core/ApolloClient.d.cts +21 -1
  24. package/__cjs/core/ObservableQuery.cjs +22 -8
  25. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  26. package/__cjs/core/ObservableQuery.d.cts +1 -0
  27. package/__cjs/core/QueryInfo.cjs +3 -0
  28. package/__cjs/core/QueryInfo.cjs.map +1 -1
  29. package/__cjs/core/QueryManager.cjs +27 -17
  30. package/__cjs/core/QueryManager.cjs.map +1 -1
  31. package/__cjs/core/QueryManager.d.cts +18 -2
  32. package/__cjs/invariantErrorCodes.cjs +39 -33
  33. package/__cjs/link/error/index.cjs +1 -1
  34. package/__cjs/link/error/index.cjs.map +1 -1
  35. package/__cjs/link/error/index.d.cts +1 -1
  36. package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
  37. package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
  38. package/__cjs/react/hooks/useLazyQuery.cjs +1 -0
  39. package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
  40. package/__cjs/react/hooks/useQuery.cjs +7 -4
  41. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  42. package/__cjs/react/hooks/useSuspenseQuery.cjs +2 -0
  43. package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
  44. package/__cjs/utilities/internal/checkDocument.cjs +2 -4
  45. package/__cjs/utilities/internal/checkDocument.cjs.map +1 -1
  46. package/__cjs/utilities/internal/constants.cjs +21 -0
  47. package/__cjs/utilities/internal/constants.cjs.map +1 -0
  48. package/__cjs/utilities/internal/constants.d.cts +18 -0
  49. package/__cjs/utilities/internal/index.cjs +6 -1
  50. package/__cjs/utilities/internal/index.cjs.map +1 -1
  51. package/__cjs/utilities/internal/index.d.cts +2 -0
  52. package/__cjs/utilities/internal/mapObservableFragment.cjs +27 -0
  53. package/__cjs/utilities/internal/mapObservableFragment.cjs.map +1 -0
  54. package/__cjs/utilities/internal/mapObservableFragment.d.cts +3 -0
  55. package/__cjs/utilities/internal/memoize.cjs +31 -0
  56. package/__cjs/utilities/internal/memoize.cjs.map +1 -0
  57. package/__cjs/utilities/internal/memoize.d.cts +8 -0
  58. package/__cjs/version.cjs +1 -1
  59. package/cache/core/cache.d.ts +47 -0
  60. package/cache/core/cache.js +65 -25
  61. package/cache/core/cache.js.map +1 -1
  62. package/cache/core/types/Cache.d.ts +38 -0
  63. package/cache/core/types/Cache.js.map +1 -1
  64. package/cache/inmemory/entityStore.js +3 -3
  65. package/cache/inmemory/entityStore.js.map +1 -1
  66. package/cache/inmemory/inMemoryCache.d.ts +47 -0
  67. package/cache/inmemory/inMemoryCache.js +47 -0
  68. package/cache/inmemory/inMemoryCache.js.map +1 -1
  69. package/cache/inmemory/key-extractor.js +1 -1
  70. package/cache/inmemory/policies.d.ts +5 -0
  71. package/cache/inmemory/policies.js +14 -5
  72. package/cache/inmemory/policies.js.map +1 -1
  73. package/cache/inmemory/readFromStore.js +3 -3
  74. package/cache/inmemory/readFromStore.js.map +1 -1
  75. package/cache/inmemory/types.d.ts +1 -0
  76. package/cache/inmemory/types.js.map +1 -1
  77. package/cache/inmemory/writeToStore.d.ts +2 -1
  78. package/cache/inmemory/writeToStore.js +6 -5
  79. package/cache/inmemory/writeToStore.js.map +1 -1
  80. package/core/ApolloClient.d.ts +21 -1
  81. package/core/ApolloClient.js +15 -15
  82. package/core/ApolloClient.js.map +1 -1
  83. package/core/ObservableQuery.d.ts +1 -0
  84. package/core/ObservableQuery.js +23 -9
  85. package/core/ObservableQuery.js.map +1 -1
  86. package/core/QueryInfo.js +3 -0
  87. package/core/QueryInfo.js.map +1 -1
  88. package/core/QueryManager.d.ts +18 -2
  89. package/core/QueryManager.js +28 -18
  90. package/core/QueryManager.js.map +1 -1
  91. package/invariantErrorCodes.js +39 -33
  92. package/link/error/index.d.ts +1 -1
  93. package/link/error/index.js +1 -1
  94. package/link/error/index.js.map +1 -1
  95. package/link/http/parseAndCheckHttpResponse.js +1 -1
  96. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  97. package/package.json +1 -1
  98. package/react/hooks/useLazyQuery.js +2 -1
  99. package/react/hooks/useLazyQuery.js.map +1 -1
  100. package/react/hooks/useQuery.js +8 -5
  101. package/react/hooks/useQuery.js.map +1 -1
  102. package/react/hooks/useSuspenseQuery.js +2 -0
  103. package/react/hooks/useSuspenseQuery.js.map +1 -1
  104. package/react/hooks-compiled/useLazyQuery.js +2 -1
  105. package/react/hooks-compiled/useLazyQuery.js.map +1 -1
  106. package/react/hooks-compiled/useQuery.js +9 -5
  107. package/react/hooks-compiled/useQuery.js.map +1 -1
  108. package/react/hooks-compiled/useSuspenseQuery.js +3 -1
  109. package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
  110. package/utilities/internal/checkDocument.js +2 -4
  111. package/utilities/internal/checkDocument.js.map +1 -1
  112. package/utilities/internal/constants.d.ts +18 -0
  113. package/utilities/internal/constants.js +18 -0
  114. package/utilities/internal/constants.js.map +1 -0
  115. package/utilities/internal/index.d.ts +2 -0
  116. package/utilities/internal/index.js +2 -0
  117. package/utilities/internal/index.js.map +1 -1
  118. package/utilities/internal/mapObservableFragment.d.ts +3 -0
  119. package/utilities/internal/mapObservableFragment.js +24 -0
  120. package/utilities/internal/mapObservableFragment.js.map +1 -0
  121. package/utilities/internal/memoize.d.ts +8 -0
  122. package/utilities/internal/memoize.js +28 -0
  123. package/utilities/internal/memoize.js.map +1 -0
  124. package/version.js +1 -1
@@ -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, 102, which);
215
+ (0, invariant_1.invariant)(!old || old === which, 103, 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(103, typename, supertype);
358
+ __DEV__ && invariant_1.invariant.warn(104, typename, supertype);
359
359
  }
360
360
  // Record positive results for faster future lookup.
361
361
  // Unfortunately, we cannot safely cache negative results,
@@ -528,7 +528,7 @@ function makeFieldFunctionOptions(policies, objectOrReference, fieldSpec, contex
528
528
  const fieldName = (0, helpers_js_1.fieldNameFromStoreName)(storeFieldName);
529
529
  const variables = fieldSpec.variables || context.variables;
530
530
  const { toReference, canRead } = context.store;
531
- return {
531
+ const options = {
532
532
  args: argsFromFieldSpecifier(fieldSpec),
533
533
  field: fieldSpec.field || null,
534
534
  fieldName,
@@ -544,6 +544,15 @@ function makeFieldFunctionOptions(policies, objectOrReference, fieldSpec, contex
544
544
  },
545
545
  mergeObjects: makeMergeObjectsFunction(context.store),
546
546
  };
547
+ // Make `extensions` only available in `merge` functions, but not `read`
548
+ // functions since we currently only support merge functions. Even though
549
+ // `context.extensions` will result in `undefined`, we don't want the key to
550
+ // exist in the options object to avoid the appearance that its supported in
551
+ // `read` functions.
552
+ if ("extensions" in context) {
553
+ options.extensions = context.extensions;
554
+ }
555
+ return options;
547
556
  }
548
557
  function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables) {
549
558
  const { 0: fieldNameOrOptions, 1: from, length: argc } = readFieldArgs;
@@ -566,7 +575,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
566
575
  }
567
576
  }
568
577
  if (environment_1.__DEV__ && options.from === void 0) {
569
- __DEV__ && invariant_1.invariant.warn(104, (0, internal_1.stringifyForDisplay)(Array.from(readFieldArgs)));
578
+ __DEV__ && invariant_1.invariant.warn(105, (0, internal_1.stringifyForDisplay)(Array.from(readFieldArgs)));
570
579
  }
571
580
  if (void 0 === options.variables) {
572
581
  options.variables = variables;
@@ -576,7 +585,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
576
585
  function makeMergeObjectsFunction(store) {
577
586
  return function mergeObjects(existing, incoming) {
578
587
  if ((0, internal_1.isArray)(existing) || (0, internal_1.isArray)(incoming)) {
579
- throw (0, invariant_1.newInvariantError)(105);
588
+ throw (0, invariant_1.newInvariantError)(106);
580
589
  }
581
590
  // These dynamic checks are necessary because the parameters of a
582
591
  // custom merge function can easily have the any type, so the type