@apollo/client 4.3.0-alpha.4 → 4.3.0-alpha.6

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 (158) hide show
  1. package/CHANGELOG.md +116 -0
  2. package/README.md +3 -7
  3. package/__cjs/cache/core/cache.cjs +1 -1
  4. package/__cjs/cache/core/cache.cjs.map +1 -1
  5. package/__cjs/cache/core/cache.d.cts +5 -1
  6. package/__cjs/cache/inmemory/entityStore.cjs +3 -3
  7. package/__cjs/cache/inmemory/inMemoryCache.cjs +0 -4
  8. package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
  9. package/__cjs/cache/inmemory/inMemoryCache.d.cts +3 -4
  10. package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
  11. package/__cjs/cache/inmemory/policies.cjs +28 -6
  12. package/__cjs/cache/inmemory/policies.cjs.map +1 -1
  13. package/__cjs/cache/inmemory/readFromStore.cjs +71 -54
  14. package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
  15. package/__cjs/cache/inmemory/readFromStore.d.cts +1 -1
  16. package/__cjs/cache/inmemory/types.d.cts +1 -2
  17. package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
  18. package/__cjs/core/ApolloClient.cjs +21 -22
  19. package/__cjs/core/ApolloClient.cjs.map +1 -1
  20. package/__cjs/core/ApolloClient.d.cts +44 -10
  21. package/__cjs/core/ObservableQuery.cjs +56 -14
  22. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  23. package/__cjs/core/ObservableQuery.d.cts +13 -2
  24. package/__cjs/core/QueryInfo.cjs +175 -161
  25. package/__cjs/core/QueryInfo.cjs.map +1 -1
  26. package/__cjs/core/QueryInfo.d.cts +15 -5
  27. package/__cjs/core/QueryManager.cjs +63 -38
  28. package/__cjs/core/QueryManager.cjs.map +1 -1
  29. package/__cjs/core/RefetchEventManager.cjs +3 -3
  30. package/__cjs/core/dataStateErrorCache.cjs +12 -0
  31. package/__cjs/core/dataStateErrorCache.cjs.map +1 -0
  32. package/__cjs/core/dataStateErrorCache.d.cts +3 -0
  33. package/__cjs/core/types.d.cts +2 -0
  34. package/__cjs/incremental/handlers/graphql17Alpha9.cjs +34 -11
  35. package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +1 -1
  36. package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +26 -3
  37. package/__cjs/incremental/types.d.cts +41 -3
  38. package/__cjs/invariantErrorCodes.cjs +56 -32
  39. package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
  40. package/__cjs/react/hooks/useBackgroundQuery.d.cts +100 -47
  41. package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
  42. package/__cjs/react/hooks/useLazyQuery.d.cts +26 -20
  43. package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
  44. package/__cjs/react/hooks/useLoadableQuery.d.cts +23 -15
  45. package/__cjs/react/hooks/useMutation.cjs.map +1 -1
  46. package/__cjs/react/hooks/useMutation.d.cts +10 -7
  47. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  48. package/__cjs/react/hooks/useQuery.d.cts +74 -32
  49. package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
  50. package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
  51. package/__cjs/react/hooks/useSuspenseQuery.d.cts +83 -34
  52. package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
  53. package/__cjs/react/internal/types.d.cts +14 -3
  54. package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
  55. package/__cjs/react/query-preloader/createQueryPreloader.d.cts +20 -5
  56. package/__cjs/testing/core/mocking/mockLink.cjs +21 -1
  57. package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
  58. package/__cjs/testing/core/mocking/mockLink.d.cts +1 -2
  59. package/__cjs/utilities/internal/addDeferFragmentLabels.cjs +33 -0
  60. package/__cjs/utilities/internal/addDeferFragmentLabels.cjs.map +1 -0
  61. package/__cjs/utilities/internal/addDeferFragmentLabels.d.cts +3 -0
  62. package/__cjs/utilities/internal/getDirectiveArgValue.cjs +19 -0
  63. package/__cjs/utilities/internal/getDirectiveArgValue.cjs.map +1 -0
  64. package/__cjs/utilities/internal/getDirectiveArgValue.d.cts +9 -0
  65. package/__cjs/utilities/internal/index.cjs +8 -2
  66. package/__cjs/utilities/internal/index.cjs.map +1 -1
  67. package/__cjs/utilities/internal/index.d.cts +3 -0
  68. package/__cjs/utilities/internal/toDiffWithDataState.cjs +20 -0
  69. package/__cjs/utilities/internal/toDiffWithDataState.cjs.map +1 -0
  70. package/__cjs/utilities/internal/toDiffWithDataState.d.cts +8 -0
  71. package/__cjs/version.cjs +1 -1
  72. package/cache/core/cache.d.ts +5 -1
  73. package/cache/core/cache.js +1 -1
  74. package/cache/core/cache.js.map +1 -1
  75. package/cache/inmemory/entityStore.js +3 -3
  76. package/cache/inmemory/inMemoryCache.d.ts +3 -4
  77. package/cache/inmemory/inMemoryCache.js +1 -5
  78. package/cache/inmemory/inMemoryCache.js.map +1 -1
  79. package/cache/inmemory/key-extractor.js +1 -1
  80. package/cache/inmemory/policies.js +28 -6
  81. package/cache/inmemory/policies.js.map +1 -1
  82. package/cache/inmemory/readFromStore.d.ts +1 -1
  83. package/cache/inmemory/readFromStore.js +72 -55
  84. package/cache/inmemory/readFromStore.js.map +1 -1
  85. package/cache/inmemory/types.d.ts +1 -2
  86. package/cache/inmemory/types.js.map +1 -1
  87. package/cache/inmemory/writeToStore.js +4 -4
  88. package/core/ApolloClient.d.ts +44 -10
  89. package/core/ApolloClient.js +21 -22
  90. package/core/ApolloClient.js.map +1 -1
  91. package/core/ObservableQuery.d.ts +13 -2
  92. package/core/ObservableQuery.js +57 -15
  93. package/core/ObservableQuery.js.map +1 -1
  94. package/core/QueryInfo.d.ts +15 -5
  95. package/core/QueryInfo.js +171 -161
  96. package/core/QueryInfo.js.map +1 -1
  97. package/core/QueryManager.js +63 -38
  98. package/core/QueryManager.js.map +1 -1
  99. package/core/RefetchEventManager.js +3 -3
  100. package/core/dataStateErrorCache.d.ts +3 -0
  101. package/core/dataStateErrorCache.js +9 -0
  102. package/core/dataStateErrorCache.js.map +1 -0
  103. package/core/types.d.ts +2 -0
  104. package/core/types.js.map +1 -1
  105. package/incremental/handlers/graphql17Alpha9.d.ts +26 -3
  106. package/incremental/handlers/graphql17Alpha9.js +35 -12
  107. package/incremental/handlers/graphql17Alpha9.js.map +1 -1
  108. package/incremental/types.d.ts +41 -3
  109. package/incremental/types.js.map +1 -1
  110. package/invariantErrorCodes.js +56 -32
  111. package/package.json +1 -1
  112. package/react/hooks/useBackgroundQuery.d.ts +100 -47
  113. package/react/hooks/useBackgroundQuery.js.map +1 -1
  114. package/react/hooks/useLazyQuery.d.ts +26 -20
  115. package/react/hooks/useLazyQuery.js.map +1 -1
  116. package/react/hooks/useLoadableQuery.d.ts +23 -15
  117. package/react/hooks/useLoadableQuery.js.map +1 -1
  118. package/react/hooks/useMutation.d.ts +10 -7
  119. package/react/hooks/useMutation.js.map +1 -1
  120. package/react/hooks/useQuery.d.ts +74 -32
  121. package/react/hooks/useQuery.js.map +1 -1
  122. package/react/hooks/useQueryRefHandlers.js.map +1 -1
  123. package/react/hooks/useSuspenseQuery.d.ts +83 -34
  124. package/react/hooks/useSuspenseQuery.js.map +1 -1
  125. package/react/hooks-compiled/useBackgroundQuery.d.ts +100 -47
  126. package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
  127. package/react/hooks-compiled/useLazyQuery.d.ts +26 -20
  128. package/react/hooks-compiled/useLazyQuery.js.map +1 -1
  129. package/react/hooks-compiled/useLoadableQuery.d.ts +23 -15
  130. package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
  131. package/react/hooks-compiled/useMutation.d.ts +10 -7
  132. package/react/hooks-compiled/useMutation.js.map +1 -1
  133. package/react/hooks-compiled/useQuery.d.ts +74 -32
  134. package/react/hooks-compiled/useQuery.js.map +1 -1
  135. package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
  136. package/react/hooks-compiled/useSuspenseQuery.d.ts +83 -34
  137. package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
  138. package/react/internal/cache/QueryReference.js.map +1 -1
  139. package/react/internal/types.d.ts +15 -4
  140. package/react/internal/types.js.map +1 -1
  141. package/react/query-preloader/createQueryPreloader.d.ts +20 -5
  142. package/react/query-preloader/createQueryPreloader.js.map +1 -1
  143. package/testing/core/mocking/mockLink.d.ts +1 -2
  144. package/testing/core/mocking/mockLink.js +21 -1
  145. package/testing/core/mocking/mockLink.js.map +1 -1
  146. package/utilities/internal/addDeferFragmentLabels.d.ts +3 -0
  147. package/utilities/internal/addDeferFragmentLabels.js +30 -0
  148. package/utilities/internal/addDeferFragmentLabels.js.map +1 -0
  149. package/utilities/internal/getDirectiveArgValue.d.ts +9 -0
  150. package/utilities/internal/getDirectiveArgValue.js +16 -0
  151. package/utilities/internal/getDirectiveArgValue.js.map +1 -0
  152. package/utilities/internal/index.d.ts +3 -0
  153. package/utilities/internal/index.js +3 -0
  154. package/utilities/internal/index.js.map +1 -1
  155. package/utilities/internal/toDiffWithDataState.d.ts +8 -0
  156. package/utilities/internal/toDiffWithDataState.js +17 -0
  157. package/utilities/internal/toDiffWithDataState.js.map +1 -0
  158. package/version.js +1 -1
@@ -22,7 +22,7 @@ export declare class StoreReader {
22
22
  * identify if any data was missing from the store.
23
23
  */
24
24
  diffQueryAgainstStore<T>(options: DiffQueryAgainstStoreOptions & {
25
- [handleIncrementalSymbol]: true | DiffIncrementalInfo;
25
+ [handleIncrementalSymbol]: DiffIncrementalInfo | undefined;
26
26
  }): Cache.InternalDiffResultWithDataState<T>;
27
27
  diffQueryAgainstStore<T>(options: DiffQueryAgainstStoreOptions): Cache.DiffResult<T>;
28
28
  isFresh(result: Record<string, any>, parent: StoreObject | Reference, selectionSet: SelectionSetNode, context: ReadMergeModifyContext): boolean;
@@ -1,7 +1,7 @@
1
1
  import type { DocumentNode, FieldNode } from "graphql";
2
2
  import type { OperationVariables } from "@apollo/client";
3
3
  import type { Reference, StoreObject, StoreValue } from "@apollo/client/utilities";
4
- import type { DeferInfoTrie, ExtensionsWithStreamInfo, handleIncrementalSymbol, RemoveIndexSignature, StreamInfoTrie } from "@apollo/client/utilities/internal";
4
+ import type { DeferInfoTrie, ExtensionsWithStreamInfo, RemoveIndexSignature, StreamInfoTrie } from "@apollo/client/utilities/internal";
5
5
  import type { ApolloCache, Transaction } from "../core/cache.cjs";
6
6
  import type { AllFieldsModifier, CanReadFunction, Modifiers, ToReferenceFunction } from "../core/types/common.cjs";
7
7
  import type { FieldValueGetter } from "./entityStore.cjs";
@@ -90,7 +90,6 @@ export interface DiffIncrementalInfo {
90
90
  }
91
91
  export type DiffQueryAgainstStoreOptions = ReadQueryOptions & {
92
92
  returnPartialData?: boolean;
93
- [handleIncrementalSymbol]?: true | DiffIncrementalInfo;
94
93
  };
95
94
  export type ApolloReducerConfig = {
96
95
  dataIdFromObject?: KeyFieldsFunction;
@@ -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)(115, result);
78
+ throw (0, invariant_1.newInvariantError)(117, 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(116, (0, internal_1.resultKeyNameFromField)(field), result);
240
+ invariant_1.invariant.error(118, (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)(117, selection.name.value);
388
+ throw (0, invariant_1.newInvariantError)(119, selection.name.value);
389
389
  }
390
390
  if (fragment &&
391
391
  policies.fragmentMatches(fragment, typename, result, context.variables)) {
@@ -558,7 +558,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
558
558
  }
559
559
  });
560
560
  }
561
- __DEV__ && invariant_1.invariant.warn(118, fieldName, parentType, childTypenames.length ?
561
+ __DEV__ && invariant_1.invariant.warn(120, fieldName, parentType, childTypenames.length ?
562
562
  "either ensure all objects of type " +
563
563
  childTypenames.join(" and ") +
564
564
  " have an ID or a custom merge function, or "
@@ -148,29 +148,28 @@ class ApolloClient {
148
148
  */
149
149
  if (!hasSuggestedDevtools && environment_1.__DEV__) {
150
150
  hasSuggestedDevtools = true;
151
- if (window.document &&
152
- window.top === window.self &&
153
- /^(https?|file):$/.test(window.location.protocol)) {
151
+ const win = window;
152
+ const ua = win.navigator.userAgent;
153
+ let url;
154
+ if (typeof ua === "string") {
155
+ if (ua.indexOf("Chrome/") > -1) {
156
+ url =
157
+ "https://chrome.google.com/webstore/detail/" +
158
+ "apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm";
159
+ }
160
+ else if (ua.indexOf("Firefox/") > -1) {
161
+ url =
162
+ "https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/";
163
+ }
164
+ }
165
+ if (win.document &&
166
+ win.top === win.self &&
167
+ /^(https?|file):$/.test(win.location.protocol) &&
168
+ url) {
154
169
  setTimeout(() => {
155
- if (!window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__) {
156
- const nav = window.navigator;
157
- const ua = nav && nav.userAgent;
158
- let url;
159
- if (typeof ua === "string") {
160
- if (ua.indexOf("Chrome/") > -1) {
161
- url =
162
- "https://chrome.google.com/webstore/detail/" +
163
- "apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm";
164
- }
165
- else if (ua.indexOf("Firefox/") > -1) {
166
- url =
167
- "https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/";
168
- }
169
- }
170
- if (url) {
171
- __DEV__ && invariant_1.invariant.log("Download the Apollo DevTools for a better development " +
172
- "experience: %s", url);
173
- }
170
+ if (!win.__APOLLO_DEVTOOLS_GLOBAL_HOOK__) {
171
+ __DEV__ && invariant_1.invariant.log("Download the Apollo DevTools for a better development " +
172
+ "experience: %s", url);
174
173
  }
175
174
  }, 10000);
176
175
  }