@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
@@ -204,7 +204,7 @@ export class Policies {
204
204
  const rootId = "ROOT_" + which.toUpperCase();
205
205
  const old = this.rootTypenamesById[rootId];
206
206
  if (typename !== old) {
207
- invariant(!old || old === which, 102, which);
207
+ invariant(!old || old === which, 103, which);
208
208
  // First, delete any old __typename associated with this rootId from
209
209
  // rootIdsByTypename.
210
210
  if (old)
@@ -347,7 +347,7 @@ export class Policies {
347
347
  if (supertypeSet.has(supertype)) {
348
348
  if (!typenameSupertypeSet.has(supertype)) {
349
349
  if (checkingFuzzySubtypes) {
350
- __DEV__ && invariant.warn(103, typename, supertype);
350
+ __DEV__ && invariant.warn(104, typename, supertype);
351
351
  }
352
352
  // Record positive results for faster future lookup.
353
353
  // Unfortunately, we cannot safely cache negative results,
@@ -519,7 +519,7 @@ function makeFieldFunctionOptions(policies, objectOrReference, fieldSpec, contex
519
519
  const fieldName = fieldNameFromStoreName(storeFieldName);
520
520
  const variables = fieldSpec.variables || context.variables;
521
521
  const { toReference, canRead } = context.store;
522
- return {
522
+ const options = {
523
523
  args: argsFromFieldSpecifier(fieldSpec),
524
524
  field: fieldSpec.field || null,
525
525
  fieldName,
@@ -535,6 +535,15 @@ function makeFieldFunctionOptions(policies, objectOrReference, fieldSpec, contex
535
535
  },
536
536
  mergeObjects: makeMergeObjectsFunction(context.store),
537
537
  };
538
+ // Make `extensions` only available in `merge` functions, but not `read`
539
+ // functions since we currently only support merge functions. Even though
540
+ // `context.extensions` will result in `undefined`, we don't want the key to
541
+ // exist in the options object to avoid the appearance that its supported in
542
+ // `read` functions.
543
+ if ("extensions" in context) {
544
+ options.extensions = context.extensions;
545
+ }
546
+ return options;
538
547
  }
539
548
  export function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables) {
540
549
  const { 0: fieldNameOrOptions, 1: from, length: argc } = readFieldArgs;
@@ -557,7 +566,7 @@ export function normalizeReadFieldOptions(readFieldArgs, objectOrReference, vari
557
566
  }
558
567
  }
559
568
  if (__DEV__ && options.from === void 0) {
560
- __DEV__ && invariant.warn(104, stringifyForDisplay(Array.from(readFieldArgs)));
569
+ __DEV__ && invariant.warn(105, stringifyForDisplay(Array.from(readFieldArgs)));
561
570
  }
562
571
  if (void 0 === options.variables) {
563
572
  options.variables = variables;
@@ -567,7 +576,7 @@ export function normalizeReadFieldOptions(readFieldArgs, objectOrReference, vari
567
576
  function makeMergeObjectsFunction(store) {
568
577
  return function mergeObjects(existing, incoming) {
569
578
  if (isArray(existing) || isArray(incoming)) {
570
- throw newInvariantError(105);
579
+ throw newInvariantError(106);
571
580
  }
572
581
  // These dynamic checks are necessary because the parameters of a
573
582
  // custom merge function can easily have the any type, so the type