@apollo/client 4.3.0-alpha.1 → 4.3.0-alpha.3

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 (135) hide show
  1. package/CHANGELOG.md +285 -0
  2. package/__cjs/cache/core/Scalar.cjs +36 -0
  3. package/__cjs/cache/core/Scalar.cjs.map +1 -0
  4. package/__cjs/cache/core/Scalar.d.cts +20 -0
  5. package/__cjs/cache/core/cache.cjs +8 -1
  6. package/__cjs/cache/core/cache.cjs.map +1 -1
  7. package/__cjs/cache/core/cache.d.cts +16 -0
  8. package/__cjs/cache/index.cjs +3 -1
  9. package/__cjs/cache/index.cjs.map +1 -1
  10. package/__cjs/cache/index.d.cts +3 -2
  11. package/__cjs/cache/inmemory/entityStore.cjs +45 -2
  12. package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
  13. package/__cjs/cache/inmemory/entityStore.d.cts +3 -0
  14. package/__cjs/cache/inmemory/helpers.d.cts +9 -1
  15. package/__cjs/cache/inmemory/inMemoryCache.cjs +73 -4
  16. package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
  17. package/__cjs/cache/inmemory/inMemoryCache.d.cts +35 -3
  18. package/__cjs/cache/inmemory/policies.cjs +8 -1
  19. package/__cjs/cache/inmemory/policies.cjs.map +1 -1
  20. package/__cjs/cache/inmemory/policies.d.cts +4 -1
  21. package/__cjs/cache/inmemory/readFromStore.cjs +16 -3
  22. package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
  23. package/__cjs/cache/inmemory/types.d.cts +20 -4
  24. package/__cjs/cache/inmemory/writeToStore.cjs +10 -6
  25. package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
  26. package/__cjs/core/ApolloClient.cjs +2 -2
  27. package/__cjs/core/ApolloClient.cjs.map +1 -1
  28. package/__cjs/core/ObservableQuery.cjs +1 -3
  29. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  30. package/__cjs/core/QueryInfo.cjs +211 -37
  31. package/__cjs/core/QueryInfo.cjs.map +1 -1
  32. package/__cjs/core/QueryInfo.d.cts +5 -2
  33. package/__cjs/core/QueryManager.cjs +12 -18
  34. package/__cjs/core/QueryManager.cjs.map +1 -1
  35. package/__cjs/core/QueryManager.d.cts +1 -3
  36. package/__cjs/core/index.cjs +2 -1
  37. package/__cjs/core/index.cjs.map +1 -1
  38. package/__cjs/core/index.d.cts +2 -2
  39. package/__cjs/invariantErrorCodes.cjs +12 -7
  40. package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
  41. package/__cjs/react/hooks/useLazyQuery.d.cts +13 -13
  42. package/__cjs/utilities/index.cjs.map +1 -1
  43. package/__cjs/utilities/index.d.cts +1 -0
  44. package/__cjs/utilities/internal/collectSiblingFields.cjs +61 -0
  45. package/__cjs/utilities/internal/collectSiblingFields.cjs.map +1 -0
  46. package/__cjs/utilities/internal/collectSiblingFields.d.cts +21 -0
  47. package/__cjs/utilities/internal/getUnwrappedType.cjs +20 -0
  48. package/__cjs/utilities/internal/getUnwrappedType.cjs.map +1 -0
  49. package/__cjs/utilities/internal/getUnwrappedType.d.cts +8 -0
  50. package/__cjs/utilities/internal/index.cjs +10 -2
  51. package/__cjs/utilities/internal/index.cjs.map +1 -1
  52. package/__cjs/utilities/internal/index.d.cts +6 -0
  53. package/__cjs/utilities/internal/isDeferredFragment.cjs +23 -0
  54. package/__cjs/utilities/internal/isDeferredFragment.cjs.map +1 -0
  55. package/__cjs/utilities/internal/isDeferredFragment.d.cts +4 -0
  56. package/__cjs/utilities/internal/isTypenameField.cjs +7 -0
  57. package/__cjs/utilities/internal/isTypenameField.cjs.map +1 -0
  58. package/__cjs/utilities/internal/isTypenameField.d.cts +3 -0
  59. package/__cjs/utilities/internal/types/IsLooselyEqual.cjs +3 -0
  60. package/__cjs/utilities/internal/types/IsLooselyEqual.cjs.map +1 -0
  61. package/__cjs/utilities/internal/types/IsLooselyEqual.d.cts +10 -0
  62. package/__cjs/utilities/policies/pagination.cjs.map +1 -1
  63. package/__cjs/utilities/policies/pagination.d.cts +1 -1
  64. package/__cjs/utilities/subscriptions/relay/index.cjs +1 -0
  65. package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
  66. package/__cjs/version.cjs +1 -1
  67. package/cache/core/Scalar.d.ts +20 -0
  68. package/cache/core/Scalar.js +32 -0
  69. package/cache/core/Scalar.js.map +1 -0
  70. package/cache/core/cache.d.ts +16 -0
  71. package/cache/core/cache.js +8 -1
  72. package/cache/core/cache.js.map +1 -1
  73. package/cache/index.d.ts +3 -2
  74. package/cache/index.js +1 -0
  75. package/cache/index.js.map +1 -1
  76. package/cache/inmemory/entityStore.d.ts +3 -0
  77. package/cache/inmemory/entityStore.js +46 -3
  78. package/cache/inmemory/entityStore.js.map +1 -1
  79. package/cache/inmemory/helpers.d.ts +9 -1
  80. package/cache/inmemory/inMemoryCache.d.ts +35 -3
  81. package/cache/inmemory/inMemoryCache.js +74 -5
  82. package/cache/inmemory/inMemoryCache.js.map +1 -1
  83. package/cache/inmemory/policies.d.ts +4 -1
  84. package/cache/inmemory/policies.js +8 -1
  85. package/cache/inmemory/policies.js.map +1 -1
  86. package/cache/inmemory/readFromStore.js +11 -2
  87. package/cache/inmemory/readFromStore.js.map +1 -1
  88. package/cache/inmemory/types.d.ts +20 -4
  89. package/cache/inmemory/types.js.map +1 -1
  90. package/cache/inmemory/writeToStore.js +11 -7
  91. package/cache/inmemory/writeToStore.js.map +1 -1
  92. package/core/ApolloClient.js +2 -2
  93. package/core/ApolloClient.js.map +1 -1
  94. package/core/ObservableQuery.js +1 -3
  95. package/core/ObservableQuery.js.map +1 -1
  96. package/core/QueryInfo.d.ts +5 -2
  97. package/core/QueryInfo.js +212 -38
  98. package/core/QueryInfo.js.map +1 -1
  99. package/core/QueryManager.d.ts +1 -3
  100. package/core/QueryManager.js +12 -18
  101. package/core/QueryManager.js.map +1 -1
  102. package/core/index.d.ts +2 -2
  103. package/core/index.js +1 -1
  104. package/core/index.js.map +1 -1
  105. package/invariantErrorCodes.js +12 -7
  106. package/package.json +1 -1
  107. package/react/hooks/useLazyQuery.d.ts +13 -13
  108. package/react/hooks/useLazyQuery.js.map +1 -1
  109. package/react/hooks-compiled/useLazyQuery.d.ts +13 -13
  110. package/react/hooks-compiled/useLazyQuery.js.map +1 -1
  111. package/utilities/index.d.ts +1 -0
  112. package/utilities/index.js.map +1 -1
  113. package/utilities/internal/collectSiblingFields.d.ts +21 -0
  114. package/utilities/internal/collectSiblingFields.js +58 -0
  115. package/utilities/internal/collectSiblingFields.js.map +1 -0
  116. package/utilities/internal/getUnwrappedType.d.ts +8 -0
  117. package/utilities/internal/getUnwrappedType.js +17 -0
  118. package/utilities/internal/getUnwrappedType.js.map +1 -0
  119. package/utilities/internal/index.d.ts +6 -0
  120. package/utilities/internal/index.js +4 -0
  121. package/utilities/internal/index.js.map +1 -1
  122. package/utilities/internal/isDeferredFragment.d.ts +4 -0
  123. package/utilities/internal/isDeferredFragment.js +20 -0
  124. package/utilities/internal/isDeferredFragment.js.map +1 -0
  125. package/utilities/internal/isTypenameField.d.ts +3 -0
  126. package/utilities/internal/isTypenameField.js +4 -0
  127. package/utilities/internal/isTypenameField.js.map +1 -0
  128. package/utilities/internal/types/IsLooselyEqual.d.ts +10 -0
  129. package/utilities/internal/types/IsLooselyEqual.js +2 -0
  130. package/utilities/internal/types/IsLooselyEqual.js.map +1 -0
  131. package/utilities/policies/pagination.d.ts +1 -1
  132. package/utilities/policies/pagination.js.map +1 -1
  133. package/utilities/subscriptions/relay/index.js +1 -0
  134. package/utilities/subscriptions/relay/index.js.map +1 -1
  135. package/version.js +1 -1
@@ -117,7 +117,7 @@ export class QueryManager {
117
117
  const mutationStoreValue = this.mutationStore &&
118
118
  (this.mutationStore[queryInfo.id] = {
119
119
  mutation,
120
- variables,
120
+ variables: this.cache.serializeVariables(mutation, variables),
121
121
  loading: true,
122
122
  error: null,
123
123
  });
@@ -330,10 +330,6 @@ export class QueryManager {
330
330
  }),
331
331
  }));
332
332
  }
333
- requestIdCounter = 1;
334
- generateRequestId() {
335
- return this.requestIdCounter++;
336
- }
337
333
  clearStore(options = {
338
334
  discardWatches: true,
339
335
  }) {
@@ -519,6 +515,7 @@ export class QueryManager {
519
515
  const executeContext = {
520
516
  client: this.client,
521
517
  };
518
+ variables = this.cache.serializeVariables(query, variables);
522
519
  if (serverQuery) {
523
520
  const { inFlightLinkObservables, link } = this;
524
521
  try {
@@ -620,7 +617,6 @@ export class QueryManager {
620
617
  };
621
618
  }
622
619
  getResultsFromLink(options, { queryInfo, cacheWriteBehavior, observableQuery, exposeExtensions, }) {
623
- const requestId = (queryInfo.lastRequestId = this.generateRequestId());
624
620
  const { errorPolicy } = options;
625
621
  // Performing transformForLink here gives this.cache a chance to fill in
626
622
  // missing fragment definitions (for example) before sending this document
@@ -630,10 +626,11 @@ export class QueryManager {
630
626
  // Use linkDocument rather than queryInfo.document so the
631
627
  // operation/fragments used to write the result are the same as the
632
628
  // ones used to obtain it from the link.
633
- const result = queryInfo.markQueryResult(incoming, {
629
+ const { dataState, ...result } = queryInfo.markQueryResult(incoming, {
634
630
  ...options,
635
631
  document: linkDocument,
636
632
  cacheWriteBehavior,
633
+ returnPartialData: options.returnPartialData,
637
634
  });
638
635
  const hasErrors = graphQLResultHasError(result);
639
636
  if (hasErrors && errorPolicy === "none") {
@@ -641,29 +638,26 @@ export class QueryManager {
641
638
  observableQuery?.["resetNotifications"]();
642
639
  throw new CombinedGraphQLErrors(removeStreamDetailsFromExtensions(result));
643
640
  }
641
+ const partial = dataState !== "complete";
644
642
  const aqr = {
645
643
  data: result.data,
646
644
  ...(queryInfo.hasNext ?
647
645
  {
648
646
  loading: true,
649
647
  networkStatus: NetworkStatus.streaming,
650
- dataState: "streaming",
651
- partial: true,
648
+ dataState,
649
+ partial,
652
650
  }
653
651
  : {
654
- dataState: result.data ? "complete" : "empty",
652
+ dataState,
655
653
  loading: false,
656
654
  networkStatus: NetworkStatus.ready,
657
- partial: !result.data,
655
+ partial,
658
656
  }),
659
657
  };
660
658
  if (exposeExtensions && "extensions" in result) {
661
659
  aqr[extensionsSymbol] = result.extensions;
662
660
  }
663
- // In the case we start multiple network requests simultaneously, we
664
- // want to ensure we properly set `data` if we're reporting on an old
665
- // result which will not be caught by the conditional above that ends up
666
- // throwing the markError result.
667
661
  if (hasErrors) {
668
662
  if (errorPolicy === "none") {
669
663
  aqr.data = void 0;
@@ -671,15 +665,14 @@ export class QueryManager {
671
665
  }
672
666
  if (errorPolicy !== "ignore") {
673
667
  aqr.error = new CombinedGraphQLErrors(removeStreamDetailsFromExtensions(result));
674
- if (aqr.dataState !== "streaming") {
668
+ if (aqr.networkStatus !== NetworkStatus.streaming) {
675
669
  aqr.networkStatus = NetworkStatus.error;
676
670
  }
677
671
  }
678
672
  }
679
673
  return aqr;
680
674
  }), catchError((error) => {
681
- // Avoid storing errors from older interrupted queries.
682
- if (requestId >= queryInfo.lastRequestId && errorPolicy === "none") {
675
+ if (errorPolicy === "none") {
683
676
  queryInfo.resetLastWrite();
684
677
  observableQuery?.["resetNotifications"]();
685
678
  throw error;
@@ -1037,6 +1030,7 @@ export class QueryManager {
1037
1030
  context,
1038
1031
  fetchPolicy,
1039
1032
  errorPolicy,
1033
+ returnPartialData,
1040
1034
  }, {
1041
1035
  cacheWriteBehavior,
1042
1036
  queryInfo,