@apollo/client 4.0.0-alpha.20 → 4.0.0-alpha.22

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 (214) hide show
  1. package/CHANGELOG.md +113 -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 +4 -4
  9. package/__cjs/core/ApolloClient.cjs +22 -19
  10. package/__cjs/core/ApolloClient.cjs.map +1 -1
  11. package/__cjs/core/ApolloClient.d.cts +7 -8
  12. package/__cjs/core/ObservableQuery.cjs +15 -11
  13. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  14. package/__cjs/core/ObservableQuery.d.cts +1 -2
  15. package/__cjs/core/QueryInfo.cjs +223 -34
  16. package/__cjs/core/QueryInfo.cjs.map +1 -1
  17. package/__cjs/core/QueryInfo.d.cts +34 -24
  18. package/__cjs/core/QueryManager.cjs +89 -265
  19. package/__cjs/core/QueryManager.cjs.map +1 -1
  20. package/__cjs/core/QueryManager.d.cts +13 -38
  21. package/__cjs/core/index.cjs.map +1 -1
  22. package/__cjs/core/index.d.cts +1 -1
  23. package/__cjs/core/networkStatus.cjs +7 -1
  24. package/__cjs/core/networkStatus.cjs.map +1 -1
  25. package/__cjs/core/networkStatus.d.cts +7 -1
  26. package/__cjs/core/types.d.cts +5 -4
  27. package/__cjs/invariantErrorCodes.cjs +99 -104
  28. package/__cjs/link/batch-http/batchHttpLink.cjs +14 -14
  29. package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
  30. package/__cjs/link/batch-http/batchHttpLink.d.cts +4 -0
  31. package/__cjs/link/batch-http/index.cjs +2 -1
  32. package/__cjs/link/batch-http/index.cjs.map +1 -1
  33. package/__cjs/link/batch-http/index.d.cts +1 -1
  34. package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +45 -0
  35. package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -0
  36. package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +62 -0
  37. package/__cjs/link/client-awareness/index.cjs +6 -0
  38. package/__cjs/link/client-awareness/index.cjs.map +1 -0
  39. package/__cjs/link/client-awareness/index.d.cts +2 -0
  40. package/__cjs/link/core/ApolloLink.cjs +2 -2
  41. package/__cjs/link/core/types.d.cts +1 -6
  42. package/__cjs/link/http/BaseHttpLink.cjs +117 -0
  43. package/__cjs/link/http/BaseHttpLink.cjs.map +1 -0
  44. package/__cjs/link/http/BaseHttpLink.d.cts +6 -0
  45. package/__cjs/link/http/HttpLink.cjs +8 -5
  46. package/__cjs/link/http/HttpLink.cjs.map +1 -1
  47. package/__cjs/link/http/HttpLink.d.cts +16 -4
  48. package/__cjs/link/http/index.cjs +4 -3
  49. package/__cjs/link/http/index.cjs.map +1 -1
  50. package/__cjs/link/http/index.d.cts +2 -2
  51. package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
  52. package/__cjs/link/http/selectHttpOptionsAndBody.cjs +6 -5
  53. package/__cjs/link/http/selectHttpOptionsAndBody.cjs.map +1 -1
  54. package/__cjs/link/http/serializeFetchParameter.cjs +1 -1
  55. package/__cjs/link/persisted-queries/index.cjs +7 -5
  56. package/__cjs/link/persisted-queries/index.cjs.map +1 -1
  57. package/__cjs/local-state/LocalState.cjs +0 -8
  58. package/__cjs/local-state/LocalState.cjs.map +1 -1
  59. package/__cjs/masking/maskDefinition.cjs +2 -2
  60. package/__cjs/masking/maskDefinition.cjs.map +1 -1
  61. package/__cjs/masking/maskFragment.cjs +2 -10
  62. package/__cjs/masking/maskFragment.cjs.map +1 -1
  63. package/__cjs/masking/maskOperation.cjs +1 -9
  64. package/__cjs/masking/maskOperation.cjs.map +1 -1
  65. package/__cjs/masking/utils.cjs +0 -8
  66. package/__cjs/masking/utils.cjs.map +1 -1
  67. package/__cjs/masking/utils.d.cts +0 -1
  68. package/__cjs/react/context/ApolloConsumer.cjs +1 -1
  69. package/__cjs/react/context/ApolloContext.cjs +1 -1
  70. package/__cjs/react/context/ApolloProvider.cjs +1 -1
  71. package/__cjs/react/hooks/internal/validateSuspenseHookOptions.cjs +2 -2
  72. package/__cjs/react/hooks/useApolloClient.cjs +1 -1
  73. package/__cjs/react/hooks/useLazyQuery.cjs +3 -4
  74. package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
  75. package/__cjs/react/hooks/useLazyQuery.d.cts +0 -8
  76. package/__cjs/react/hooks/useLoadableQuery.cjs +2 -2
  77. package/__cjs/react/hooks/useSubscription.cjs +1 -1
  78. package/__cjs/react/hooks/useSyncExternalStore.cjs +1 -1
  79. package/__cjs/react/internal/cache/QueryReference.cjs +1 -1
  80. package/__cjs/react/ssr/prerenderStatic.cjs +2 -2
  81. package/__cjs/testing/core/mocking/mockLink.cjs +4 -4
  82. package/__cjs/utilities/caching/sizes.cjs.map +1 -1
  83. package/__cjs/utilities/caching/sizes.d.cts +6 -0
  84. package/__cjs/utilities/graphql/DocumentTransform.cjs +1 -1
  85. package/__cjs/utilities/index.cjs +1 -16
  86. package/__cjs/utilities/index.cjs.map +1 -1
  87. package/__cjs/utilities/index.d.cts +0 -13
  88. package/__cjs/utilities/internal/checkDocument.cjs +47 -13
  89. package/__cjs/utilities/internal/checkDocument.cjs.map +1 -1
  90. package/__cjs/utilities/internal/checkDocument.d.cts +1 -1
  91. package/__cjs/utilities/internal/getFragmentDefinition.cjs +3 -3
  92. package/__cjs/utilities/internal/getFragmentFromSelection.cjs +1 -1
  93. package/__cjs/utilities/internal/getFragmentQueryDocument.cjs +2 -2
  94. package/__cjs/utilities/internal/getMainDefinition.cjs +1 -1
  95. package/__cjs/utilities/internal/getMemoryInternals.cjs +1 -0
  96. package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
  97. package/__cjs/utilities/internal/getMemoryInternals.d.cts +0 -1
  98. package/__cjs/utilities/internal/getQueryDefinition.cjs +1 -1
  99. package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs +1 -1
  100. package/__cjs/utilities/internal/shouldInclude.cjs +4 -4
  101. package/__cjs/utilities/internal/valueToObjectRepresentation.cjs +1 -1
  102. package/__cjs/version.cjs +1 -1
  103. package/cache/core/cache.js +1 -1
  104. package/cache/inmemory/entityStore.js +3 -3
  105. package/cache/inmemory/key-extractor.js +1 -1
  106. package/cache/inmemory/policies.js +4 -4
  107. package/cache/inmemory/policies.js.map +1 -1
  108. package/cache/inmemory/readFromStore.js +2 -2
  109. package/cache/inmemory/writeToStore.js +4 -4
  110. package/core/ApolloClient.d.ts +7 -8
  111. package/core/ApolloClient.js +23 -20
  112. package/core/ApolloClient.js.map +1 -1
  113. package/core/ObservableQuery.d.ts +1 -2
  114. package/core/ObservableQuery.js +15 -11
  115. package/core/ObservableQuery.js.map +1 -1
  116. package/core/QueryInfo.d.ts +34 -24
  117. package/core/QueryInfo.js +221 -34
  118. package/core/QueryInfo.js.map +1 -1
  119. package/core/QueryManager.d.ts +13 -38
  120. package/core/QueryManager.js +91 -267
  121. package/core/QueryManager.js.map +1 -1
  122. package/core/index.d.ts +1 -1
  123. package/core/index.js.map +1 -1
  124. package/core/networkStatus.d.ts +7 -1
  125. package/core/networkStatus.js +7 -1
  126. package/core/networkStatus.js.map +1 -1
  127. package/core/types.d.ts +5 -4
  128. package/invariantErrorCodes.js +99 -104
  129. package/legacyEntryPoints/link/client-awareness/client-awareness.cjs +1 -0
  130. package/legacyEntryPoints/link/client-awareness/client-awareness.d.cts +1 -0
  131. package/legacyEntryPoints/link/client-awareness/index.d.ts +1 -0
  132. package/legacyEntryPoints/link/client-awareness/index.js +1 -0
  133. package/link/batch-http/batchHttpLink.d.ts +4 -0
  134. package/link/batch-http/batchHttpLink.js +11 -12
  135. package/link/batch-http/batchHttpLink.js.map +1 -1
  136. package/link/batch-http/index.d.ts +1 -1
  137. package/link/batch-http/index.js +1 -1
  138. package/link/batch-http/index.js.map +1 -1
  139. package/link/client-awareness/ClientAwarenessLink.d.ts +62 -0
  140. package/link/client-awareness/ClientAwarenessLink.js +41 -0
  141. package/link/client-awareness/ClientAwarenessLink.js.map +1 -0
  142. package/link/client-awareness/index.d.ts +2 -0
  143. package/link/client-awareness/index.js +2 -0
  144. package/link/client-awareness/index.js.map +1 -0
  145. package/link/core/ApolloLink.js +2 -2
  146. package/link/core/types.d.ts +1 -6
  147. package/link/http/BaseHttpLink.d.ts +6 -0
  148. package/link/http/BaseHttpLink.js +113 -0
  149. package/link/http/BaseHttpLink.js.map +1 -0
  150. package/link/http/HttpLink.d.ts +16 -4
  151. package/link/http/HttpLink.js +6 -4
  152. package/link/http/HttpLink.js.map +1 -1
  153. package/link/http/index.d.ts +2 -2
  154. package/link/http/index.js +2 -2
  155. package/link/http/index.js.map +1 -1
  156. package/link/http/parseAndCheckHttpResponse.js +1 -1
  157. package/link/http/selectHttpOptionsAndBody.js +6 -5
  158. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  159. package/link/http/serializeFetchParameter.js +1 -1
  160. package/link/persisted-queries/index.js +7 -5
  161. package/link/persisted-queries/index.js.map +1 -1
  162. package/local-state/LocalState.js +0 -8
  163. package/local-state/LocalState.js.map +1 -1
  164. package/masking/maskDefinition.js +2 -2
  165. package/masking/maskDefinition.js.map +1 -1
  166. package/masking/maskFragment.js +2 -10
  167. package/masking/maskFragment.js.map +1 -1
  168. package/masking/maskOperation.js +1 -9
  169. package/masking/maskOperation.js.map +1 -1
  170. package/masking/utils.d.ts +0 -1
  171. package/masking/utils.js +0 -7
  172. package/masking/utils.js.map +1 -1
  173. package/package.json +7 -1
  174. package/react/context/ApolloConsumer.js +1 -1
  175. package/react/context/ApolloContext.js +1 -1
  176. package/react/context/ApolloProvider.js +1 -1
  177. package/react/hooks/internal/validateSuspenseHookOptions.js +2 -2
  178. package/react/hooks/useApolloClient.js +1 -1
  179. package/react/hooks/useLazyQuery.d.ts +0 -8
  180. package/react/hooks/useLazyQuery.js +3 -4
  181. package/react/hooks/useLazyQuery.js.map +1 -1
  182. package/react/hooks/useLoadableQuery.js +2 -2
  183. package/react/hooks/useSubscription.js +1 -1
  184. package/react/hooks/useSyncExternalStore.js +1 -1
  185. package/react/internal/cache/QueryReference.js +1 -1
  186. package/react/ssr/prerenderStatic.js +2 -2
  187. package/testing/core/mocking/mockLink.js +4 -4
  188. package/utilities/caching/sizes.d.ts +6 -0
  189. package/utilities/caching/sizes.js.map +1 -1
  190. package/utilities/graphql/DocumentTransform.js +1 -1
  191. package/utilities/index.d.ts +0 -13
  192. package/utilities/index.js +0 -12
  193. package/utilities/index.js.map +1 -1
  194. package/utilities/internal/checkDocument.d.ts +1 -1
  195. package/utilities/internal/checkDocument.js +46 -12
  196. package/utilities/internal/checkDocument.js.map +1 -1
  197. package/utilities/internal/getFragmentDefinition.js +3 -3
  198. package/utilities/internal/getFragmentFromSelection.js +1 -1
  199. package/utilities/internal/getFragmentQueryDocument.js +2 -2
  200. package/utilities/internal/getMainDefinition.js +1 -1
  201. package/utilities/internal/getMemoryInternals.d.ts +0 -1
  202. package/utilities/internal/getMemoryInternals.js +1 -0
  203. package/utilities/internal/getMemoryInternals.js.map +1 -1
  204. package/utilities/internal/getQueryDefinition.js +1 -1
  205. package/utilities/internal/removeDirectivesFromDocument.js +1 -1
  206. package/utilities/internal/shouldInclude.js +4 -4
  207. package/utilities/internal/valueToObjectRepresentation.js +1 -1
  208. package/version.js +1 -1
  209. package/__cjs/link/http/createHttpLink.cjs +0 -151
  210. package/__cjs/link/http/createHttpLink.cjs.map +0 -1
  211. package/__cjs/link/http/createHttpLink.d.cts +0 -4
  212. package/link/http/createHttpLink.d.ts +0 -4
  213. package/link/http/createHttpLink.js +0 -143
  214. package/link/http/createHttpLink.js.map +0 -1
@@ -5,7 +5,6 @@ import { compact, filterMap, getOperationDefinition, getQueryDefinition, prevent
5
5
  import { invariant } from "@apollo/client/utilities/invariant";
6
6
  import { equalByQuery } from "./equalByQuery.js";
7
7
  import { isNetworkRequestInFlight, NetworkStatus } from "./networkStatus.js";
8
- import { QueryInfo } from "./QueryInfo.js";
9
8
  const { assign, hasOwnProperty } = Object;
10
9
  const uninitialized = {
11
10
  loading: true,
@@ -346,7 +345,7 @@ export class ObservableQuery {
346
345
  const queryDef = getQueryDefinition(this.query);
347
346
  const vars = queryDef.variableDefinitions;
348
347
  if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
349
- __DEV__ && invariant.warn(77, variables, queryDef.name?.value || queryDef);
348
+ __DEV__ && invariant.warn(78, variables, queryDef.name?.value || queryDef);
350
349
  }
351
350
  }
352
351
  if (variables && !equal(this.variables, variables)) {
@@ -395,7 +394,7 @@ export class ObservableQuery {
395
394
  const updateQuery = fetchMoreOptions?.updateQuery;
396
395
  const isCached = this.options.fetchPolicy !== "no-cache";
397
396
  if (!isCached) {
398
- invariant(updateQuery, 78);
397
+ invariant(updateQuery, 79);
399
398
  }
400
399
  const { finalize, pushNotification } = this.pushOperation(NetworkStatus.fetchMore);
401
400
  pushNotification({
@@ -528,7 +527,7 @@ export class ObservableQuery {
528
527
  onError(error);
529
528
  }
530
529
  else {
531
- __DEV__ && invariant.error(79, error);
530
+ __DEV__ && invariant.error(80, error);
532
531
  }
533
532
  return;
534
533
  }
@@ -667,10 +666,6 @@ export class ObservableQuery {
667
666
  // TODO Make sure we update the networkStatus (and infer fetchVariables)
668
667
  // before actually committing to the fetch.
669
668
  const initialFetchPolicy = this.options.fetchPolicy;
670
- const queryInfo = new QueryInfo({
671
- queryManager: this.queryManager,
672
- observableQuery: this,
673
- });
674
669
  options.context ??= {};
675
670
  let synchronouslyEmitted = false;
676
671
  const onCacheHit = () => {
@@ -716,7 +711,13 @@ export class ObservableQuery {
716
711
  }
717
712
  }
718
713
  });
719
- let { observable, fromLink } = this.queryManager.fetchObservableWithInfo(queryInfo, options, { networkStatus, query: fetchQuery, onCacheHit, fetchQueryOperator });
714
+ let { observable, fromLink } = this.queryManager.fetchObservableWithInfo(options, {
715
+ networkStatus,
716
+ query: fetchQuery,
717
+ onCacheHit,
718
+ fetchQueryOperator,
719
+ observableQuery: this,
720
+ });
720
721
  // track query and variables from the start of the operation
721
722
  const { query, variables } = this;
722
723
  const operation = {
@@ -772,7 +773,7 @@ export class ObservableQuery {
772
773
  if (pollingInfo && pollingInfo.interval === pollInterval) {
773
774
  return;
774
775
  }
775
- invariant(pollInterval, 80);
776
+ invariant(pollInterval, 81);
776
777
  const info = pollingInfo || (this.pollingInfo = {});
777
778
  info.interval = pollInterval;
778
779
  const maybeFetch = () => {
@@ -1108,6 +1109,9 @@ export class ObservableQuery {
1108
1109
  };
1109
1110
  }
1110
1111
  calculateNetworkStatus(baseNetworkStatus) {
1112
+ if (baseNetworkStatus === NetworkStatus.streaming) {
1113
+ return baseNetworkStatus;
1114
+ }
1111
1115
  // in the future, this could be more complex logic, e.g. "refetch" and
1112
1116
  // "fetchMore" having priority over "polling" or "loading" network statuses
1113
1117
  // as for now we just take the "latest" operation that is still active,
@@ -1255,7 +1259,7 @@ export class ObservableQuery {
1255
1259
  }
1256
1260
  export function logMissingFieldErrors(missing) {
1257
1261
  if (__DEV__ && missing) {
1258
- __DEV__ && invariant.debug(81, missing);
1262
+ __DEV__ && invariant.debug(82, missing);
1259
1263
  }
1260
1264
  }
1261
1265
  function isEqualQuery(a, b) {