@apollo/client 3.10.3 → 3.10.5

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 (102) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/apollo-client.cjs +166 -134
  3. package/apollo-client.cjs.map +1 -1
  4. package/apollo-client.min.cjs +1 -1
  5. package/cache/cache.cjs +81 -8
  6. package/cache/cache.cjs.map +1 -1
  7. package/cache/cache.cjs.native.js +81 -8
  8. package/cache/core/cache.js +8 -4
  9. package/cache/core/cache.js.map +1 -1
  10. package/core/ApolloClient.js +2 -1
  11. package/core/ApolloClient.js.map +1 -1
  12. package/core/ObservableQuery.js +1 -1
  13. package/core/ObservableQuery.js.map +1 -1
  14. package/core/QueryInfo.js +7 -11
  15. package/core/QueryInfo.js.map +1 -1
  16. package/core/core.cjs +5 -7
  17. package/core/core.cjs.map +1 -1
  18. package/core/core.cjs.native.js +5 -7
  19. package/dev/dev.cjs +32 -27
  20. package/dev/dev.cjs.map +1 -1
  21. package/dev/dev.cjs.native.js +32 -27
  22. package/invariantErrorCodes.js +32 -26
  23. package/link/batch-http/batch-http.cjs +6 -5
  24. package/link/batch-http/batch-http.cjs.map +1 -1
  25. package/link/batch-http/batch-http.cjs.native.js +6 -5
  26. package/link/batch-http/batchHttpLink.js +15 -10
  27. package/link/batch-http/batchHttpLink.js.map +1 -1
  28. package/link/error/error.cjs +3 -2
  29. package/link/error/error.cjs.map +1 -1
  30. package/link/error/error.cjs.native.js +3 -2
  31. package/link/error/index.js +3 -2
  32. package/link/error/index.js.map +1 -1
  33. package/package.json +10 -6
  34. package/react/hooks/hooks.cjs +62 -34
  35. package/react/hooks/hooks.cjs.map +1 -1
  36. package/react/hooks/hooks.cjs.native.js +62 -34
  37. package/react/hooks/internal/useRenderGuard.js +37 -12
  38. package/react/hooks/internal/useRenderGuard.js.map +1 -1
  39. package/react/hooks/useBackgroundQuery.d.ts +10 -13
  40. package/react/hooks/useBackgroundQuery.js.map +1 -1
  41. package/react/hooks/useLazyQuery.js +7 -8
  42. package/react/hooks/useLazyQuery.js.map +1 -1
  43. package/react/hooks/useLoadableQuery.d.ts +3 -3
  44. package/react/hooks/useLoadableQuery.js +11 -3
  45. package/react/hooks/useLoadableQuery.js.map +1 -1
  46. package/react/hooks/useMutation.js +10 -7
  47. package/react/hooks/useMutation.js.map +1 -1
  48. package/react/hooks/useQuery.d.ts +2 -2
  49. package/react/hooks/useQuery.js +26 -12
  50. package/react/hooks/useQuery.js.map +1 -1
  51. package/react/hooks/useQueryRefHandlers.d.ts +3 -3
  52. package/react/hooks/useQueryRefHandlers.js +7 -2
  53. package/react/hooks/useQueryRefHandlers.js.map +1 -1
  54. package/react/hooks/useReadQuery.d.ts +2 -2
  55. package/react/hooks/useReadQuery.js +7 -2
  56. package/react/hooks/useReadQuery.js.map +1 -1
  57. package/react/hooks/useSubscription.js +4 -0
  58. package/react/hooks/useSubscription.js.map +1 -1
  59. package/react/hooks/useSuspenseQuery.js +2 -2
  60. package/react/hooks/useSuspenseQuery.js.map +1 -1
  61. package/react/hooks/useSyncExternalStore.js +4 -0
  62. package/react/hooks/useSyncExternalStore.js.map +1 -1
  63. package/react/internal/cache/QueryReference.d.ts +68 -6
  64. package/react/internal/cache/QueryReference.js +4 -0
  65. package/react/internal/cache/QueryReference.js.map +1 -1
  66. package/react/internal/index.d.ts +2 -2
  67. package/react/internal/index.js +1 -1
  68. package/react/internal/index.js.map +1 -1
  69. package/react/internal/internal.cjs +92 -0
  70. package/react/internal/internal.cjs.map +1 -1
  71. package/react/internal/internal.cjs.native.js +92 -0
  72. package/react/parser/index.js +5 -5
  73. package/react/parser/parser.cjs +5 -5
  74. package/react/parser/parser.cjs.map +1 -1
  75. package/react/parser/parser.cjs.native.js +5 -5
  76. package/react/query-preloader/createQueryPreloader.d.ts +6 -6
  77. package/react/query-preloader/createQueryPreloader.js.map +1 -1
  78. package/react/types/types.d.ts +1 -1
  79. package/react/types/types.js.map +1 -1
  80. package/testing/core/core.cjs +4 -4
  81. package/testing/core/core.cjs.map +1 -1
  82. package/testing/core/core.cjs.native.js +4 -4
  83. package/testing/core/mocking/mockLink.d.ts +8 -3
  84. package/testing/core/mocking/mockLink.js +5 -5
  85. package/testing/core/mocking/mockLink.js.map +1 -1
  86. package/testing/internal/profile/profile.js +6 -2
  87. package/testing/internal/profile/profile.js.map +1 -1
  88. package/testing/matchers/toBeDisposed.js +4 -13
  89. package/testing/matchers/toBeDisposed.js.map +1 -1
  90. package/utilities/globals/globals.cjs +1 -1
  91. package/utilities/globals/globals.cjs.map +1 -1
  92. package/utilities/globals/globals.cjs.native.js +1 -1
  93. package/utilities/graphql/DocumentTransform.js +1 -1
  94. package/utilities/graphql/directives.js +4 -4
  95. package/utilities/graphql/fragments.js +3 -3
  96. package/utilities/graphql/getFromAST.js +8 -8
  97. package/utilities/graphql/storeUtils.js +1 -1
  98. package/utilities/graphql/transform.js +2 -2
  99. package/utilities/utilities.cjs +19 -19
  100. package/utilities/utilities.cjs.map +1 -1
  101. package/utilities/utilities.cjs.native.js +19 -19
  102. package/version.js +1 -1
@@ -7,10 +7,14 @@ var tslib = require('tslib');
7
7
  var optimism = require('optimism');
8
8
  var utilities = require('../utilities');
9
9
  var caches = require('@wry/caches');
10
- var equality = require('@wry/equality');
10
+ var equal = require('@wry/equality');
11
11
  var trie = require('@wry/trie');
12
12
  var graphql = require('graphql');
13
13
 
14
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
15
+
16
+ var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
17
+
14
18
  var getInMemoryCacheMemoryInternals = globalThis.__DEV__ !== false ?
15
19
  _getInMemoryCacheMemoryInternals
16
20
  : undefined;
@@ -56,6 +60,72 @@ function recurseTransformInfo(transform) {
56
60
  : [];
57
61
  }
58
62
 
63
+ function equalByQuery(query, _a, _b, variables) {
64
+ var aData = _a.data, aRest = tslib.__rest(_a, ["data"]);
65
+ var bData = _b.data, bRest = tslib.__rest(_b, ["data"]);
66
+ return (equal__default(aRest, bRest) &&
67
+ equalBySelectionSet(utilities.getMainDefinition(query).selectionSet, aData, bData, {
68
+ fragmentMap: utilities.createFragmentMap(utilities.getFragmentDefinitions(query)),
69
+ variables: variables,
70
+ }));
71
+ }
72
+ function equalBySelectionSet(selectionSet, aResult, bResult, context) {
73
+ if (aResult === bResult) {
74
+ return true;
75
+ }
76
+ var seenSelections = new Set();
77
+ return selectionSet.selections.every(function (selection) {
78
+ if (seenSelections.has(selection))
79
+ return true;
80
+ seenSelections.add(selection);
81
+ if (!utilities.shouldInclude(selection, context.variables))
82
+ return true;
83
+ if (selectionHasNonreactiveDirective(selection))
84
+ return true;
85
+ if (utilities.isField(selection)) {
86
+ var resultKey = utilities.resultKeyNameFromField(selection);
87
+ var aResultChild = aResult && aResult[resultKey];
88
+ var bResultChild = bResult && bResult[resultKey];
89
+ var childSelectionSet = selection.selectionSet;
90
+ if (!childSelectionSet) {
91
+ return equal__default(aResultChild, bResultChild);
92
+ }
93
+ var aChildIsArray = Array.isArray(aResultChild);
94
+ var bChildIsArray = Array.isArray(bResultChild);
95
+ if (aChildIsArray !== bChildIsArray)
96
+ return false;
97
+ if (aChildIsArray && bChildIsArray) {
98
+ var length_1 = aResultChild.length;
99
+ if (bResultChild.length !== length_1) {
100
+ return false;
101
+ }
102
+ for (var i = 0; i < length_1; ++i) {
103
+ if (!equalBySelectionSet(childSelectionSet, aResultChild[i], bResultChild[i], context)) {
104
+ return false;
105
+ }
106
+ }
107
+ return true;
108
+ }
109
+ return equalBySelectionSet(childSelectionSet, aResultChild, bResultChild, context);
110
+ }
111
+ else {
112
+ var fragment = utilities.getFragmentFromSelection(selection, context.fragmentMap);
113
+ if (fragment) {
114
+ if (selectionHasNonreactiveDirective(fragment))
115
+ return true;
116
+ return equalBySelectionSet(fragment.selectionSet,
117
+ aResult, bResult, context);
118
+ }
119
+ }
120
+ });
121
+ }
122
+ function selectionHasNonreactiveDirective(selection) {
123
+ return (!!selection.directives && selection.directives.some(directiveIsNonreactive));
124
+ }
125
+ function directiveIsNonreactive(dir) {
126
+ return dir.name.value === "nonreactive";
127
+ }
128
+
59
129
  var ApolloCache = (function () {
60
130
  function ApolloCache() {
61
131
  this.assumeImmutableResults = false;
@@ -99,16 +169,19 @@ var ApolloCache = (function () {
99
169
  ApolloCache.prototype.watchFragment = function (options) {
100
170
  var _this = this;
101
171
  var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a;
172
+ var query = this.getFragmentDoc(fragment, fragmentName);
102
173
  var diffOptions = {
103
174
  returnPartialData: true,
104
175
  id: typeof from === "string" ? from : this.identify(from),
105
- query: this.getFragmentDoc(fragment, fragmentName),
176
+ query: query,
106
177
  optimistic: optimistic,
107
178
  };
108
179
  var latestDiff;
109
180
  return new utilities.Observable(function (observer) {
110
- return _this.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: true, query: _this.getFragmentDoc(fragment, fragmentName), callback: function (diff) {
111
- if (equality.equal(diff, latestDiff)) {
181
+ return _this.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: true, callback: function (diff) {
182
+ if (
183
+ latestDiff &&
184
+ equalByQuery(query, { data: latestDiff === null || latestDiff === void 0 ? void 0 : latestDiff.result }, { data: diff.result })) {
112
185
  return;
113
186
  }
114
187
  var result = {
@@ -731,7 +804,7 @@ var Layer = (function (_super) {
731
804
  }
732
805
  else if (ownStoreObject !== parentStoreObject) {
733
806
  Object.keys(ownStoreObject).forEach(function (storeFieldName) {
734
- if (!equality.equal(ownStoreObject[storeFieldName], parentStoreObject[storeFieldName])) {
807
+ if (!equal.equal(ownStoreObject[storeFieldName], parentStoreObject[storeFieldName])) {
735
808
  _this.group.dirty(dataId, storeFieldName);
736
809
  }
737
810
  });
@@ -776,7 +849,7 @@ var Stump = (function (_super) {
776
849
  function storeObjectReconciler(existingObject, incomingObject, property) {
777
850
  var existingValue = existingObject[property];
778
851
  var incomingValue = incomingObject[property];
779
- return equality.equal(existingValue, incomingValue) ? existingValue : incomingValue;
852
+ return equal.equal(existingValue, incomingValue) ? existingValue : incomingValue;
780
853
  }
781
854
  function supportsResultCaching(store) {
782
855
  return !!(store instanceof exports.EntityStore && store.group.caching);
@@ -2130,7 +2203,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
2130
2203
  return;
2131
2204
  if (utilities.isReference(existing))
2132
2205
  return;
2133
- if (equality.equal(existing, incoming))
2206
+ if (equal.equal(existing, incoming))
2134
2207
  return;
2135
2208
  if (Object.keys(existing).every(function (key) { return store.getFieldValue(incoming, key) !== void 0; })) {
2136
2209
  return;
@@ -2453,7 +2526,7 @@ var InMemoryCache = (function (_super) {
2453
2526
  return;
2454
2527
  }
2455
2528
  }
2456
- if (!lastDiff || !equality.equal(lastDiff.result, diff.result)) {
2529
+ if (!lastDiff || !equal.equal(lastDiff.result, diff.result)) {
2457
2530
  c.callback((c.lastDiff = diff), lastDiff);
2458
2531
  }
2459
2532
  };
@@ -3,7 +3,7 @@ import { wrap } from "optimism";
3
3
  import { Observable, cacheSizes, getFragmentQueryDocument, mergeDeepArray, } from "../../utilities/index.js";
4
4
  import { WeakCache } from "@wry/caches";
5
5
  import { getApolloCacheMemoryInternals } from "../../utilities/caching/getMemoryInternals.js";
6
- import { equal } from "@wry/equality";
6
+ import { equalByQuery } from "../../core/equalByQuery.js";
7
7
  var ApolloCache = /** @class */ (function () {
8
8
  function ApolloCache() {
9
9
  this.assumeImmutableResults = false;
@@ -62,16 +62,20 @@ var ApolloCache = /** @class */ (function () {
62
62
  ApolloCache.prototype.watchFragment = function (options) {
63
63
  var _this = this;
64
64
  var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a;
65
+ var query = this.getFragmentDoc(fragment, fragmentName);
65
66
  var diffOptions = {
66
67
  returnPartialData: true,
67
68
  id: typeof from === "string" ? from : this.identify(from),
68
- query: this.getFragmentDoc(fragment, fragmentName),
69
+ query: query,
69
70
  optimistic: optimistic,
70
71
  };
71
72
  var latestDiff;
72
73
  return new Observable(function (observer) {
73
- return _this.watch(__assign(__assign({}, diffOptions), { immediate: true, query: _this.getFragmentDoc(fragment, fragmentName), callback: function (diff) {
74
- if (equal(diff, latestDiff)) {
74
+ return _this.watch(__assign(__assign({}, diffOptions), { immediate: true, callback: function (diff) {
75
+ if (
76
+ // Always ensure we deliver the first result
77
+ latestDiff &&
78
+ equalByQuery(query, { data: latestDiff === null || latestDiff === void 0 ? void 0 : latestDiff.result }, { data: diff.result })) {
75
79
  return;
76
80
  }
77
81
  var result = {
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/cache/core/cache.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAOhC,OAAO,EACL,UAAU,EACV,UAAU,EAEV,wBAAwB,EACxB,cAAc,GACf,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,6BAA6B,EAAE,MAAM,+CAA+C,CAAC;AAK9F,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AA4EtC;IAAA;QACkB,2BAAsB,GAAY,KAAK,CAAC;QAyKxD,oEAAoE;QACpE,qDAAqD;QAC7C,mBAAc,GAAG,IAAI,CAAC,wBAAwB,EAAE;YACtD,GAAG,EACD,UAAU,CAAC,8BAA8B,CAAC;4EACO;YACnD,KAAK,EAAE,SAAS;SACjB,CAAC,CAAC;IAiFL,CAAC;IAlNC,oBAAoB;IAEpB,0EAA0E;IAC1E,4EAA4E;IAC5E,4EAA4E;IAC5E,4EAA4E;IAC5E,4EAA4E;IACrE,2BAAK,GAAZ,UAAgB,OAAoC;QAApD,iBAWC;QAVC,IAAM,YAAY,GAChB,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CA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CAAC;gBAC1D,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAEM,oCAAc,GAArB,UACE,OAAuD,EACvD,MAAmD;QAEnD,OAAO,IAAI,CAAC,KAAK,CAAC;YAChB,MAAM,YAAC,KAAK;gBACV,IAAM,KAAK,GAAG,KAAK,CAAC,YAAY,CAAoB,OAAO,CAAC,CAAC;gBAC7D,IAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC3B,IAAI,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,KAAK,IAAI;oBAAE,OAAO,KAAK,CAAC;gBACnD,KAAK,CAAC,aAAa,uBAAyB,OAAO,KAAE,IAAI,MAAA,IAAG,CAAC;gBAC7D,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAUH,kBAAC;AAAD,CAAC,AAlQD,IAkQC;;AAED,IAAI,OAAO,EAAE,CAAC;IACZ,WAAW,CAAC,SAAS,CAAC,kBAAkB,GAAG,6BAA6B,CAAC;AAC3E,CAAC","sourcesContent":["import type { DocumentNode } from \"graphql\";\nimport { wrap } from \"optimism\";\n\nimport type {\n StoreObject,\n Reference,\n DeepPartial,\n} from \"../../utilities/index.js\";\nimport {\n Observable,\n cacheSizes,\n defaultCacheSizes,\n getFragmentQueryDocument,\n mergeDeepArray,\n} from \"../../utilities/index.js\";\nimport type { DataProxy } from \"./types/DataProxy.js\";\nimport type { Cache } from \"./types/Cache.js\";\nimport { WeakCache } from \"@wry/caches\";\nimport { getApolloCacheMemoryInternals } from \"../../utilities/caching/getMemoryInternals.js\";\nimport type {\n OperationVariables,\n TypedDocumentNode,\n} from \"../../core/types.js\";\nimport { equal } from \"@wry/equality\";\nimport type { MissingTree } from \"./types/common.js\";\n\nexport type Transaction<T> = (c: ApolloCache<T>) => void;\n\n/**\n * Watched fragment options.\n */\nexport interface WatchFragmentOptions<TData, TVars> {\n /**\n * A GraphQL fragment document parsed into an AST with the `gql`\n * template literal.\n *\n * @docGroup 1. Required options\n */\n fragment: DocumentNode | TypedDocumentNode<TData, TVars>;\n /**\n * An object containing a `__typename` and primary key fields\n * (such as `id`) identifying the entity object from which the fragment will\n * be retrieved, or a `{ __ref: \"...\" }` reference, or a `string` ID\n * (uncommon).\n *\n * @docGroup 1. Required options\n */\n from: StoreObject | Reference | string;\n /**\n * Any variables that the GraphQL fragment may depend on.\n *\n * @docGroup 2. Cache options\n */\n variables?: TVars;\n /**\n * The name of the fragment defined in the fragment document.\n *\n * Required if the fragment document includes more than one fragment,\n * optional otherwise.\n *\n * @docGroup 2. Cache options\n */\n fragmentName?: string;\n /**\n * If `true`, `watchFragment` returns optimistic results.\n *\n * The default value is `true`.\n *\n * @docGroup 2. Cache options\n */\n optimistic?: boolean;\n /**\n * @deprecated\n * Using `canonizeResults` can result in memory leaks so we generally do not\n * recommend using this option anymore.\n * A future version of Apollo Client will contain a similar feature.\n *\n * Whether to canonize cache results before returning them. Canonization\n * takes some extra time, but it speeds up future deep equality comparisons.\n * Defaults to false.\n */\n canonizeResults?: boolean;\n}\n\n/**\n * Watched fragment results.\n */\nexport type WatchFragmentResult<TData> =\n | {\n data: TData;\n complete: true;\n missing?: never;\n }\n | {\n data: DeepPartial<TData>;\n complete: false;\n missing: MissingTree;\n };\n\nexport abstract class ApolloCache<TSerialized> implements DataProxy {\n public readonly assumeImmutableResults: boolean = false;\n\n // required to implement\n // core API\n public abstract read<TData = any, TVariables = any>(\n query: Cache.ReadOptions<TVariables, TData>\n ): TData | null;\n public abstract write<TData = any, TVariables = any>(\n write: Cache.WriteOptions<TData, TVariables>\n ): Reference | undefined;\n public abstract diff<T>(query: Cache.DiffOptions): Cache.DiffResult<T>;\n public abstract watch<TData = any, TVariables = any>(\n watch: Cache.WatchOptions<TData, TVariables>\n ): () => void;\n\n // Empty the cache and restart all current watches (unless\n // options.discardWatches is true).\n public abstract reset(options?: Cache.ResetOptions): Promise<void>;\n\n // Remove whole objects from the cache by passing just options.id, or\n // specific fields by passing options.field and/or options.args. If no\n // options.args are provided, all fields matching options.field (even\n // those with arguments) will be removed. Returns true iff any data was\n // removed from the cache.\n public abstract evict(options: Cache.EvictOptions): boolean;\n\n // initializer / offline / ssr API\n /**\n * Replaces existing state in the cache (if any) with the values expressed by\n * `serializedState`.\n *\n * Called when hydrating a cache (server side rendering, or offline storage),\n * and also (potentially) during hot reloads.\n */\n public abstract restore(\n serializedState: TSerialized\n ): ApolloCache<TSerialized>;\n\n /**\n * Exposes the cache's complete state, in a serializable format for later restoration.\n */\n public abstract extract(optimistic?: boolean): TSerialized;\n\n // Optimistic API\n\n public abstract removeOptimistic(id: string): void;\n\n // Transactional API\n\n // The batch method is intended to replace/subsume both performTransaction\n // and recordOptimisticTransaction, but performTransaction came first, so we\n // provide a default batch implementation that's just another way of calling\n // performTransaction. Subclasses of ApolloCache (such as InMemoryCache) can\n // override the batch method to do more interesting things with its options.\n public batch<U>(options: Cache.BatchOptions<this, U>): U {\n const optimisticId =\n typeof options.optimistic === \"string\" ? options.optimistic\n : options.optimistic === false ? null\n : void 0;\n let updateResult: U;\n this.performTransaction(\n () => (updateResult = options.update(this)),\n optimisticId\n );\n return updateResult!;\n }\n\n public abstract performTransaction(\n transaction: Transaction<TSerialized>,\n // Although subclasses may implement recordOptimisticTransaction\n // however they choose, the default implementation simply calls\n // performTransaction with a string as the second argument, allowing\n // performTransaction to handle both optimistic and non-optimistic\n // (broadcast-batching) transactions. Passing null for optimisticId is\n // also allowed, and indicates that performTransaction should apply\n // the transaction non-optimistically (ignoring optimistic data).\n optimisticId?: string | null\n ): void;\n\n public recordOptimisticTransaction(\n transaction: Transaction<TSerialized>,\n optimisticId: string\n ) {\n this.performTransaction(transaction, optimisticId);\n }\n\n // Optional API\n\n // Called once per input document, allowing the cache to make static changes\n // to the query, such as adding __typename fields.\n public transformDocument(document: DocumentNode): DocumentNode {\n return document;\n }\n\n // Called before each ApolloLink request, allowing the cache to make dynamic\n // changes to the query, such as filling in missing fragment definitions.\n public transformForLink(document: DocumentNode): DocumentNode {\n return document;\n }\n\n public identify(object: StoreObject | Reference): string | undefined {\n return;\n }\n\n public gc(): string[] {\n return [];\n }\n\n public modify<Entity extends Record<string, any> = Record<string, any>>(\n options: Cache.ModifyOptions<Entity>\n ): boolean {\n return false;\n }\n\n // DataProxy API\n public readQuery<QueryType, TVariables = any>(\n options: Cache.ReadQueryOptions<QueryType, TVariables>,\n optimistic = !!options.optimistic\n ): QueryType | null {\n return this.read({\n ...options,\n rootId: options.id || \"ROOT_QUERY\",\n optimistic,\n });\n }\n\n /** {@inheritDoc @apollo/client!ApolloClient#watchFragment:member(1)} */\n public watchFragment<TData = any, TVars = OperationVariables>(\n options: WatchFragmentOptions<TData, TVars>\n ): Observable<WatchFragmentResult<TData>> {\n const { fragment, fragmentName, from, optimistic = true } = options;\n\n const diffOptions: Cache.DiffOptions<TData, TVars> = {\n returnPartialData: true,\n id: typeof from === \"string\" ? from : this.identify(from),\n query: this.getFragmentDoc(fragment, fragmentName),\n optimistic,\n };\n\n let latestDiff: DataProxy.DiffResult<TData> | undefined;\n\n return new Observable((observer) => {\n return this.watch<TData, TVars>({\n ...diffOptions,\n immediate: true,\n query: this.getFragmentDoc(fragment, fragmentName),\n callback(diff) {\n if (equal(diff, latestDiff)) {\n return;\n }\n\n const result = {\n data: diff.result as DeepPartial<TData>,\n complete: !!diff.complete,\n } as WatchFragmentResult<TData>;\n\n if (diff.missing) {\n result.missing = mergeDeepArray(\n diff.missing.map((error) => error.missing)\n );\n }\n\n latestDiff = diff;\n observer.next(result);\n },\n });\n });\n }\n\n // Make sure we compute the same (===) fragment query document every\n // time we receive the same fragment in readFragment.\n private getFragmentDoc = wrap(getFragmentQueryDocument, {\n max:\n cacheSizes[\"cache.fragmentQueryDocuments\"] ||\n defaultCacheSizes[\"cache.fragmentQueryDocuments\"],\n cache: WeakCache,\n });\n\n public readFragment<FragmentType, TVariables = any>(\n options: Cache.ReadFragmentOptions<FragmentType, TVariables>,\n optimistic = !!options.optimistic\n ): FragmentType | null {\n return this.read({\n ...options,\n query: this.getFragmentDoc(options.fragment, options.fragmentName),\n rootId: options.id,\n optimistic,\n });\n }\n\n public writeQuery<TData = any, TVariables = any>({\n id,\n data,\n ...options\n }: Cache.WriteQueryOptions<TData, TVariables>): Reference | undefined {\n return this.write(\n Object.assign(options, {\n dataId: id || \"ROOT_QUERY\",\n result: data,\n })\n );\n }\n\n public writeFragment<TData = any, TVariables = any>({\n id,\n data,\n fragment,\n fragmentName,\n ...options\n }: Cache.WriteFragmentOptions<TData, TVariables>): Reference | undefined {\n return this.write(\n Object.assign(options, {\n query: this.getFragmentDoc(fragment, fragmentName),\n dataId: id,\n result: data,\n })\n );\n }\n\n public updateQuery<TData = any, TVariables = any>(\n options: Cache.UpdateQueryOptions<TData, TVariables>,\n update: (data: TData | null) => TData | null | void\n ): TData | null {\n return this.batch({\n update(cache) {\n const value = cache.readQuery<TData, TVariables>(options);\n const data = update(value);\n if (data === void 0 || data === null) return value;\n cache.writeQuery<TData, TVariables>({ ...options, data });\n return data;\n },\n });\n }\n\n public updateFragment<TData = any, TVariables = any>(\n options: Cache.UpdateFragmentOptions<TData, TVariables>,\n update: (data: TData | null) => TData | null | void\n ): TData | null {\n return this.batch({\n update(cache) {\n const value = cache.readFragment<TData, TVariables>(options);\n const data = update(value);\n if (data === void 0 || data === null) return value;\n cache.writeFragment<TData, TVariables>({ ...options, data });\n return data;\n },\n });\n }\n\n /**\n * @experimental\n * @internal\n * This is not a stable API - it is used in development builds to expose\n * information to the DevTools.\n * Use at your own risk!\n */\n public getMemoryInternals?: typeof getApolloCacheMemoryInternals;\n}\n\nif (__DEV__) {\n ApolloCache.prototype.getMemoryInternals = getApolloCacheMemoryInternals;\n}\n"]}
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/cache/core/cache.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAOhC,OAAO,EACL,UAAU,EACV,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D,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAUH,kBAAC;AAAD,CAAC,AA1QD,IA0QC;;AAED,IAAI,OAAO,EAAE,CAAC;IACZ,WAAW,CAAC,SAAS,CAAC,kBAAkB,GAAG,6BAA6B,CAAC;AAC3E,CAAC","sourcesContent":["import type { DocumentNode } from \"graphql\";\nimport { wrap } from \"optimism\";\n\nimport type {\n StoreObject,\n Reference,\n DeepPartial,\n} from \"../../utilities/index.js\";\nimport {\n Observable,\n cacheSizes,\n defaultCacheSizes,\n getFragmentQueryDocument,\n mergeDeepArray,\n} from \"../../utilities/index.js\";\nimport type { DataProxy } from \"./types/DataProxy.js\";\nimport type { Cache } from \"./types/Cache.js\";\nimport { WeakCache } from \"@wry/caches\";\nimport { getApolloCacheMemoryInternals } from \"../../utilities/caching/getMemoryInternals.js\";\nimport type {\n OperationVariables,\n TypedDocumentNode,\n} from \"../../core/types.js\";\nimport type { MissingTree } from \"./types/common.js\";\nimport { equalByQuery } from \"../../core/equalByQuery.js\";\n\nexport type Transaction<T> = (c: ApolloCache<T>) => void;\n\n/**\n * Watched fragment options.\n */\nexport interface WatchFragmentOptions<TData, TVars> {\n /**\n * A GraphQL fragment document parsed into an AST with the `gql`\n * template literal.\n *\n * @docGroup 1. Required options\n */\n fragment: DocumentNode | TypedDocumentNode<TData, TVars>;\n /**\n * An object containing a `__typename` and primary key fields\n * (such as `id`) identifying the entity object from which the fragment will\n * be retrieved, or a `{ __ref: \"...\" }` reference, or a `string` ID\n * (uncommon).\n *\n * @docGroup 1. Required options\n */\n from: StoreObject | Reference | string;\n /**\n * Any variables that the GraphQL fragment may depend on.\n *\n * @docGroup 2. Cache options\n */\n variables?: TVars;\n /**\n * The name of the fragment defined in the fragment document.\n *\n * Required if the fragment document includes more than one fragment,\n * optional otherwise.\n *\n * @docGroup 2. Cache options\n */\n fragmentName?: string;\n /**\n * If `true`, `watchFragment` returns optimistic results.\n *\n * The default value is `true`.\n *\n * @docGroup 2. Cache options\n */\n optimistic?: boolean;\n /**\n * @deprecated\n * Using `canonizeResults` can result in memory leaks so we generally do not\n * recommend using this option anymore.\n * A future version of Apollo Client will contain a similar feature.\n *\n * Whether to canonize cache results before returning them. Canonization\n * takes some extra time, but it speeds up future deep equality comparisons.\n * Defaults to false.\n */\n canonizeResults?: boolean;\n}\n\n/**\n * Watched fragment results.\n */\nexport type WatchFragmentResult<TData> =\n | {\n data: TData;\n complete: true;\n missing?: never;\n }\n | {\n data: DeepPartial<TData>;\n complete: false;\n missing: MissingTree;\n };\n\nexport abstract class ApolloCache<TSerialized> implements DataProxy {\n public readonly assumeImmutableResults: boolean = false;\n\n // required to implement\n // core API\n public abstract read<TData = any, TVariables = any>(\n query: Cache.ReadOptions<TVariables, TData>\n ): TData | null;\n public abstract write<TData = any, TVariables = any>(\n write: Cache.WriteOptions<TData, TVariables>\n ): Reference | undefined;\n public abstract diff<T>(query: Cache.DiffOptions): Cache.DiffResult<T>;\n public abstract watch<TData = any, TVariables = any>(\n watch: Cache.WatchOptions<TData, TVariables>\n ): () => void;\n\n // Empty the cache and restart all current watches (unless\n // options.discardWatches is true).\n public abstract reset(options?: Cache.ResetOptions): Promise<void>;\n\n // Remove whole objects from the cache by passing just options.id, or\n // specific fields by passing options.field and/or options.args. If no\n // options.args are provided, all fields matching options.field (even\n // those with arguments) will be removed. Returns true iff any data was\n // removed from the cache.\n public abstract evict(options: Cache.EvictOptions): boolean;\n\n // initializer / offline / ssr API\n /**\n * Replaces existing state in the cache (if any) with the values expressed by\n * `serializedState`.\n *\n * Called when hydrating a cache (server side rendering, or offline storage),\n * and also (potentially) during hot reloads.\n */\n public abstract restore(\n serializedState: TSerialized\n ): ApolloCache<TSerialized>;\n\n /**\n * Exposes the cache's complete state, in a serializable format for later restoration.\n */\n public abstract extract(optimistic?: boolean): TSerialized;\n\n // Optimistic API\n\n public abstract removeOptimistic(id: string): void;\n\n // Transactional API\n\n // The batch method is intended to replace/subsume both performTransaction\n // and recordOptimisticTransaction, but performTransaction came first, so we\n // provide a default batch implementation that's just another way of calling\n // performTransaction. Subclasses of ApolloCache (such as InMemoryCache) can\n // override the batch method to do more interesting things with its options.\n public batch<U>(options: Cache.BatchOptions<this, U>): U {\n const optimisticId =\n typeof options.optimistic === \"string\" ? options.optimistic\n : options.optimistic === false ? null\n : void 0;\n let updateResult: U;\n this.performTransaction(\n () => (updateResult = options.update(this)),\n optimisticId\n );\n return updateResult!;\n }\n\n public abstract performTransaction(\n transaction: Transaction<TSerialized>,\n // Although subclasses may implement recordOptimisticTransaction\n // however they choose, the default implementation simply calls\n // performTransaction with a string as the second argument, allowing\n // performTransaction to handle both optimistic and non-optimistic\n // (broadcast-batching) transactions. Passing null for optimisticId is\n // also allowed, and indicates that performTransaction should apply\n // the transaction non-optimistically (ignoring optimistic data).\n optimisticId?: string | null\n ): void;\n\n public recordOptimisticTransaction(\n transaction: Transaction<TSerialized>,\n optimisticId: string\n ) {\n this.performTransaction(transaction, optimisticId);\n }\n\n // Optional API\n\n // Called once per input document, allowing the cache to make static changes\n // to the query, such as adding __typename fields.\n public transformDocument(document: DocumentNode): DocumentNode {\n return document;\n }\n\n // Called before each ApolloLink request, allowing the cache to make dynamic\n // changes to the query, such as filling in missing fragment definitions.\n public transformForLink(document: DocumentNode): DocumentNode {\n return document;\n }\n\n public identify(object: StoreObject | Reference): string | undefined {\n return;\n }\n\n public gc(): string[] {\n return [];\n }\n\n public modify<Entity extends Record<string, any> = Record<string, any>>(\n options: Cache.ModifyOptions<Entity>\n ): boolean {\n return false;\n }\n\n // DataProxy API\n public readQuery<QueryType, TVariables = any>(\n options: Cache.ReadQueryOptions<QueryType, TVariables>,\n optimistic = !!options.optimistic\n ): QueryType | null {\n return this.read({\n ...options,\n rootId: options.id || \"ROOT_QUERY\",\n optimistic,\n });\n }\n\n /** {@inheritDoc @apollo/client!ApolloClient#watchFragment:member(1)} */\n public watchFragment<TData = any, TVars = OperationVariables>(\n options: WatchFragmentOptions<TData, TVars>\n ): Observable<WatchFragmentResult<TData>> {\n const { fragment, fragmentName, from, optimistic = true } = options;\n const query = this.getFragmentDoc(fragment, fragmentName);\n\n const diffOptions: Cache.DiffOptions<TData, TVars> = {\n returnPartialData: true,\n id: typeof from === \"string\" ? from : this.identify(from),\n query,\n optimistic,\n };\n\n let latestDiff: DataProxy.DiffResult<TData> | undefined;\n\n return new Observable((observer) => {\n return this.watch<TData, TVars>({\n ...diffOptions,\n immediate: true,\n callback(diff) {\n if (\n // Always ensure we deliver the first result\n latestDiff &&\n equalByQuery(\n query,\n { data: latestDiff?.result },\n { data: diff.result }\n )\n ) {\n return;\n }\n\n const result = {\n data: diff.result as DeepPartial<TData>,\n complete: !!diff.complete,\n } as WatchFragmentResult<TData>;\n\n if (diff.missing) {\n result.missing = mergeDeepArray(\n diff.missing.map((error) => error.missing)\n );\n }\n\n latestDiff = diff;\n observer.next(result);\n },\n });\n });\n }\n\n // Make sure we compute the same (===) fragment query document every\n // time we receive the same fragment in readFragment.\n private getFragmentDoc = wrap(getFragmentQueryDocument, {\n max:\n cacheSizes[\"cache.fragmentQueryDocuments\"] ||\n defaultCacheSizes[\"cache.fragmentQueryDocuments\"],\n cache: WeakCache,\n });\n\n public readFragment<FragmentType, TVariables = any>(\n options: Cache.ReadFragmentOptions<FragmentType, TVariables>,\n optimistic = !!options.optimistic\n ): FragmentType | null {\n return this.read({\n ...options,\n query: this.getFragmentDoc(options.fragment, options.fragmentName),\n rootId: options.id,\n optimistic,\n });\n }\n\n public writeQuery<TData = any, TVariables = any>({\n id,\n data,\n ...options\n }: Cache.WriteQueryOptions<TData, TVariables>): Reference | undefined {\n return this.write(\n Object.assign(options, {\n dataId: id || \"ROOT_QUERY\",\n result: data,\n })\n );\n }\n\n public writeFragment<TData = any, TVariables = any>({\n id,\n data,\n fragment,\n fragmentName,\n ...options\n }: Cache.WriteFragmentOptions<TData, TVariables>): Reference | undefined {\n return this.write(\n Object.assign(options, {\n query: this.getFragmentDoc(fragment, fragmentName),\n dataId: id,\n result: data,\n })\n );\n }\n\n public updateQuery<TData = any, TVariables = any>(\n options: Cache.UpdateQueryOptions<TData, TVariables>,\n update: (data: TData | null) => TData | null | void\n ): TData | null {\n return this.batch({\n update(cache) {\n const value = cache.readQuery<TData, TVariables>(options);\n const data = update(value);\n if (data === void 0 || data === null) return value;\n cache.writeQuery<TData, TVariables>({ ...options, data });\n return data;\n },\n });\n }\n\n public updateFragment<TData = any, TVariables = any>(\n options: Cache.UpdateFragmentOptions<TData, TVariables>,\n update: (data: TData | null) => TData | null | void\n ): TData | null {\n return this.batch({\n update(cache) {\n const value = cache.readFragment<TData, TVariables>(options);\n const data = update(value);\n if (data === void 0 || data === null) return value;\n cache.writeFragment<TData, TVariables>({ ...options, data });\n return data;\n },\n });\n }\n\n /**\n * @experimental\n * @internal\n * This is not a stable API - it is used in development builds to expose\n * information to the DevTools.\n * Use at your own risk!\n */\n public getMemoryInternals?: typeof getApolloCacheMemoryInternals;\n}\n\nif (__DEV__) {\n ApolloCache.prototype.getMemoryInternals = getApolloCacheMemoryInternals;\n}\n"]}
@@ -140,7 +140,8 @@ var ApolloClient = /** @class */ (function () {
140
140
  if (typeof window !== "undefined" &&
141
141
  window.document &&
142
142
  window.top === window.self &&
143
- !window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__) {
143
+ !window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__ &&
144
+ /^(https?|file):$/.test(window.location.protocol)) {
144
145
  var nav = window.navigator;
145
146
  var ua = nav && nav.userAgent;
146
147
  var url = void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"ApolloClient.js","sourceRoot":"","sources":["../../src/core/ApolloClient.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAK7E,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,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IAC1C,CAAC;IAED;;OAEG;IACI,mCAAY,GAAnB,UAAoB,SAAkC;QACpD,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACI,mCAAY,GAAnB;QACE,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;IACxC,CAAC;IAED;;OAEG;IACI,mDAA4B,GAAnC,UAAoC,eAAgC;QAClE,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACI,8BAAO,GAAd,UAAe,OAAmB;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,GAAG,OAAO,CAAC;IAC/C,CAAC;IAED,sBAAW,wCAAc;aAAzB;YACE,OAAO,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC;QAC1C,CAAC;;;OAAA;IAmFH,mBAAC;AAAD,CAAC,AAttBD,IAstBC;;AAED,IAAI,OAAO,EAAE,CAAC;IACZ,YAAY,CAAC,SAAS,CAAC,kBAAkB,GAAG,8BAA8B,CAAC;AAC7E,CAAC","sourcesContent":["import { invariant, newInvariantError } from \"../utilities/globals/index.js\";\n\nimport type { ExecutionResult, DocumentNode } from \"graphql\";\n\nimport type { FetchResult, GraphQLRequest } from \"../link/core/index.js\";\nimport { ApolloLink, execute } from \"../link/core/index.js\";\nimport type { ApolloCache, DataProxy, Reference } from \"../cache/index.js\";\nimport type { DocumentTransform, Observable } from \"../utilities/index.js\";\nimport { version } from \"../version.js\";\nimport type { UriFunction } from \"../link/http/index.js\";\nimport { HttpLink } from \"../link/http/index.js\";\n\nimport { QueryManager } from \"./QueryManager.js\";\nimport type { ObservableQuery } from \"./ObservableQuery.js\";\n\nimport type {\n ApolloQueryResult,\n DefaultContext,\n OperationVariables,\n Resolvers,\n RefetchQueriesOptions,\n RefetchQueriesResult,\n InternalRefetchQueriesResult,\n RefetchQueriesInclude,\n} from \"./types.js\";\n\nimport type {\n QueryOptions,\n WatchQueryOptions,\n MutationOptions,\n SubscriptionOptions,\n WatchQueryFetchPolicy,\n} from \"./watchQueryOptions.js\";\n\nimport type { FragmentMatcher } from \"./LocalState.js\";\nimport { LocalState } from \"./LocalState.js\";\n\nexport interface DefaultOptions {\n watchQuery?: Partial<WatchQueryOptions<any, any>>;\n query?: Partial<QueryOptions<any, any>>;\n mutate?: Partial<MutationOptions<any, any, any>>;\n}\n\nlet hasSuggestedDevtools = false;\n\nexport interface ApolloClientOptions<TCacheShape> {\n /**\n * The URI of the GraphQL endpoint that Apollo Client will communicate with.\n *\n * One of `uri` or `link` is **required**. If you provide both, `link` takes precedence.\n */\n uri?: string | UriFunction;\n credentials?: string;\n /**\n * An object representing headers to include in every HTTP request, such as `{Authorization: 'Bearer 1234'}`\n *\n * This value will be ignored when using the `link` option.\n */\n headers?: Record<string, string>;\n /**\n * You can provide an `ApolloLink` instance to serve as Apollo Client's network layer. For more information, see [Advanced HTTP networking](https://www.apollographql.com/docs/react/networking/advanced-http-networking/).\n *\n * One of `uri` or `link` is **required**. If you provide both, `link` takes precedence.\n */\n link?: ApolloLink;\n /**\n * The cache that Apollo Client should use to store query results locally. The recommended cache is `InMemoryCache`, which is provided by the `@apollo/client` package.\n *\n * For more information, see [Configuring the cache](https://www.apollographql.com/docs/react/caching/cache-configuration/).\n */\n cache: ApolloCache<TCacheShape>;\n /**\n * The time interval (in milliseconds) before Apollo Client force-fetches queries after a server-side render.\n *\n * @defaultValue `0` (no delay)\n */\n ssrForceFetchDelay?: number;\n /**\n * When using Apollo Client for [server-side rendering](https://www.apollographql.com/docs/react/performance/server-side-rendering/), set this to `true` so that the [`getDataFromTree` function](../react/ssr/#getdatafromtree) can work effectively.\n *\n * @defaultValue `false`\n */\n ssrMode?: boolean;\n /**\n * If `true`, the [Apollo Client Devtools](https://www.apollographql.com/docs/react/development-testing/developer-tooling/#apollo-client-devtools) browser extension can connect to Apollo Client.\n *\n * The default value is `false` in production and `true` in development (if there is a `window` object).\n */\n connectToDevTools?: boolean;\n /**\n * If `false`, Apollo Client sends every created query to the server, even if a _completely_ identical query (identical in terms of query string, variable values, and operationName) is already in flight.\n *\n * @defaultValue `true`\n */\n queryDeduplication?: boolean;\n /**\n * Provide this object to set application-wide default values for options you can provide to the `watchQuery`, `query`, and `mutate` functions. See below for an example object.\n *\n * See this [example object](https://www.apollographql.com/docs/react/api/core/ApolloClient#example-defaultoptions-object).\n */\n defaultOptions?: DefaultOptions;\n defaultContext?: Partial<DefaultContext>;\n /**\n * If `true`, Apollo Client will assume results read from the cache are never mutated by application code, which enables substantial performance optimizations.\n *\n * @defaultValue `false`\n */\n assumeImmutableResults?: boolean;\n resolvers?: Resolvers | Resolvers[];\n typeDefs?: string | string[] | DocumentNode | DocumentNode[];\n fragmentMatcher?: FragmentMatcher;\n /**\n * A custom name (e.g., `iOS`) that identifies this particular client among your set of clients. Apollo Server and Apollo Studio use this property as part of the [client awareness](https://www.apollographql.com/docs/apollo-server/monitoring/metrics#identifying-distinct-clients) feature.\n */\n name?: string;\n /**\n * A custom version that identifies the current version of this particular client (e.g., `1.2`). Apollo Server and Apollo Studio use this property as part of the [client awareness](https://www.apollographql.com/docs/apollo-server/monitoring/metrics#identifying-distinct-clients) feature.\n *\n * This is **not** the version of Apollo Client that you are using, but rather any version string that helps you differentiate between versions of your client.\n */\n version?: string;\n documentTransform?: DocumentTransform;\n}\n\n// Though mergeOptions now resides in @apollo/client/utilities, it was\n// previously declared and exported from this module, and then reexported from\n// @apollo/client/core. Since we need to preserve that API anyway, the easiest\n// solution is to reexport mergeOptions where it was previously declared (here).\nimport { mergeOptions } from \"../utilities/index.js\";\nimport { getApolloClientMemoryInternals } from \"../utilities/caching/getMemoryInternals.js\";\nimport type {\n WatchFragmentOptions,\n WatchFragmentResult,\n} from \"../cache/core/cache.js\";\nexport { mergeOptions };\n\n/**\n * This is the primary Apollo Client class. It is used to send GraphQL documents (i.e. queries\n * and mutations) to a GraphQL spec-compliant server over an `ApolloLink` instance,\n * receive results from the server and cache the results in a store. It also delivers updates\n * to GraphQL queries through `Observable` instances.\n */\nexport class ApolloClient<TCacheShape> implements DataProxy {\n public link: ApolloLink;\n public cache: ApolloCache<TCacheShape>;\n public disableNetworkFetches: boolean;\n public version: string;\n public queryDeduplication: boolean;\n public defaultOptions: DefaultOptions;\n public readonly typeDefs: ApolloClientOptions<TCacheShape>[\"typeDefs\"];\n\n private queryManager: QueryManager<TCacheShape>;\n private devToolsHookCb?: Function;\n private resetStoreCallbacks: Array<() => Promise<any>> = [];\n private clearStoreCallbacks: Array<() => Promise<any>> = [];\n private localState: LocalState<TCacheShape>;\n\n /**\n * Constructs an instance of `ApolloClient`.\n *\n * @example\n * ```js\n * import { ApolloClient, InMemoryCache } from '@apollo/client';\n *\n * const cache = new InMemoryCache();\n *\n * const client = new ApolloClient({\n * // Provide required constructor fields\n * cache: cache,\n * uri: 'http://localhost:4000/',\n *\n * // Provide some optional constructor fields\n * name: 'react-web-client',\n * version: '1.3',\n * queryDeduplication: false,\n * defaultOptions: {\n * watchQuery: {\n * fetchPolicy: 'cache-and-network',\n * },\n * },\n * });\n * ```\n */\n constructor(options: ApolloClientOptions<TCacheShape>) {\n if (!options.cache) {\n throw newInvariantError(\n \"To initialize Apollo Client, you must specify a 'cache' property \" +\n \"in the options object. \\n\" +\n \"For more information, please visit: https://go.apollo.dev/c/docs\"\n );\n }\n\n const {\n uri,\n credentials,\n headers,\n cache,\n documentTransform,\n ssrMode = false,\n ssrForceFetchDelay = 0,\n // Expose the client instance as window.__APOLLO_CLIENT__ and call\n // onBroadcast in queryManager.broadcastQueries to enable browser\n // devtools, but disable them by default in production.\n connectToDevTools = typeof window === \"object\" &&\n !(window as any).__APOLLO_CLIENT__ &&\n __DEV__,\n queryDeduplication = true,\n defaultOptions,\n defaultContext,\n assumeImmutableResults = cache.assumeImmutableResults,\n resolvers,\n typeDefs,\n fragmentMatcher,\n name: clientAwarenessName,\n version: clientAwarenessVersion,\n } = options;\n\n let { link } = options;\n\n if (!link) {\n link =\n uri ? new HttpLink({ uri, credentials, headers }) : ApolloLink.empty();\n }\n\n this.link = link;\n this.cache = cache;\n this.disableNetworkFetches = ssrMode || ssrForceFetchDelay > 0;\n this.queryDeduplication = queryDeduplication;\n this.defaultOptions = defaultOptions || Object.create(null);\n this.typeDefs = typeDefs;\n\n if (ssrForceFetchDelay) {\n setTimeout(\n () => (this.disableNetworkFetches = false),\n ssrForceFetchDelay\n );\n }\n\n this.watchQuery = this.watchQuery.bind(this);\n this.query = this.query.bind(this);\n this.mutate = this.mutate.bind(this);\n this.watchFragment = this.watchFragment.bind(this);\n this.resetStore = this.resetStore.bind(this);\n this.reFetchObservableQueries = this.reFetchObservableQueries.bind(this);\n\n this.version = version;\n\n this.localState = new LocalState({\n cache,\n client: this,\n resolvers,\n fragmentMatcher,\n });\n\n this.queryManager = new QueryManager({\n cache: this.cache,\n link: this.link,\n defaultOptions: this.defaultOptions,\n defaultContext,\n documentTransform,\n queryDeduplication,\n ssrMode,\n clientAwareness: {\n name: clientAwarenessName!,\n version: clientAwarenessVersion!,\n },\n localState: this.localState,\n assumeImmutableResults,\n onBroadcast:\n connectToDevTools ?\n () => {\n if (this.devToolsHookCb) {\n this.devToolsHookCb({\n action: {},\n state: {\n queries: this.queryManager.getQueryStore(),\n mutations: this.queryManager.mutationStore || {},\n },\n dataWithOptimisticResults: this.cache.extract(true),\n });\n }\n }\n : void 0,\n });\n\n if (connectToDevTools) this.connectToDevTools();\n }\n\n private connectToDevTools() {\n if (typeof window === \"object\") {\n type DevToolsConnector = {\n push(client: ApolloClient<any>): void;\n };\n const windowWithDevTools = window as Window & {\n [devtoolsSymbol]?: DevToolsConnector;\n __APOLLO_CLIENT__?: ApolloClient<any>;\n };\n const devtoolsSymbol = Symbol.for(\"apollo.devtools\");\n (windowWithDevTools[devtoolsSymbol] =\n windowWithDevTools[devtoolsSymbol] || ([] as DevToolsConnector)).push(\n this\n );\n windowWithDevTools.__APOLLO_CLIENT__ = this;\n }\n\n /**\n * Suggest installing the devtools for developers who don't have them\n */\n if (!hasSuggestedDevtools && __DEV__) {\n hasSuggestedDevtools = true;\n setTimeout(() => {\n if (\n typeof window !== \"undefined\" &&\n window.document &&\n window.top === window.self &&\n !(window as any).__APOLLO_DEVTOOLS_GLOBAL_HOOK__\n ) {\n const nav = window.navigator;\n const ua = nav && nav.userAgent;\n let url: string | undefined;\n if (typeof ua === \"string\") {\n if (ua.indexOf(\"Chrome/\") > -1) {\n url =\n \"https://chrome.google.com/webstore/detail/\" +\n \"apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm\";\n } else if (ua.indexOf(\"Firefox/\") > -1) {\n url =\n \"https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/\";\n }\n }\n if (url) {\n invariant.log(\n \"Download the Apollo DevTools for a better development \" +\n \"experience: %s\",\n url\n );\n }\n }\n }, 10000);\n }\n }\n\n /**\n * The `DocumentTransform` used to modify GraphQL documents before a request\n * is made. If a custom `DocumentTransform` is not provided, this will be the\n * default document transform.\n */\n get documentTransform() {\n return this.queryManager.documentTransform;\n }\n\n /**\n * Call this method to terminate any active client processes, making it safe\n * to dispose of this `ApolloClient` instance.\n */\n public stop() {\n this.queryManager.stop();\n }\n\n /**\n * This watches the cache store of the query according to the options specified and\n * returns an `ObservableQuery`. We can subscribe to this `ObservableQuery` and\n * receive updated results through an observer when the cache store changes.\n *\n * Note that this method is not an implementation of GraphQL subscriptions. Rather,\n * it uses Apollo's store in order to reactively deliver updates to your query results.\n *\n * For example, suppose you call watchQuery on a GraphQL query that fetches a person's\n * first and last name and this person has a particular object identifier, provided by\n * dataIdFromObject. Later, a different query fetches that same person's\n * first and last name and the first name has now changed. Then, any observers associated\n * with the results of the first query will be updated with a new result object.\n *\n * Note that if the cache does not change, the subscriber will *not* be notified.\n *\n * See [here](https://medium.com/apollo-stack/the-concepts-of-graphql-bc68bd819be3#.3mb0cbcmc) for\n * a description of store reactivity.\n */\n public watchQuery<\n T = any,\n TVariables extends OperationVariables = OperationVariables,\n >(options: WatchQueryOptions<TVariables, T>): ObservableQuery<T, TVariables> {\n if (this.defaultOptions.watchQuery) {\n options = mergeOptions(this.defaultOptions.watchQuery, options);\n }\n\n // XXX Overwriting options is probably not the best way to do this long term...\n if (\n this.disableNetworkFetches &&\n (options.fetchPolicy === \"network-only\" ||\n options.fetchPolicy === \"cache-and-network\")\n ) {\n options = { ...options, fetchPolicy: \"cache-first\" };\n }\n\n return this.queryManager.watchQuery<T, TVariables>(options);\n }\n\n /**\n * This resolves a single query according to the options specified and\n * returns a `Promise` which is either resolved with the resulting data\n * or rejected with an error.\n *\n * @param options - An object of type `QueryOptions` that allows us to\n * describe how this query should be treated e.g. whether it should hit the\n * server at all or just resolve from the cache, etc.\n */\n public query<\n T = any,\n TVariables extends OperationVariables = OperationVariables,\n >(options: QueryOptions<TVariables, T>): Promise<ApolloQueryResult<T>> {\n if (this.defaultOptions.query) {\n options = mergeOptions(this.defaultOptions.query, options);\n }\n\n invariant(\n (options.fetchPolicy as WatchQueryFetchPolicy) !== \"cache-and-network\",\n \"The cache-and-network fetchPolicy does not work with client.query, because \" +\n \"client.query can only return a single result. Please use client.watchQuery \" +\n \"to receive multiple results from the cache and the network, or consider \" +\n \"using a different fetchPolicy, such as cache-first or network-only.\"\n );\n\n if (this.disableNetworkFetches && options.fetchPolicy === \"network-only\") {\n options = { ...options, fetchPolicy: \"cache-first\" };\n }\n\n return this.queryManager.query<T, TVariables>(options);\n }\n\n /**\n * This resolves a single mutation according to the options specified and returns a\n * Promise which is either resolved with the resulting data or rejected with an\n * error. In some cases both `data` and `errors` might be undefined, for example\n * when `errorPolicy` is set to `'ignore'`.\n *\n * It takes options as an object with the following keys and values:\n */\n public mutate<\n TData = any,\n TVariables extends OperationVariables = OperationVariables,\n TContext extends Record<string, any> = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n >(\n options: MutationOptions<TData, TVariables, TContext>\n ): Promise<FetchResult<TData>> {\n if (this.defaultOptions.mutate) {\n options = mergeOptions(this.defaultOptions.mutate, options);\n }\n return this.queryManager.mutate<TData, TVariables, TContext, TCache>(\n options\n );\n }\n\n /**\n * This subscribes to a graphql subscription according to the options specified and returns an\n * `Observable` which either emits received data or an error.\n */\n public subscribe<\n T = any,\n TVariables extends OperationVariables = OperationVariables,\n >(options: SubscriptionOptions<TVariables, T>): Observable<FetchResult<T>> {\n return this.queryManager.startGraphQLSubscription<T>(options);\n }\n\n /**\n * Tries to read some data from the store in the shape of the provided\n * GraphQL query without making a network request. This method will start at\n * the root query. To start at a specific id returned by `dataIdFromObject`\n * use `readFragment`.\n *\n * @param optimistic - Set to `true` to allow `readQuery` to return\n * optimistic results. Is `false` by default.\n */\n public readQuery<T = any, TVariables = OperationVariables>(\n options: DataProxy.Query<TVariables, T>,\n optimistic: boolean = false\n ): T | null {\n return this.cache.readQuery<T, TVariables>(options, optimistic);\n }\n\n /**\n * Watches the cache store of the fragment according to the options specified\n * and returns an `Observable`. We can subscribe to this\n * `Observable` and receive updated results through an\n * observer when the cache store changes.\n *\n * You must pass in a GraphQL document with a single fragment or a document\n * with multiple fragments that represent what you are reading. If you pass\n * in a document with multiple fragments then you must also specify a\n * `fragmentName`.\n *\n * @since 3.10.0\n * @param options - An object of type `WatchFragmentOptions` that allows\n * the cache to identify the fragment and optionally specify whether to react\n * to optimistic updates.\n */\n\n public watchFragment<\n TFragmentData = unknown,\n TVariables = OperationVariables,\n >(\n options: WatchFragmentOptions<TFragmentData, TVariables>\n ): Observable<WatchFragmentResult<TFragmentData>> {\n return this.cache.watchFragment<TFragmentData, TVariables>(options);\n }\n\n /**\n * Tries to read some data from the store in the shape of the provided\n * GraphQL fragment without making a network request. This method will read a\n * GraphQL fragment from any arbitrary id that is currently cached, unlike\n * `readQuery` which will only read from the root query.\n *\n * You must pass in a GraphQL document with a single fragment or a document\n * with multiple fragments that represent what you are reading. If you pass\n * in a document with multiple fragments then you must also specify a\n * `fragmentName`.\n *\n * @param optimistic - Set to `true` to allow `readFragment` to return\n * optimistic results. Is `false` by default.\n */\n public readFragment<T = any, TVariables = OperationVariables>(\n options: DataProxy.Fragment<TVariables, T>,\n optimistic: boolean = false\n ): T | null {\n return this.cache.readFragment<T, TVariables>(options, optimistic);\n }\n\n /**\n * Writes some data in the shape of the provided GraphQL query directly to\n * the store. This method will start at the root query. To start at a\n * specific id returned by `dataIdFromObject` then use `writeFragment`.\n */\n public writeQuery<TData = any, TVariables = OperationVariables>(\n options: DataProxy.WriteQueryOptions<TData, TVariables>\n ): Reference | undefined {\n const ref = this.cache.writeQuery<TData, TVariables>(options);\n\n if (options.broadcast !== false) {\n this.queryManager.broadcastQueries();\n }\n\n return ref;\n }\n\n /**\n * Writes some data in the shape of the provided GraphQL fragment directly to\n * the store. This method will write to a GraphQL fragment from any arbitrary\n * id that is currently cached, unlike `writeQuery` which will only write\n * from the root query.\n *\n * You must pass in a GraphQL document with a single fragment or a document\n * with multiple fragments that represent what you are writing. If you pass\n * in a document with multiple fragments then you must also specify a\n * `fragmentName`.\n */\n public writeFragment<TData = any, TVariables = OperationVariables>(\n options: DataProxy.WriteFragmentOptions<TData, TVariables>\n ): Reference | undefined {\n const ref = this.cache.writeFragment<TData, TVariables>(options);\n\n if (options.broadcast !== false) {\n this.queryManager.broadcastQueries();\n }\n\n return ref;\n }\n\n public __actionHookForDevTools(cb: () => any) {\n this.devToolsHookCb = cb;\n }\n\n public __requestRaw(payload: GraphQLRequest): Observable<ExecutionResult> {\n return execute(this.link, payload);\n }\n\n /**\n * Resets your entire store by clearing out your cache and then re-executing\n * all of your active queries. This makes it so that you may guarantee that\n * there is no data left in your store from a time before you called this\n * method.\n *\n * `resetStore()` is useful when your user just logged out. You’ve removed the\n * user session, and you now want to make sure that any references to data you\n * might have fetched while the user session was active is gone.\n *\n * It is important to remember that `resetStore()` *will* refetch any active\n * queries. This means that any components that might be mounted will execute\n * their queries again using your network interface. If you do not want to\n * re-execute any queries then you should make sure to stop watching any\n * active queries.\n */\n public resetStore(): Promise<ApolloQueryResult<any>[] | null> {\n return Promise.resolve()\n .then(() =>\n this.queryManager.clearStore({\n discardWatches: false,\n })\n )\n .then(() => Promise.all(this.resetStoreCallbacks.map((fn) => fn())))\n .then(() => this.reFetchObservableQueries());\n }\n\n /**\n * Remove all data from the store. Unlike `resetStore`, `clearStore` will\n * not refetch any active queries.\n */\n public clearStore(): Promise<any[]> {\n return Promise.resolve()\n .then(() =>\n this.queryManager.clearStore({\n discardWatches: true,\n })\n )\n .then(() => Promise.all(this.clearStoreCallbacks.map((fn) => fn())));\n }\n\n /**\n * Allows callbacks to be registered that are executed when the store is\n * reset. `onResetStore` returns an unsubscribe function that can be used\n * to remove registered callbacks.\n */\n public onResetStore(cb: () => Promise<any>): () => void {\n this.resetStoreCallbacks.push(cb);\n return () => {\n this.resetStoreCallbacks = this.resetStoreCallbacks.filter(\n (c) => c !== cb\n );\n };\n }\n\n /**\n * Allows callbacks to be registered that are executed when the store is\n * cleared. `onClearStore` returns an unsubscribe function that can be used\n * to remove registered callbacks.\n */\n public onClearStore(cb: () => Promise<any>): () => void {\n this.clearStoreCallbacks.push(cb);\n return () => {\n this.clearStoreCallbacks = this.clearStoreCallbacks.filter(\n (c) => c !== cb\n );\n };\n }\n\n /**\n * Refetches all of your active queries.\n *\n * `reFetchObservableQueries()` is useful if you want to bring the client back to proper state in case of a network outage\n *\n * It is important to remember that `reFetchObservableQueries()` *will* refetch any active\n * queries. This means that any components that might be mounted will execute\n * their queries again using your network interface. If you do not want to\n * re-execute any queries then you should make sure to stop watching any\n * active queries.\n * Takes optional parameter `includeStandby` which will include queries in standby-mode when refetching.\n */\n public reFetchObservableQueries(\n includeStandby?: boolean\n ): Promise<ApolloQueryResult<any>[]> {\n return this.queryManager.reFetchObservableQueries(includeStandby);\n }\n\n /**\n * Refetches specified active queries. Similar to \"reFetchObservableQueries()\" but with a specific list of queries.\n *\n * `refetchQueries()` is useful for use cases to imperatively refresh a selection of queries.\n *\n * It is important to remember that `refetchQueries()` *will* refetch specified active\n * queries. This means that any components that might be mounted will execute\n * their queries again using your network interface. If you do not want to\n * re-execute any queries then you should make sure to stop watching any\n * active queries.\n */\n public refetchQueries<\n TCache extends ApolloCache<any> = ApolloCache<TCacheShape>,\n TResult = Promise<ApolloQueryResult<any>>,\n >(\n options: RefetchQueriesOptions<TCache, TResult>\n ): RefetchQueriesResult<TResult> {\n const map = this.queryManager.refetchQueries(\n options as RefetchQueriesOptions<ApolloCache<TCacheShape>, TResult>\n );\n const queries: ObservableQuery<any>[] = [];\n const results: InternalRefetchQueriesResult<TResult>[] = [];\n\n map.forEach((result, obsQuery) => {\n queries.push(obsQuery);\n results.push(result);\n });\n\n const result = Promise.all<TResult>(\n results as TResult[]\n ) as RefetchQueriesResult<TResult>;\n\n // In case you need the raw results immediately, without awaiting\n // Promise.all(results):\n result.queries = queries;\n result.results = results;\n\n // If you decide to ignore the result Promise because you're using\n // result.queries and result.results instead, you shouldn't have to worry\n // about preventing uncaught rejections for the Promise.all result.\n result.catch((error) => {\n invariant.debug(\n `In client.refetchQueries, Promise.all promise rejected with error %o`,\n error\n );\n });\n\n return result;\n }\n\n /**\n * Get all currently active `ObservableQuery` objects, in a `Map` keyed by\n * query ID strings.\n *\n * An \"active\" query is one that has observers and a `fetchPolicy` other than\n * \"standby\" or \"cache-only\".\n *\n * You can include all `ObservableQuery` objects (including the inactive ones)\n * by passing \"all\" instead of \"active\", or you can include just a subset of\n * active queries by passing an array of query names or DocumentNode objects.\n */\n public getObservableQueries(\n include: RefetchQueriesInclude = \"active\"\n ): Map<string, ObservableQuery<any>> {\n return this.queryManager.getObservableQueries(include);\n }\n\n /**\n * Exposes the cache's complete state, in a serializable format for later restoration.\n */\n public extract(optimistic?: boolean): TCacheShape {\n return this.cache.extract(optimistic);\n }\n\n /**\n * Replaces existing state in the cache (if any) with the values expressed by\n * `serializedState`.\n *\n * Called when hydrating a cache (server side rendering, or offline storage),\n * and also (potentially) during hot reloads.\n */\n public restore(serializedState: TCacheShape): ApolloCache<TCacheShape> {\n return this.cache.restore(serializedState);\n }\n\n /**\n * Add additional local resolvers.\n */\n public addResolvers(resolvers: Resolvers | Resolvers[]) {\n this.localState.addResolvers(resolvers);\n }\n\n /**\n * Set (override existing) local resolvers.\n */\n public setResolvers(resolvers: Resolvers | Resolvers[]) {\n this.localState.setResolvers(resolvers);\n }\n\n /**\n * Get all registered local resolvers.\n */\n public getResolvers() {\n return this.localState.getResolvers();\n }\n\n /**\n * Set a custom local state fragment matcher.\n */\n public setLocalStateFragmentMatcher(fragmentMatcher: FragmentMatcher) {\n this.localState.setFragmentMatcher(fragmentMatcher);\n }\n\n /**\n * Define a new ApolloLink (or link chain) that Apollo Client will use.\n */\n public setLink(newLink: ApolloLink) {\n this.link = this.queryManager.link = newLink;\n }\n\n public get defaultContext() {\n return this.queryManager.defaultContext;\n }\n\n /**\n * @experimental\n * This is not a stable API - it is used in development builds to expose\n * information to the DevTools.\n * Use at your own risk!\n * For more details, see [Memory Management](https://www.apollographql.com/docs/react/caching/memory-management/#measuring-cache-usage)\n *\n * @example\n * ```ts\n * console.log(client.getMemoryInternals())\n * ```\n * Logs output in the following JSON format:\n * @example\n * ```json\n *{\n * limits: {\n * parser: 1000,\n * canonicalStringify: 1000,\n * print: 2000,\n * 'documentTransform.cache': 2000,\n * 'queryManager.getDocumentInfo': 2000,\n * 'PersistedQueryLink.persistedQueryHashes': 2000,\n * 'fragmentRegistry.transform': 2000,\n * 'fragmentRegistry.lookup': 1000,\n * 'fragmentRegistry.findFragmentSpreads': 4000,\n * 'cache.fragmentQueryDocuments': 1000,\n * 'removeTypenameFromVariables.getVariableDefinitions': 2000,\n * 'inMemoryCache.maybeBroadcastWatch': 5000,\n * 'inMemoryCache.executeSelectionSet': 10000,\n * 'inMemoryCache.executeSubSelectedArray': 5000\n * },\n * sizes: {\n * parser: 26,\n * canonicalStringify: 4,\n * print: 14,\n * addTypenameDocumentTransform: [\n * {\n * cache: 14,\n * },\n * ],\n * queryManager: {\n * getDocumentInfo: 14,\n * documentTransforms: [\n * {\n * cache: 14,\n * },\n * {\n * cache: 14,\n * },\n * ],\n * },\n * fragmentRegistry: {\n * findFragmentSpreads: 34,\n * lookup: 20,\n * transform: 14,\n * },\n * cache: {\n * fragmentQueryDocuments: 22,\n * },\n * inMemoryCache: {\n * executeSelectionSet: 4345,\n * executeSubSelectedArray: 1206,\n * maybeBroadcastWatch: 32,\n * },\n * links: [\n * {\n * PersistedQueryLink: {\n * persistedQueryHashes: 14,\n * },\n * },\n * {\n * removeTypenameFromVariables: {\n * getVariableDefinitions: 14,\n * },\n * },\n * ],\n * },\n * }\n *```\n */\n public getMemoryInternals?: typeof getApolloClientMemoryInternals;\n}\n\nif (__DEV__) {\n ApolloClient.prototype.getMemoryInternals = getApolloClientMemoryInternals;\n}\n"]}
1
+ {"version":3,"file":"ApolloClient.js","sourceRoot":"","sources":["../../src/core/ApolloClient.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAK7E,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAuBjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAQ7C,IAAI,oBAAoB,GAAG,KAAK,CAAC;AAiFjC,sEAAsE;AACtE,8EAA8E;AAC9E,8EAA8E;AAC9E,gFAAgF;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AAK5F,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB;;;;;GAKG;AACH;IAeE;;;;;;;;;;;;;;;;;;;;;;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AAd,UAAe,OAAmB;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,GAAG,OAAO,CAAC;IAC/C,CAAC;IAED,sBAAW,wCAAc;aAAzB;YACE,OAAO,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC;QAC1C,CAAC;;;OAAA;IAmFH,mBAAC;AAAD,CAAC,AAvtBD,IAutBC;;AAED,IAAI,OAAO,EAAE,CAAC;IACZ,YAAY,CAAC,SAAS,CAAC,kBAAkB,GAAG,8BAA8B,CAAC;AAC7E,CAAC","sourcesContent":["import { invariant, newInvariantError } from \"../utilities/globals/index.js\";\n\nimport type { ExecutionResult, DocumentNode } from \"graphql\";\n\nimport type { FetchResult, GraphQLRequest } from \"../link/core/index.js\";\nimport { ApolloLink, execute } from \"../link/core/index.js\";\nimport type { ApolloCache, DataProxy, Reference } from \"../cache/index.js\";\nimport type { DocumentTransform, Observable } from \"../utilities/index.js\";\nimport { version } from \"../version.js\";\nimport type { UriFunction } from \"../link/http/index.js\";\nimport { HttpLink } from \"../link/http/index.js\";\n\nimport { QueryManager } from \"./QueryManager.js\";\nimport type { ObservableQuery } from \"./ObservableQuery.js\";\n\nimport type {\n ApolloQueryResult,\n DefaultContext,\n OperationVariables,\n Resolvers,\n RefetchQueriesOptions,\n RefetchQueriesResult,\n InternalRefetchQueriesResult,\n RefetchQueriesInclude,\n} from \"./types.js\";\n\nimport type {\n QueryOptions,\n WatchQueryOptions,\n MutationOptions,\n SubscriptionOptions,\n WatchQueryFetchPolicy,\n} from \"./watchQueryOptions.js\";\n\nimport type { FragmentMatcher } from \"./LocalState.js\";\nimport { LocalState } from \"./LocalState.js\";\n\nexport interface DefaultOptions {\n watchQuery?: Partial<WatchQueryOptions<any, any>>;\n query?: Partial<QueryOptions<any, any>>;\n mutate?: Partial<MutationOptions<any, any, any>>;\n}\n\nlet hasSuggestedDevtools = false;\n\nexport interface ApolloClientOptions<TCacheShape> {\n /**\n * The URI of the GraphQL endpoint that Apollo Client will communicate with.\n *\n * One of `uri` or `link` is **required**. If you provide both, `link` takes precedence.\n */\n uri?: string | UriFunction;\n credentials?: string;\n /**\n * An object representing headers to include in every HTTP request, such as `{Authorization: 'Bearer 1234'}`\n *\n * This value will be ignored when using the `link` option.\n */\n headers?: Record<string, string>;\n /**\n * You can provide an `ApolloLink` instance to serve as Apollo Client's network layer. For more information, see [Advanced HTTP networking](https://www.apollographql.com/docs/react/networking/advanced-http-networking/).\n *\n * One of `uri` or `link` is **required**. If you provide both, `link` takes precedence.\n */\n link?: ApolloLink;\n /**\n * The cache that Apollo Client should use to store query results locally. The recommended cache is `InMemoryCache`, which is provided by the `@apollo/client` package.\n *\n * For more information, see [Configuring the cache](https://www.apollographql.com/docs/react/caching/cache-configuration/).\n */\n cache: ApolloCache<TCacheShape>;\n /**\n * The time interval (in milliseconds) before Apollo Client force-fetches queries after a server-side render.\n *\n * @defaultValue `0` (no delay)\n */\n ssrForceFetchDelay?: number;\n /**\n * When using Apollo Client for [server-side rendering](https://www.apollographql.com/docs/react/performance/server-side-rendering/), set this to `true` so that the [`getDataFromTree` function](../react/ssr/#getdatafromtree) can work effectively.\n *\n * @defaultValue `false`\n */\n ssrMode?: boolean;\n /**\n * If `true`, the [Apollo Client Devtools](https://www.apollographql.com/docs/react/development-testing/developer-tooling/#apollo-client-devtools) browser extension can connect to Apollo Client.\n *\n * The default value is `false` in production and `true` in development (if there is a `window` object).\n */\n connectToDevTools?: boolean;\n /**\n * If `false`, Apollo Client sends every created query to the server, even if a _completely_ identical query (identical in terms of query string, variable values, and operationName) is already in flight.\n *\n * @defaultValue `true`\n */\n queryDeduplication?: boolean;\n /**\n * Provide this object to set application-wide default values for options you can provide to the `watchQuery`, `query`, and `mutate` functions. See below for an example object.\n *\n * See this [example object](https://www.apollographql.com/docs/react/api/core/ApolloClient#example-defaultoptions-object).\n */\n defaultOptions?: DefaultOptions;\n defaultContext?: Partial<DefaultContext>;\n /**\n * If `true`, Apollo Client will assume results read from the cache are never mutated by application code, which enables substantial performance optimizations.\n *\n * @defaultValue `false`\n */\n assumeImmutableResults?: boolean;\n resolvers?: Resolvers | Resolvers[];\n typeDefs?: string | string[] | DocumentNode | DocumentNode[];\n fragmentMatcher?: FragmentMatcher;\n /**\n * A custom name (e.g., `iOS`) that identifies this particular client among your set of clients. Apollo Server and Apollo Studio use this property as part of the [client awareness](https://www.apollographql.com/docs/apollo-server/monitoring/metrics#identifying-distinct-clients) feature.\n */\n name?: string;\n /**\n * A custom version that identifies the current version of this particular client (e.g., `1.2`). Apollo Server and Apollo Studio use this property as part of the [client awareness](https://www.apollographql.com/docs/apollo-server/monitoring/metrics#identifying-distinct-clients) feature.\n *\n * This is **not** the version of Apollo Client that you are using, but rather any version string that helps you differentiate between versions of your client.\n */\n version?: string;\n documentTransform?: DocumentTransform;\n}\n\n// Though mergeOptions now resides in @apollo/client/utilities, it was\n// previously declared and exported from this module, and then reexported from\n// @apollo/client/core. Since we need to preserve that API anyway, the easiest\n// solution is to reexport mergeOptions where it was previously declared (here).\nimport { mergeOptions } from \"../utilities/index.js\";\nimport { getApolloClientMemoryInternals } from \"../utilities/caching/getMemoryInternals.js\";\nimport type {\n WatchFragmentOptions,\n WatchFragmentResult,\n} from \"../cache/core/cache.js\";\nexport { mergeOptions };\n\n/**\n * This is the primary Apollo Client class. It is used to send GraphQL documents (i.e. queries\n * and mutations) to a GraphQL spec-compliant server over an `ApolloLink` instance,\n * receive results from the server and cache the results in a store. It also delivers updates\n * to GraphQL queries through `Observable` instances.\n */\nexport class ApolloClient<TCacheShape> implements DataProxy {\n public link: ApolloLink;\n public cache: ApolloCache<TCacheShape>;\n public disableNetworkFetches: boolean;\n public version: string;\n public queryDeduplication: boolean;\n public defaultOptions: DefaultOptions;\n public readonly typeDefs: ApolloClientOptions<TCacheShape>[\"typeDefs\"];\n\n private queryManager: QueryManager<TCacheShape>;\n private devToolsHookCb?: Function;\n private resetStoreCallbacks: Array<() => Promise<any>> = [];\n private clearStoreCallbacks: Array<() => Promise<any>> = [];\n private localState: LocalState<TCacheShape>;\n\n /**\n * Constructs an instance of `ApolloClient`.\n *\n * @example\n * ```js\n * import { ApolloClient, InMemoryCache } from '@apollo/client';\n *\n * const cache = new InMemoryCache();\n *\n * const client = new ApolloClient({\n * // Provide required constructor fields\n * cache: cache,\n * uri: 'http://localhost:4000/',\n *\n * // Provide some optional constructor fields\n * name: 'react-web-client',\n * version: '1.3',\n * queryDeduplication: false,\n * defaultOptions: {\n * watchQuery: {\n * fetchPolicy: 'cache-and-network',\n * },\n * },\n * });\n * ```\n */\n constructor(options: ApolloClientOptions<TCacheShape>) {\n if (!options.cache) {\n throw newInvariantError(\n \"To initialize Apollo Client, you must specify a 'cache' property \" +\n \"in the options object. \\n\" +\n \"For more information, please visit: https://go.apollo.dev/c/docs\"\n );\n }\n\n const {\n uri,\n credentials,\n headers,\n cache,\n documentTransform,\n ssrMode = false,\n ssrForceFetchDelay = 0,\n // Expose the client instance as window.__APOLLO_CLIENT__ and call\n // onBroadcast in queryManager.broadcastQueries to enable browser\n // devtools, but disable them by default in production.\n connectToDevTools = typeof window === \"object\" &&\n !(window as any).__APOLLO_CLIENT__ &&\n __DEV__,\n queryDeduplication = true,\n defaultOptions,\n defaultContext,\n assumeImmutableResults = cache.assumeImmutableResults,\n resolvers,\n typeDefs,\n fragmentMatcher,\n name: clientAwarenessName,\n version: clientAwarenessVersion,\n } = options;\n\n let { link } = options;\n\n if (!link) {\n link =\n uri ? new HttpLink({ uri, credentials, headers }) : ApolloLink.empty();\n }\n\n this.link = link;\n this.cache = cache;\n this.disableNetworkFetches = ssrMode || ssrForceFetchDelay > 0;\n this.queryDeduplication = queryDeduplication;\n this.defaultOptions = defaultOptions || Object.create(null);\n this.typeDefs = typeDefs;\n\n if (ssrForceFetchDelay) {\n setTimeout(\n () => (this.disableNetworkFetches = false),\n ssrForceFetchDelay\n );\n }\n\n this.watchQuery = this.watchQuery.bind(this);\n this.query = this.query.bind(this);\n this.mutate = this.mutate.bind(this);\n this.watchFragment = this.watchFragment.bind(this);\n this.resetStore = this.resetStore.bind(this);\n this.reFetchObservableQueries = this.reFetchObservableQueries.bind(this);\n\n this.version = version;\n\n this.localState = new LocalState({\n cache,\n client: this,\n resolvers,\n fragmentMatcher,\n });\n\n this.queryManager = new QueryManager({\n cache: this.cache,\n link: this.link,\n defaultOptions: this.defaultOptions,\n defaultContext,\n documentTransform,\n queryDeduplication,\n ssrMode,\n clientAwareness: {\n name: clientAwarenessName!,\n version: clientAwarenessVersion!,\n },\n localState: this.localState,\n assumeImmutableResults,\n onBroadcast:\n connectToDevTools ?\n () => {\n if (this.devToolsHookCb) {\n this.devToolsHookCb({\n action: {},\n state: {\n queries: this.queryManager.getQueryStore(),\n mutations: this.queryManager.mutationStore || {},\n },\n dataWithOptimisticResults: this.cache.extract(true),\n });\n }\n }\n : void 0,\n });\n\n if (connectToDevTools) this.connectToDevTools();\n }\n\n private connectToDevTools() {\n if (typeof window === \"object\") {\n type DevToolsConnector = {\n push(client: ApolloClient<any>): void;\n };\n const windowWithDevTools = window as Window & {\n [devtoolsSymbol]?: DevToolsConnector;\n __APOLLO_CLIENT__?: ApolloClient<any>;\n };\n const devtoolsSymbol = Symbol.for(\"apollo.devtools\");\n (windowWithDevTools[devtoolsSymbol] =\n windowWithDevTools[devtoolsSymbol] || ([] as DevToolsConnector)).push(\n this\n );\n windowWithDevTools.__APOLLO_CLIENT__ = this;\n }\n\n /**\n * Suggest installing the devtools for developers who don't have them\n */\n if (!hasSuggestedDevtools && __DEV__) {\n hasSuggestedDevtools = true;\n setTimeout(() => {\n if (\n typeof window !== \"undefined\" &&\n window.document &&\n window.top === window.self &&\n !(window as any).__APOLLO_DEVTOOLS_GLOBAL_HOOK__ &&\n /^(https?|file):$/.test(window.location.protocol)\n ) {\n const nav = window.navigator;\n const ua = nav && nav.userAgent;\n let url: string | undefined;\n if (typeof ua === \"string\") {\n if (ua.indexOf(\"Chrome/\") > -1) {\n url =\n \"https://chrome.google.com/webstore/detail/\" +\n \"apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm\";\n } else if (ua.indexOf(\"Firefox/\") > -1) {\n url =\n \"https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/\";\n }\n }\n if (url) {\n invariant.log(\n \"Download the Apollo DevTools for a better development \" +\n \"experience: %s\",\n url\n );\n }\n }\n }, 10000);\n }\n }\n\n /**\n * The `DocumentTransform` used to modify GraphQL documents before a request\n * is made. If a custom `DocumentTransform` is not provided, this will be the\n * default document transform.\n */\n get documentTransform() {\n return this.queryManager.documentTransform;\n }\n\n /**\n * Call this method to terminate any active client processes, making it safe\n * to dispose of this `ApolloClient` instance.\n */\n public stop() {\n this.queryManager.stop();\n }\n\n /**\n * This watches the cache store of the query according to the options specified and\n * returns an `ObservableQuery`. We can subscribe to this `ObservableQuery` and\n * receive updated results through an observer when the cache store changes.\n *\n * Note that this method is not an implementation of GraphQL subscriptions. Rather,\n * it uses Apollo's store in order to reactively deliver updates to your query results.\n *\n * For example, suppose you call watchQuery on a GraphQL query that fetches a person's\n * first and last name and this person has a particular object identifier, provided by\n * dataIdFromObject. Later, a different query fetches that same person's\n * first and last name and the first name has now changed. Then, any observers associated\n * with the results of the first query will be updated with a new result object.\n *\n * Note that if the cache does not change, the subscriber will *not* be notified.\n *\n * See [here](https://medium.com/apollo-stack/the-concepts-of-graphql-bc68bd819be3#.3mb0cbcmc) for\n * a description of store reactivity.\n */\n public watchQuery<\n T = any,\n TVariables extends OperationVariables = OperationVariables,\n >(options: WatchQueryOptions<TVariables, T>): ObservableQuery<T, TVariables> {\n if (this.defaultOptions.watchQuery) {\n options = mergeOptions(this.defaultOptions.watchQuery, options);\n }\n\n // XXX Overwriting options is probably not the best way to do this long term...\n if (\n this.disableNetworkFetches &&\n (options.fetchPolicy === \"network-only\" ||\n options.fetchPolicy === \"cache-and-network\")\n ) {\n options = { ...options, fetchPolicy: \"cache-first\" };\n }\n\n return this.queryManager.watchQuery<T, TVariables>(options);\n }\n\n /**\n * This resolves a single query according to the options specified and\n * returns a `Promise` which is either resolved with the resulting data\n * or rejected with an error.\n *\n * @param options - An object of type `QueryOptions` that allows us to\n * describe how this query should be treated e.g. whether it should hit the\n * server at all or just resolve from the cache, etc.\n */\n public query<\n T = any,\n TVariables extends OperationVariables = OperationVariables,\n >(options: QueryOptions<TVariables, T>): Promise<ApolloQueryResult<T>> {\n if (this.defaultOptions.query) {\n options = mergeOptions(this.defaultOptions.query, options);\n }\n\n invariant(\n (options.fetchPolicy as WatchQueryFetchPolicy) !== \"cache-and-network\",\n \"The cache-and-network fetchPolicy does not work with client.query, because \" +\n \"client.query can only return a single result. Please use client.watchQuery \" +\n \"to receive multiple results from the cache and the network, or consider \" +\n \"using a different fetchPolicy, such as cache-first or network-only.\"\n );\n\n if (this.disableNetworkFetches && options.fetchPolicy === \"network-only\") {\n options = { ...options, fetchPolicy: \"cache-first\" };\n }\n\n return this.queryManager.query<T, TVariables>(options);\n }\n\n /**\n * This resolves a single mutation according to the options specified and returns a\n * Promise which is either resolved with the resulting data or rejected with an\n * error. In some cases both `data` and `errors` might be undefined, for example\n * when `errorPolicy` is set to `'ignore'`.\n *\n * It takes options as an object with the following keys and values:\n */\n public mutate<\n TData = any,\n TVariables extends OperationVariables = OperationVariables,\n TContext extends Record<string, any> = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n >(\n options: MutationOptions<TData, TVariables, TContext>\n ): Promise<FetchResult<TData>> {\n if (this.defaultOptions.mutate) {\n options = mergeOptions(this.defaultOptions.mutate, options);\n }\n return this.queryManager.mutate<TData, TVariables, TContext, TCache>(\n options\n );\n }\n\n /**\n * This subscribes to a graphql subscription according to the options specified and returns an\n * `Observable` which either emits received data or an error.\n */\n public subscribe<\n T = any,\n TVariables extends OperationVariables = OperationVariables,\n >(options: SubscriptionOptions<TVariables, T>): Observable<FetchResult<T>> {\n return this.queryManager.startGraphQLSubscription<T>(options);\n }\n\n /**\n * Tries to read some data from the store in the shape of the provided\n * GraphQL query without making a network request. This method will start at\n * the root query. To start at a specific id returned by `dataIdFromObject`\n * use `readFragment`.\n *\n * @param optimistic - Set to `true` to allow `readQuery` to return\n * optimistic results. Is `false` by default.\n */\n public readQuery<T = any, TVariables = OperationVariables>(\n options: DataProxy.Query<TVariables, T>,\n optimistic: boolean = false\n ): T | null {\n return this.cache.readQuery<T, TVariables>(options, optimistic);\n }\n\n /**\n * Watches the cache store of the fragment according to the options specified\n * and returns an `Observable`. We can subscribe to this\n * `Observable` and receive updated results through an\n * observer when the cache store changes.\n *\n * You must pass in a GraphQL document with a single fragment or a document\n * with multiple fragments that represent what you are reading. If you pass\n * in a document with multiple fragments then you must also specify a\n * `fragmentName`.\n *\n * @since 3.10.0\n * @param options - An object of type `WatchFragmentOptions` that allows\n * the cache to identify the fragment and optionally specify whether to react\n * to optimistic updates.\n */\n\n public watchFragment<\n TFragmentData = unknown,\n TVariables = OperationVariables,\n >(\n options: WatchFragmentOptions<TFragmentData, TVariables>\n ): Observable<WatchFragmentResult<TFragmentData>> {\n return this.cache.watchFragment<TFragmentData, TVariables>(options);\n }\n\n /**\n * Tries to read some data from the store in the shape of the provided\n * GraphQL fragment without making a network request. This method will read a\n * GraphQL fragment from any arbitrary id that is currently cached, unlike\n * `readQuery` which will only read from the root query.\n *\n * You must pass in a GraphQL document with a single fragment or a document\n * with multiple fragments that represent what you are reading. If you pass\n * in a document with multiple fragments then you must also specify a\n * `fragmentName`.\n *\n * @param optimistic - Set to `true` to allow `readFragment` to return\n * optimistic results. Is `false` by default.\n */\n public readFragment<T = any, TVariables = OperationVariables>(\n options: DataProxy.Fragment<TVariables, T>,\n optimistic: boolean = false\n ): T | null {\n return this.cache.readFragment<T, TVariables>(options, optimistic);\n }\n\n /**\n * Writes some data in the shape of the provided GraphQL query directly to\n * the store. This method will start at the root query. To start at a\n * specific id returned by `dataIdFromObject` then use `writeFragment`.\n */\n public writeQuery<TData = any, TVariables = OperationVariables>(\n options: DataProxy.WriteQueryOptions<TData, TVariables>\n ): Reference | undefined {\n const ref = this.cache.writeQuery<TData, TVariables>(options);\n\n if (options.broadcast !== false) {\n this.queryManager.broadcastQueries();\n }\n\n return ref;\n }\n\n /**\n * Writes some data in the shape of the provided GraphQL fragment directly to\n * the store. This method will write to a GraphQL fragment from any arbitrary\n * id that is currently cached, unlike `writeQuery` which will only write\n * from the root query.\n *\n * You must pass in a GraphQL document with a single fragment or a document\n * with multiple fragments that represent what you are writing. If you pass\n * in a document with multiple fragments then you must also specify a\n * `fragmentName`.\n */\n public writeFragment<TData = any, TVariables = OperationVariables>(\n options: DataProxy.WriteFragmentOptions<TData, TVariables>\n ): Reference | undefined {\n const ref = this.cache.writeFragment<TData, TVariables>(options);\n\n if (options.broadcast !== false) {\n this.queryManager.broadcastQueries();\n }\n\n return ref;\n }\n\n public __actionHookForDevTools(cb: () => any) {\n this.devToolsHookCb = cb;\n }\n\n public __requestRaw(payload: GraphQLRequest): Observable<ExecutionResult> {\n return execute(this.link, payload);\n }\n\n /**\n * Resets your entire store by clearing out your cache and then re-executing\n * all of your active queries. This makes it so that you may guarantee that\n * there is no data left in your store from a time before you called this\n * method.\n *\n * `resetStore()` is useful when your user just logged out. You’ve removed the\n * user session, and you now want to make sure that any references to data you\n * might have fetched while the user session was active is gone.\n *\n * It is important to remember that `resetStore()` *will* refetch any active\n * queries. This means that any components that might be mounted will execute\n * their queries again using your network interface. If you do not want to\n * re-execute any queries then you should make sure to stop watching any\n * active queries.\n */\n public resetStore(): Promise<ApolloQueryResult<any>[] | null> {\n return Promise.resolve()\n .then(() =>\n this.queryManager.clearStore({\n discardWatches: false,\n })\n )\n .then(() => Promise.all(this.resetStoreCallbacks.map((fn) => fn())))\n .then(() => this.reFetchObservableQueries());\n }\n\n /**\n * Remove all data from the store. Unlike `resetStore`, `clearStore` will\n * not refetch any active queries.\n */\n public clearStore(): Promise<any[]> {\n return Promise.resolve()\n .then(() =>\n this.queryManager.clearStore({\n discardWatches: true,\n })\n )\n .then(() => Promise.all(this.clearStoreCallbacks.map((fn) => fn())));\n }\n\n /**\n * Allows callbacks to be registered that are executed when the store is\n * reset. `onResetStore` returns an unsubscribe function that can be used\n * to remove registered callbacks.\n */\n public onResetStore(cb: () => Promise<any>): () => void {\n this.resetStoreCallbacks.push(cb);\n return () => {\n this.resetStoreCallbacks = this.resetStoreCallbacks.filter(\n (c) => c !== cb\n );\n };\n }\n\n /**\n * Allows callbacks to be registered that are executed when the store is\n * cleared. `onClearStore` returns an unsubscribe function that can be used\n * to remove registered callbacks.\n */\n public onClearStore(cb: () => Promise<any>): () => void {\n this.clearStoreCallbacks.push(cb);\n return () => {\n this.clearStoreCallbacks = this.clearStoreCallbacks.filter(\n (c) => c !== cb\n );\n };\n }\n\n /**\n * Refetches all of your active queries.\n *\n * `reFetchObservableQueries()` is useful if you want to bring the client back to proper state in case of a network outage\n *\n * It is important to remember that `reFetchObservableQueries()` *will* refetch any active\n * queries. This means that any components that might be mounted will execute\n * their queries again using your network interface. If you do not want to\n * re-execute any queries then you should make sure to stop watching any\n * active queries.\n * Takes optional parameter `includeStandby` which will include queries in standby-mode when refetching.\n */\n public reFetchObservableQueries(\n includeStandby?: boolean\n ): Promise<ApolloQueryResult<any>[]> {\n return this.queryManager.reFetchObservableQueries(includeStandby);\n }\n\n /**\n * Refetches specified active queries. Similar to \"reFetchObservableQueries()\" but with a specific list of queries.\n *\n * `refetchQueries()` is useful for use cases to imperatively refresh a selection of queries.\n *\n * It is important to remember that `refetchQueries()` *will* refetch specified active\n * queries. This means that any components that might be mounted will execute\n * their queries again using your network interface. If you do not want to\n * re-execute any queries then you should make sure to stop watching any\n * active queries.\n */\n public refetchQueries<\n TCache extends ApolloCache<any> = ApolloCache<TCacheShape>,\n TResult = Promise<ApolloQueryResult<any>>,\n >(\n options: RefetchQueriesOptions<TCache, TResult>\n ): RefetchQueriesResult<TResult> {\n const map = this.queryManager.refetchQueries(\n options as RefetchQueriesOptions<ApolloCache<TCacheShape>, TResult>\n );\n const queries: ObservableQuery<any>[] = [];\n const results: InternalRefetchQueriesResult<TResult>[] = [];\n\n map.forEach((result, obsQuery) => {\n queries.push(obsQuery);\n results.push(result);\n });\n\n const result = Promise.all<TResult>(\n results as TResult[]\n ) as RefetchQueriesResult<TResult>;\n\n // In case you need the raw results immediately, without awaiting\n // Promise.all(results):\n result.queries = queries;\n result.results = results;\n\n // If you decide to ignore the result Promise because you're using\n // result.queries and result.results instead, you shouldn't have to worry\n // about preventing uncaught rejections for the Promise.all result.\n result.catch((error) => {\n invariant.debug(\n `In client.refetchQueries, Promise.all promise rejected with error %o`,\n error\n );\n });\n\n return result;\n }\n\n /**\n * Get all currently active `ObservableQuery` objects, in a `Map` keyed by\n * query ID strings.\n *\n * An \"active\" query is one that has observers and a `fetchPolicy` other than\n * \"standby\" or \"cache-only\".\n *\n * You can include all `ObservableQuery` objects (including the inactive ones)\n * by passing \"all\" instead of \"active\", or you can include just a subset of\n * active queries by passing an array of query names or DocumentNode objects.\n */\n public getObservableQueries(\n include: RefetchQueriesInclude = \"active\"\n ): Map<string, ObservableQuery<any>> {\n return this.queryManager.getObservableQueries(include);\n }\n\n /**\n * Exposes the cache's complete state, in a serializable format for later restoration.\n */\n public extract(optimistic?: boolean): TCacheShape {\n return this.cache.extract(optimistic);\n }\n\n /**\n * Replaces existing state in the cache (if any) with the values expressed by\n * `serializedState`.\n *\n * Called when hydrating a cache (server side rendering, or offline storage),\n * and also (potentially) during hot reloads.\n */\n public restore(serializedState: TCacheShape): ApolloCache<TCacheShape> {\n return this.cache.restore(serializedState);\n }\n\n /**\n * Add additional local resolvers.\n */\n public addResolvers(resolvers: Resolvers | Resolvers[]) {\n this.localState.addResolvers(resolvers);\n }\n\n /**\n * Set (override existing) local resolvers.\n */\n public setResolvers(resolvers: Resolvers | Resolvers[]) {\n this.localState.setResolvers(resolvers);\n }\n\n /**\n * Get all registered local resolvers.\n */\n public getResolvers() {\n return this.localState.getResolvers();\n }\n\n /**\n * Set a custom local state fragment matcher.\n */\n public setLocalStateFragmentMatcher(fragmentMatcher: FragmentMatcher) {\n this.localState.setFragmentMatcher(fragmentMatcher);\n }\n\n /**\n * Define a new ApolloLink (or link chain) that Apollo Client will use.\n */\n public setLink(newLink: ApolloLink) {\n this.link = this.queryManager.link = newLink;\n }\n\n public get defaultContext() {\n return this.queryManager.defaultContext;\n }\n\n /**\n * @experimental\n * This is not a stable API - it is used in development builds to expose\n * information to the DevTools.\n * Use at your own risk!\n * For more details, see [Memory Management](https://www.apollographql.com/docs/react/caching/memory-management/#measuring-cache-usage)\n *\n * @example\n * ```ts\n * console.log(client.getMemoryInternals())\n * ```\n * Logs output in the following JSON format:\n * @example\n * ```json\n *{\n * limits: {\n * parser: 1000,\n * canonicalStringify: 1000,\n * print: 2000,\n * 'documentTransform.cache': 2000,\n * 'queryManager.getDocumentInfo': 2000,\n * 'PersistedQueryLink.persistedQueryHashes': 2000,\n * 'fragmentRegistry.transform': 2000,\n * 'fragmentRegistry.lookup': 1000,\n * 'fragmentRegistry.findFragmentSpreads': 4000,\n * 'cache.fragmentQueryDocuments': 1000,\n * 'removeTypenameFromVariables.getVariableDefinitions': 2000,\n * 'inMemoryCache.maybeBroadcastWatch': 5000,\n * 'inMemoryCache.executeSelectionSet': 10000,\n * 'inMemoryCache.executeSubSelectedArray': 5000\n * },\n * sizes: {\n * parser: 26,\n * canonicalStringify: 4,\n * print: 14,\n * addTypenameDocumentTransform: [\n * {\n * cache: 14,\n * },\n * ],\n * queryManager: {\n * getDocumentInfo: 14,\n * documentTransforms: [\n * {\n * cache: 14,\n * },\n * {\n * cache: 14,\n * },\n * ],\n * },\n * fragmentRegistry: {\n * findFragmentSpreads: 34,\n * lookup: 20,\n * transform: 14,\n * },\n * cache: {\n * fragmentQueryDocuments: 22,\n * },\n * inMemoryCache: {\n * executeSelectionSet: 4345,\n * executeSubSelectedArray: 1206,\n * maybeBroadcastWatch: 32,\n * },\n * links: [\n * {\n * PersistedQueryLink: {\n * persistedQueryHashes: 14,\n * },\n * },\n * {\n * removeTypenameFromVariables: {\n * getVariableDefinitions: 14,\n * },\n * },\n * ],\n * },\n * }\n *```\n */\n public getMemoryInternals?: typeof getApolloClientMemoryInternals;\n}\n\nif (__DEV__) {\n ApolloClient.prototype.getMemoryInternals = getApolloClientMemoryInternals;\n}\n"]}
@@ -542,7 +542,7 @@ var ObservableQuery = /** @class */ (function (_super) {
542
542
  return;
543
543
  }
544
544
  var _a = this, pollingInfo = _a.pollingInfo, pollInterval = _a.options.pollInterval;
545
- if (!pollInterval) {
545
+ if (!pollInterval || !this.hasObservers()) {
546
546
  if (pollingInfo) {
547
547
  clearTimeout(pollingInfo.timeout);
548
548
  delete this.pollingInfo;