@apollo/client 3.14.0-alpha.0 → 3.14.0-rc.0

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 (200) hide show
  1. package/.changeset/breezy-lions-rule.md +5 -0
  2. package/.changeset/great-jobs-fetch.md +5 -0
  3. package/.changeset/pre.json +6 -2
  4. package/.changeset/shy-boxes-exercise.md +5 -0
  5. package/.changeset/tidy-bulldogs-exercise.md +5 -0
  6. package/CHANGELOG.md +16 -0
  7. package/README.md +2 -2
  8. package/apollo-client.cjs +187 -119
  9. package/apollo-client.cjs.map +1 -1
  10. package/apollo-client.min.cjs +1 -1
  11. package/cache/cache.cjs +7 -2
  12. package/cache/cache.cjs.map +1 -1
  13. package/cache/cache.cjs.native.js +7 -2
  14. package/cache/inmemory/inMemoryCache.d.ts +8 -0
  15. package/cache/inmemory/inMemoryCache.js +3 -0
  16. package/cache/inmemory/inMemoryCache.js.map +1 -1
  17. package/core/ApolloClient.d.ts +9 -9
  18. package/core/ApolloClient.js +6 -1
  19. package/core/ApolloClient.js.map +1 -1
  20. package/core/LocalState.js +2 -2
  21. package/core/ObservableQuery.d.ts +51 -6
  22. package/core/ObservableQuery.js +89 -13
  23. package/core/ObservableQuery.js.map +1 -1
  24. package/core/QueryInfo.js +6 -3
  25. package/core/QueryInfo.js.map +1 -1
  26. package/core/QueryManager.js +14 -12
  27. package/core/QueryManager.js.map +1 -1
  28. package/core/core.cjs +85 -33
  29. package/core/core.cjs.map +1 -1
  30. package/core/core.cjs.native.js +85 -33
  31. package/core/types.d.ts +177 -3
  32. package/core/types.js.map +1 -1
  33. package/core/watchQueryOptions.d.ts +10 -2
  34. package/core/watchQueryOptions.js.map +1 -1
  35. package/dev/dev.cjs +149 -97
  36. package/dev/dev.cjs.map +1 -1
  37. package/dev/dev.cjs.native.js +149 -97
  38. package/errors/errors.cjs.map +1 -1
  39. package/errors/index.d.ts +19 -0
  40. package/errors/index.js +19 -0
  41. package/errors/index.js.map +1 -1
  42. package/invariantErrorCodes.js +161 -96
  43. package/link/batch-http/batch-http.cjs +9 -0
  44. package/link/batch-http/batch-http.cjs.map +1 -1
  45. package/link/batch-http/batch-http.cjs.native.js +9 -0
  46. package/link/batch-http/batchHttpLink.js +9 -0
  47. package/link/batch-http/batchHttpLink.js.map +1 -1
  48. package/link/core/ApolloLink.d.ts +8 -0
  49. package/link/core/ApolloLink.js +19 -2
  50. package/link/core/ApolloLink.js.map +1 -1
  51. package/link/core/core.cjs +24 -2
  52. package/link/core/core.cjs.map +1 -1
  53. package/link/core/core.cjs.native.js +24 -2
  54. package/link/core/types.d.ts +20 -0
  55. package/link/core/types.js.map +1 -1
  56. package/link/error/index.d.ts +48 -0
  57. package/link/error/index.js.map +1 -1
  58. package/link/http/checkFetcher.js +1 -1
  59. package/link/http/createHttpLink.js +4 -1
  60. package/link/http/createHttpLink.js.map +1 -1
  61. package/link/http/http.cjs +6 -3
  62. package/link/http/http.cjs.map +1 -1
  63. package/link/http/http.cjs.native.js +6 -3
  64. package/link/http/serializeFetchParameter.js +1 -1
  65. package/link/persisted-queries/index.d.ts +38 -0
  66. package/link/persisted-queries/index.js +2 -2
  67. package/link/persisted-queries/index.js.map +1 -1
  68. package/link/persisted-queries/persisted-queries.cjs +2 -2
  69. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  70. package/link/persisted-queries/persisted-queries.cjs.native.js +2 -2
  71. package/link/utils/fromError.d.ts +16 -0
  72. package/link/utils/fromError.js +16 -0
  73. package/link/utils/fromError.js.map +1 -1
  74. package/link/utils/fromPromise.d.ts +16 -0
  75. package/link/utils/fromPromise.js +16 -0
  76. package/link/utils/fromPromise.js.map +1 -1
  77. package/link/utils/throwServerError.d.ts +30 -0
  78. package/link/utils/throwServerError.js +17 -0
  79. package/link/utils/throwServerError.js.map +1 -1
  80. package/link/utils/toPromise.d.ts +16 -0
  81. package/link/utils/toPromise.js +17 -1
  82. package/link/utils/toPromise.js.map +1 -1
  83. package/link/utils/utils.cjs +2 -2
  84. package/link/utils/utils.cjs.map +1 -1
  85. package/link/utils/utils.cjs.native.js +2 -2
  86. package/link/utils/validateOperation.js +1 -1
  87. package/masking/maskDefinition.js +2 -2
  88. package/masking/maskFragment.js +2 -2
  89. package/masking/maskOperation.js +1 -1
  90. package/masking/masking.cjs +6 -6
  91. package/masking/masking.cjs.map +1 -1
  92. package/masking/masking.cjs.native.js +6 -6
  93. package/masking/utils.js +1 -1
  94. package/masking/utils.js.map +1 -1
  95. package/package.json +1 -1
  96. package/react/components/Mutation.js +1 -1
  97. package/react/components/Query.js +1 -1
  98. package/react/components/Subscription.js +1 -1
  99. package/react/components/components.cjs +6 -4
  100. package/react/components/components.cjs.map +1 -1
  101. package/react/components/components.cjs.native.js +6 -4
  102. package/react/context/ApolloConsumer.js +1 -1
  103. package/react/context/ApolloContext.js +2 -2
  104. package/react/context/ApolloProvider.js +1 -1
  105. package/react/context/context.cjs +4 -4
  106. package/react/context/context.cjs.map +1 -1
  107. package/react/context/context.cjs.native.js +4 -4
  108. package/react/hoc/graphql.js +1 -1
  109. package/react/hoc/hoc-utils.js +1 -1
  110. package/react/hoc/hoc.cjs +9 -7
  111. package/react/hoc/hoc.cjs.map +1 -1
  112. package/react/hoc/hoc.cjs.native.js +9 -7
  113. package/react/hoc/mutation-hoc.js +1 -1
  114. package/react/hoc/query-hoc.js +1 -1
  115. package/react/hoc/subscription-hoc.js +1 -1
  116. package/react/hoc/withApollo.js +1 -1
  117. package/react/hooks/hooks.cjs +18 -16
  118. package/react/hooks/hooks.cjs.map +1 -1
  119. package/react/hooks/hooks.cjs.native.js +18 -16
  120. package/react/hooks/internal/useWarnRemoved.d.ts +2 -1
  121. package/react/hooks/internal/useWarnRemoved.js.map +1 -1
  122. package/react/hooks/internal/useWarnRemovedOption.js +1 -1
  123. package/react/hooks/useApolloClient.js +1 -1
  124. package/react/hooks/useLazyQuery.js +2 -2
  125. package/react/hooks/useLoadableQuery.js +2 -2
  126. package/react/hooks/useQuery.js +1 -1
  127. package/react/hooks/useSubscription.js +3 -3
  128. package/react/hooks/useSuspenseQuery.js +2 -2
  129. package/react/hooks/useSyncExternalStore.js +1 -1
  130. package/react/internal/cache/QueryReference.d.ts +1 -0
  131. package/react/internal/cache/QueryReference.js +5 -2
  132. package/react/internal/cache/QueryReference.js.map +1 -1
  133. package/react/internal/internal.cjs +16 -3
  134. package/react/internal/internal.cjs.map +1 -1
  135. package/react/internal/internal.cjs.native.js +16 -3
  136. package/react/parser/index.js +6 -6
  137. package/react/parser/parser.cjs +9 -7
  138. package/react/parser/parser.cjs.map +1 -1
  139. package/react/parser/parser.cjs.native.js +9 -7
  140. package/react/react.cjs +4 -2
  141. package/react/react.cjs.map +1 -1
  142. package/react/react.cjs.native.js +4 -2
  143. package/react/types/types.d.ts +40 -0
  144. package/react/types/types.documentation.d.ts +1 -1
  145. package/react/types/types.documentation.js.map +1 -1
  146. package/react/types/types.js.map +1 -1
  147. package/testing/core/core.cjs +17 -3
  148. package/testing/core/core.cjs.map +1 -1
  149. package/testing/core/core.cjs.native.js +17 -3
  150. package/testing/core/itAsync.d.ts +5 -0
  151. package/testing/core/itAsync.js +5 -0
  152. package/testing/core/itAsync.js.map +1 -1
  153. package/testing/core/mocking/mockClient.d.ts +4 -0
  154. package/testing/core/mocking/mockClient.js +4 -0
  155. package/testing/core/mocking/mockClient.js.map +1 -1
  156. package/testing/core/mocking/mockLink.d.ts +10 -0
  157. package/testing/core/mocking/mockLink.js +23 -4
  158. package/testing/core/mocking/mockLink.js.map +1 -1
  159. package/testing/core/mocking/mockSubscriptionLink.d.ts +4 -0
  160. package/testing/core/mocking/mockSubscriptionLink.js +4 -0
  161. package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
  162. package/testing/core/subscribeAndCount.d.ts +4 -0
  163. package/testing/core/subscribeAndCount.js +4 -0
  164. package/testing/core/subscribeAndCount.js.map +1 -1
  165. package/testing/experimental/createSchemaFetch.d.ts +1 -1
  166. package/testing/experimental/createSchemaFetch.js +1 -1
  167. package/testing/experimental/createSchemaFetch.js.map +1 -1
  168. package/testing/experimental/createTestSchema.d.ts +1 -1
  169. package/testing/experimental/createTestSchema.js +1 -1
  170. package/testing/experimental/createTestSchema.js.map +1 -1
  171. package/testing/experimental/experimental.cjs.map +1 -1
  172. package/testing/testing.cjs +4 -2
  173. package/testing/testing.cjs.map +1 -1
  174. package/testing/testing.cjs.native.js +4 -2
  175. package/utilities/deprecation/index.d.ts +83 -3
  176. package/utilities/deprecation/index.js +15 -3
  177. package/utilities/deprecation/index.js.map +1 -1
  178. package/utilities/globals/globals.cjs +1 -1
  179. package/utilities/globals/globals.cjs.map +1 -1
  180. package/utilities/globals/globals.cjs.native.js +1 -1
  181. package/utilities/graphql/DocumentTransform.js +1 -1
  182. package/utilities/graphql/directives.js +7 -7
  183. package/utilities/graphql/fragments.js +3 -3
  184. package/utilities/graphql/getFromAST.js +8 -8
  185. package/utilities/graphql/storeUtils.js +1 -1
  186. package/utilities/graphql/transform.js +2 -2
  187. package/utilities/observables/asyncMap.d.ts +13 -0
  188. package/utilities/observables/asyncMap.js +13 -0
  189. package/utilities/observables/asyncMap.js.map +1 -1
  190. package/utilities/observables/iteration.d.ts +4 -0
  191. package/utilities/observables/iteration.js +4 -0
  192. package/utilities/observables/iteration.js.map +1 -1
  193. package/utilities/subscriptions/urql/index.d.ts +5 -0
  194. package/utilities/subscriptions/urql/index.js +5 -0
  195. package/utilities/subscriptions/urql/index.js.map +1 -1
  196. package/utilities/subscriptions/urql/urql.cjs.map +1 -1
  197. package/utilities/utilities.cjs +22 -22
  198. package/utilities/utilities.cjs.map +1 -1
  199. package/utilities/utilities.cjs.native.js +22 -22
  200. package/version.js +1 -1
package/core/QueryInfo.js CHANGED
@@ -123,7 +123,8 @@ var QueryInfo = /** @class */ (function () {
123
123
  };
124
124
  };
125
125
  QueryInfo.prototype.setDiff = function (diff) {
126
- var _a, _b;
126
+ var _this = this;
127
+ var _a;
127
128
  var oldDiff = this.lastDiff && this.lastDiff.diff;
128
129
  // If we are trying to deliver an incomplete cache result, we avoid
129
130
  // reporting it if the query has errored, otherwise we let the broadcast try
@@ -134,12 +135,14 @@ var QueryInfo = /** @class */ (function () {
134
135
  //
135
136
  // See https://github.com/apollographql/apollo-client/issues/11400 for more
136
137
  // information on this issue.
137
- if (diff && !diff.complete && ((_a = this.observableQuery) === null || _a === void 0 ? void 0 : _a.getLastError())) {
138
+ if (diff &&
139
+ !diff.complete &&
140
+ muteDeprecations("getLastError", function () { var _a; return (_a = _this.observableQuery) === null || _a === void 0 ? void 0 : _a.getLastError(); })) {
138
141
  return;
139
142
  }
140
143
  this.updateLastDiff(diff);
141
144
  if (!equal(oldDiff && oldDiff.result, diff && diff.result)) {
142
- (_b = this.observableQuery) === null || _b === void 0 ? void 0 : _b["scheduleNotify"]();
145
+ (_a = this.observableQuery) === null || _a === void 0 ? void 0 : _a["scheduleNotify"]();
143
146
  }
144
147
  };
145
148
  QueryInfo.prototype.setObservableQuery = function (oq) {
@@ -1 +1 @@
1
- {"version":3,"file":"QueryInfo.js","sourceRoot":"","sources":["../../src/core/QueryInfo.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAI7D,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAInD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAarE,IAAM,uBAAuB,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAGhE,CAAC;AAEJ,SAAS,0BAA0B,CACjC,KAAuB,EACvB,UAAwC;IAExC,IAAM,QAAQ,GAAG,KAAK,CAA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CAAC;IAEM,6BAAS,GAAhB;QACE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC;IAEM,6BAAS,GAAhB,UAAiB,KAAkB;;QACjC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC;QACzC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC;QAExB,MAAA,IAAI,CAAC,eAAe,0CAAG,oBAAoB,GAAG,CAAC;QAE/C,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;YACxB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;QAC3C,CAAC;QAED,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;YACvB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;QACzC,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IACH,gBAAC;AAAD,CAAC,AA9XD,IA8XC;;AAED,MAAM,UAAU,iBAAiB,CAC/B,MAAsB,EACtB,WAAiC;IAAjC,4BAAA,EAAA,oBAAiC;IAEjC,IAAM,YAAY,GAAG,WAAW,KAAK,QAAQ,IAAI,WAAW,KAAK,KAAK,CAAC;IACvE,IAAI,eAAe,GAAG,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACrD,IAAI,CAAC,eAAe,IAAI,YAAY,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QACpD,eAAe,GAAG,IAAI,CAAC;IACzB,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import type { DocumentNode, GraphQLFormattedError } from \"graphql\";\nimport { equal } from \"@wry/equality\";\n\nimport type { Cache, ApolloCache } from \"../cache/index.js\";\nimport { DeepMerger } from \"../utilities/index.js\";\nimport { mergeIncrementalData } from \"../utilities/index.js\";\nimport type { WatchQueryOptions, ErrorPolicy } from \"./watchQueryOptions.js\";\nimport type { ObservableQuery } from \"./ObservableQuery.js\";\nimport type { FetchResult } from \"../link/core/index.js\";\nimport {\n isNonEmptyArray,\n graphQLResultHasError,\n canUseWeakMap,\n} from \"../utilities/index.js\";\nimport { NetworkStatus } from \"./networkStatus.js\";\nimport type { ApolloError } from \"../errors/index.js\";\nimport type { QueryManager } from \"./QueryManager.js\";\nimport type { Unmasked } from \"../masking/index.js\";\nimport { muteDeprecations } from \"../utilities/deprecation/index.js\";\n\nexport type QueryStoreValue = Pick<\n QueryInfo,\n \"variables\" | \"networkStatus\" | \"networkError\" | \"graphQLErrors\"\n>;\n\nexport const enum CacheWriteBehavior {\n FORBID,\n OVERWRITE,\n MERGE,\n}\n\nconst destructiveMethodCounts = new (canUseWeakMap ? WeakMap : Map)<\n ApolloCache<any>,\n number\n>();\n\nfunction wrapDestructiveCacheMethod(\n cache: ApolloCache<any>,\n methodName: \"evict\" | \"modify\" | \"reset\"\n) {\n const original = cache[methodName];\n if (typeof original === \"function\") {\n // @ts-expect-error this is just too generic to be typed correctly\n cache[methodName] = function () {\n destructiveMethodCounts.set(\n cache,\n // The %1e15 allows the count to wrap around to 0 safely every\n // quadrillion evictions, so there's no risk of overflow. To be\n // clear, this is more of a pedantic principle than something\n // that matters in any conceivable practical scenario.\n (destructiveMethodCounts.get(cache)! + 1) % 1e15\n );\n // @ts-expect-error this is just too generic to be typed correctly\n return original.apply(this, arguments);\n };\n }\n}\n\n// A QueryInfo object represents a single query managed by the\n// QueryManager, which tracks all QueryInfo objects by queryId in its\n// this.queries Map. QueryInfo objects store the latest results and errors\n// for the given query, and are responsible for reporting those results to\n// the corresponding ObservableQuery, via the QueryInfo.notify method.\n// Results are reported asynchronously whenever setDiff marks the\n// QueryInfo object as dirty, though a call to the QueryManager's\n// broadcastQueries method may trigger the notification before it happens\n// automatically. This class used to be a simple interface type without\n// any field privacy or meaningful methods, which is why it still has so\n// many public fields. The effort to lock down and simplify the QueryInfo\n// interface is ongoing, and further improvements are welcome.\nexport class QueryInfo {\n document: DocumentNode | null = null;\n lastRequestId = 1;\n variables?: Record<string, any>;\n networkStatus?: NetworkStatus;\n networkError?: Error | null;\n graphQLErrors?: ReadonlyArray<GraphQLFormattedError>;\n stopped = false;\n\n private cancelWatch?: () => void;\n private cache: ApolloCache<any>;\n\n constructor(\n queryManager: QueryManager<any>,\n public readonly queryId = queryManager.generateQueryId()\n ) {\n const cache = (this.cache = queryManager.cache);\n\n // Track how often cache.evict is called, since we want eviction to\n // override the feud-stopping logic in the markResult method, by\n // causing shouldWrite to return true. Wrapping the cache.evict method\n // is a bit of a hack, but it saves us from having to make eviction\n // counting an official part of the ApolloCache API.\n if (!destructiveMethodCounts.has(cache)) {\n destructiveMethodCounts.set(cache, 0);\n wrapDestructiveCacheMethod(cache, \"evict\");\n wrapDestructiveCacheMethod(cache, \"modify\");\n wrapDestructiveCacheMethod(cache, \"reset\");\n }\n }\n\n public init(query: {\n document: DocumentNode;\n variables: Record<string, any> | undefined;\n // The initial networkStatus for this fetch, most often\n // NetworkStatus.loading, but also possibly fetchMore, poll, refetch,\n // or setVariables.\n networkStatus?: NetworkStatus;\n observableQuery?: ObservableQuery<any, any>;\n lastRequestId?: number;\n }): this {\n let networkStatus = query.networkStatus || NetworkStatus.loading;\n if (\n this.variables &&\n this.networkStatus !== NetworkStatus.loading &&\n !equal(this.variables, query.variables)\n ) {\n networkStatus = NetworkStatus.setVariables;\n }\n\n if (!equal(query.variables, this.variables)) {\n this.lastDiff = void 0;\n // Ensure we don't continue to receive cache updates for old variables\n this.cancel();\n }\n\n Object.assign(this, {\n document: query.document,\n variables: query.variables,\n networkError: null,\n graphQLErrors: this.graphQLErrors || [],\n networkStatus,\n });\n\n if (query.observableQuery) {\n this.setObservableQuery(query.observableQuery);\n }\n\n if (query.lastRequestId) {\n this.lastRequestId = query.lastRequestId;\n }\n\n return this;\n }\n\n resetDiff() {\n this.lastDiff = void 0;\n }\n\n getDiff(): Cache.DiffResult<any> {\n const options = this.getDiffOptions();\n\n if (this.lastDiff && equal(options, this.lastDiff.options)) {\n return this.lastDiff.diff;\n }\n\n this.updateWatch(this.variables);\n\n const oq = this.observableQuery;\n if (oq && oq.options.fetchPolicy === \"no-cache\") {\n return { complete: false };\n }\n\n const diff = muteDeprecations(\"canonizeResults\", () =>\n this.cache.diff(options)\n );\n this.updateLastDiff(diff, options);\n return diff;\n }\n\n private lastDiff?: {\n diff: Cache.DiffResult<any>;\n options: Cache.DiffOptions;\n };\n\n private updateLastDiff(\n diff: Cache.DiffResult<any> | null,\n options?: Cache.DiffOptions\n ) {\n this.lastDiff =\n diff ?\n {\n diff,\n options: options || this.getDiffOptions(),\n }\n : void 0;\n }\n\n private getDiffOptions(variables = this.variables): Cache.DiffOptions {\n return {\n query: this.document!,\n variables,\n returnPartialData: true,\n optimistic: true,\n canonizeResults: this.observableQuery?.options.canonizeResults,\n };\n }\n\n setDiff(diff: Cache.DiffResult<any> | null) {\n const oldDiff = this.lastDiff && this.lastDiff.diff;\n\n // If we are trying to deliver an incomplete cache result, we avoid\n // reporting it if the query has errored, otherwise we let the broadcast try\n // and repair the partial result by refetching the query. This check avoids\n // a situation where a query that errors and another succeeds with\n // overlapping data does not report the partial data result to the errored\n // query.\n //\n // See https://github.com/apollographql/apollo-client/issues/11400 for more\n // information on this issue.\n if (diff && !diff.complete && this.observableQuery?.getLastError()) {\n return;\n }\n\n this.updateLastDiff(diff);\n\n if (!equal(oldDiff && oldDiff.result, diff && diff.result)) {\n this.observableQuery?.[\"scheduleNotify\"]();\n }\n }\n\n public readonly observableQuery: ObservableQuery<any, any> | null = null;\n setObservableQuery(oq: ObservableQuery<any, any> | null) {\n if (oq === this.observableQuery) return;\n (this as any).observableQuery = oq;\n if (oq) {\n oq[\"queryInfo\"] = this;\n }\n }\n\n public stop() {\n if (!this.stopped) {\n this.stopped = true;\n\n // Cancel the pending notify timeout\n this.observableQuery?.[\"resetNotifications\"]();\n this.cancel();\n\n const oq = this.observableQuery;\n if (oq) oq.stopPolling();\n }\n }\n\n private cancel() {\n this.cancelWatch?.();\n this.cancelWatch = void 0;\n }\n\n private lastWatch?: Cache.WatchOptions;\n\n private updateWatch(variables = this.variables) {\n const oq = this.observableQuery;\n if (oq && oq.options.fetchPolicy === \"no-cache\") {\n return;\n }\n\n const watchOptions: Cache.WatchOptions = {\n // Although this.getDiffOptions returns Cache.DiffOptions instead of\n // Cache.WatchOptions, all the overlapping options should be the same, so\n // we can reuse getDiffOptions here, for consistency.\n ...this.getDiffOptions(variables),\n watcher: this,\n callback: (diff) => this.setDiff(diff),\n };\n\n if (!this.lastWatch || !equal(watchOptions, this.lastWatch)) {\n this.cancel();\n this.cancelWatch = this.cache.watch((this.lastWatch = watchOptions));\n }\n }\n\n private lastWrite?: {\n result: FetchResult<any>;\n variables: WatchQueryOptions[\"variables\"];\n dmCount: number | undefined;\n };\n\n public resetLastWrite() {\n this.lastWrite = void 0;\n }\n\n private shouldWrite(\n result: FetchResult<any>,\n variables: WatchQueryOptions[\"variables\"]\n ) {\n const { lastWrite } = this;\n return !(\n lastWrite &&\n // If cache.evict has been called since the last time we wrote this\n // data into the cache, there's a chance writing this result into\n // the cache will repair what was evicted.\n lastWrite.dmCount === destructiveMethodCounts.get(this.cache) &&\n equal(variables, lastWrite.variables) &&\n equal(result.data, lastWrite.result.data)\n );\n }\n\n public markResult<T>(\n result: FetchResult<T>,\n document: DocumentNode,\n options: Pick<\n WatchQueryOptions,\n \"variables\" | \"fetchPolicy\" | \"errorPolicy\"\n >,\n cacheWriteBehavior: CacheWriteBehavior\n ) {\n const merger = new DeepMerger();\n const graphQLErrors =\n isNonEmptyArray(result.errors) ? result.errors.slice(0) : [];\n\n // Cancel the pending notify timeout (if it exists) to prevent extraneous network\n // requests. To allow future notify timeouts, diff and dirty are reset as well.\n this.observableQuery?.[\"resetNotifications\"]();\n\n if (\"incremental\" in result && isNonEmptyArray(result.incremental)) {\n const mergedData = mergeIncrementalData(this.getDiff().result, result);\n result.data = mergedData;\n\n // Detect the first chunk of a deferred query and merge it with existing\n // cache data. This ensures a `cache-first` fetch policy that returns\n // partial cache data or a `cache-and-network` fetch policy that already\n // has full data in the cache does not complain when trying to merge the\n // initial deferred server data with existing cache data.\n } else if (\"hasNext\" in result && result.hasNext) {\n const diff = this.getDiff();\n result.data = merger.merge(diff.result, result.data);\n }\n\n this.graphQLErrors = graphQLErrors;\n\n if (options.fetchPolicy === \"no-cache\") {\n this.updateLastDiff(\n { result: result.data, complete: true },\n this.getDiffOptions(options.variables)\n );\n } else if (cacheWriteBehavior !== CacheWriteBehavior.FORBID) {\n if (shouldWriteResult(result, options.errorPolicy)) {\n // Using a transaction here so we have a chance to read the result\n // back from the cache before the watch callback fires as a result\n // of writeQuery, so we can store the new diff quietly and ignore\n // it when we receive it redundantly from the watch callback.\n this.cache.performTransaction((cache) => {\n if (this.shouldWrite(result, options.variables)) {\n cache.writeQuery({\n query: document,\n data: result.data as Unmasked<T>,\n variables: options.variables,\n overwrite: cacheWriteBehavior === CacheWriteBehavior.OVERWRITE,\n });\n\n this.lastWrite = {\n result,\n variables: options.variables,\n dmCount: destructiveMethodCounts.get(this.cache),\n };\n } else {\n // If result is the same as the last result we received from\n // the network (and the variables match too), avoid writing\n // result into the cache again. The wisdom of skipping this\n // cache write is far from obvious, since any cache write\n // could be the one that puts the cache back into a desired\n // state, fixing corruption or missing data. However, if we\n // always write every network result into the cache, we enable\n // feuds between queries competing to update the same data in\n // incompatible ways, which can lead to an endless cycle of\n // cache broadcasts and useless network requests. As with any\n // feud, eventually one side must step back from the brink,\n // letting the other side(s) have the last word(s). There may\n // be other points where we could break this cycle, such as\n // silencing the broadcast for cache.writeQuery (not a good\n // idea, since it just delays the feud a bit) or somehow\n // avoiding the network request that just happened (also bad,\n // because the server could return useful new data). All\n // options considered, skipping this cache write seems to be\n // the least damaging place to break the cycle, because it\n // reflects the intuition that we recently wrote this exact\n // result into the cache, so the cache *should* already/still\n // contain this data. If some other query has clobbered that\n // data in the meantime, that's too bad, but there will be no\n // winners if every query blindly reverts to its own version\n // of the data. This approach also gives the network a chance\n // to return new data, which will be written into the cache as\n // usual, notifying only those queries that are directly\n // affected by the cache updates, as usual. In the future, an\n // even more sophisticated cache could perhaps prevent or\n // mitigate the clobbering somehow, but that would make this\n // particular cache write even less important, and thus\n // skipping it would be even safer than it is today.\n if (this.lastDiff && this.lastDiff.diff.complete) {\n // Reuse data from the last good (complete) diff that we\n // received, when possible.\n result.data = this.lastDiff.diff.result;\n return;\n }\n // If the previous this.diff was incomplete, fall through to\n // re-reading the latest data with cache.diff, below.\n }\n\n const diffOptions = this.getDiffOptions(options.variables);\n const diff = muteDeprecations(\"canonizeResults\", () =>\n cache.diff<T>(diffOptions)\n );\n\n // In case the QueryManager stops this QueryInfo before its\n // results are delivered, it's important to avoid restarting the\n // cache watch when markResult is called. We also avoid updating\n // the watch if we are writing a result that doesn't match the current\n // variables to avoid race conditions from broadcasting the wrong\n // result.\n if (!this.stopped && equal(this.variables, options.variables)) {\n // Any time we're about to update this.diff, we need to make\n // sure we've started watching the cache.\n this.updateWatch(options.variables);\n }\n\n // If we're allowed to write to the cache, and we can read a\n // complete result from the cache, update result.data to be the\n // result from the cache, rather than the raw network result.\n // Set without setDiff to avoid triggering a notify call, since\n // we have other ways of notifying for this result.\n this.updateLastDiff(diff, diffOptions);\n if (diff.complete) {\n result.data = diff.result;\n }\n });\n } else {\n this.lastWrite = void 0;\n }\n }\n }\n\n public markReady() {\n this.networkError = null;\n return (this.networkStatus = NetworkStatus.ready);\n }\n\n public markError(error: ApolloError) {\n this.networkStatus = NetworkStatus.error;\n this.lastWrite = void 0;\n\n this.observableQuery?.[\"resetNotifications\"]();\n\n if (error.graphQLErrors) {\n this.graphQLErrors = error.graphQLErrors;\n }\n\n if (error.networkError) {\n this.networkError = error.networkError;\n }\n\n return error;\n }\n}\n\nexport function shouldWriteResult<T>(\n result: FetchResult<T>,\n errorPolicy: ErrorPolicy = \"none\"\n) {\n const ignoreErrors = errorPolicy === \"ignore\" || errorPolicy === \"all\";\n let writeWithErrors = !graphQLResultHasError(result);\n if (!writeWithErrors && ignoreErrors && result.data) {\n writeWithErrors = true;\n }\n return writeWithErrors;\n}\n"]}
1
+ {"version":3,"file":"QueryInfo.js","sourceRoot":"","sources":["../../src/core/QueryInfo.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAI7D,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAInD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAarE,IAAM,uBAAuB,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAGhE,CAAC;AAEJ,SAAS,0BAA0B,CACjC,KAAuB,EACvB,UAAwC;IAExC,IAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IACnC,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QACnC,kEAAkE;QAClE,KAAK,CAAC,UAAU,CAAC,GAAG;YAClB,uBAAuB,CAAC,GAAG,CACzB,KAAK;YACL,8DAA8D;YAC9D,+DAA+D;YAC/D,6DAA6D;YAC7D,sDAAsD;YACtD,CAAC,uBAAuB,CAAC,GAAG,CAAC,KAAK,CAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CACjD,CAAC;YACF,kEAAkE;YAClE,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACzC,CAAC,CAAC;IACJ,CAAC;AACH,CAAC;AAED,8DAA8D;AAC9D,qEAAqE;AACrE,0EAA0E;AAC1E,0EAA0E;AAC1E,sEAAsE;AACtE,iEAAiE;AACjE,iE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,KAAK,CAAC,YAAY,EAAE,CAAC;YACvB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;QACzC,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IACH,gBAAC;AAAD,CAAC,AArYD,IAqYC;;AAED,MAAM,UAAU,iBAAiB,CAC/B,MAAsB,EACtB,WAAiC;IAAjC,4BAAA,EAAA,oBAAiC;IAEjC,IAAM,YAAY,GAAG,WAAW,KAAK,QAAQ,IAAI,WAAW,KAAK,KAAK,CAAC;IACvE,IAAI,eAAe,GAAG,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACrD,IAAI,CAAC,eAAe,IAAI,YAAY,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QACpD,eAAe,GAAG,IAAI,CAAC;IACzB,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import type { DocumentNode, GraphQLFormattedError } from \"graphql\";\nimport { equal } from \"@wry/equality\";\n\nimport type { Cache, ApolloCache } from \"../cache/index.js\";\nimport { DeepMerger } from \"../utilities/index.js\";\nimport { mergeIncrementalData } from \"../utilities/index.js\";\nimport type { WatchQueryOptions, ErrorPolicy } from \"./watchQueryOptions.js\";\nimport type { ObservableQuery } from \"./ObservableQuery.js\";\nimport type { FetchResult } from \"../link/core/index.js\";\nimport {\n isNonEmptyArray,\n graphQLResultHasError,\n canUseWeakMap,\n} from \"../utilities/index.js\";\nimport { NetworkStatus } from \"./networkStatus.js\";\nimport type { ApolloError } from \"../errors/index.js\";\nimport type { QueryManager } from \"./QueryManager.js\";\nimport type { Unmasked } from \"../masking/index.js\";\nimport { muteDeprecations } from \"../utilities/deprecation/index.js\";\n\nexport type QueryStoreValue = Pick<\n QueryInfo,\n \"variables\" | \"networkStatus\" | \"networkError\" | \"graphQLErrors\"\n>;\n\nexport const enum CacheWriteBehavior {\n FORBID,\n OVERWRITE,\n MERGE,\n}\n\nconst destructiveMethodCounts = new (canUseWeakMap ? WeakMap : Map)<\n ApolloCache<any>,\n number\n>();\n\nfunction wrapDestructiveCacheMethod(\n cache: ApolloCache<any>,\n methodName: \"evict\" | \"modify\" | \"reset\"\n) {\n const original = cache[methodName];\n if (typeof original === \"function\") {\n // @ts-expect-error this is just too generic to be typed correctly\n cache[methodName] = function () {\n destructiveMethodCounts.set(\n cache,\n // The %1e15 allows the count to wrap around to 0 safely every\n // quadrillion evictions, so there's no risk of overflow. To be\n // clear, this is more of a pedantic principle than something\n // that matters in any conceivable practical scenario.\n (destructiveMethodCounts.get(cache)! + 1) % 1e15\n );\n // @ts-expect-error this is just too generic to be typed correctly\n return original.apply(this, arguments);\n };\n }\n}\n\n// A QueryInfo object represents a single query managed by the\n// QueryManager, which tracks all QueryInfo objects by queryId in its\n// this.queries Map. QueryInfo objects store the latest results and errors\n// for the given query, and are responsible for reporting those results to\n// the corresponding ObservableQuery, via the QueryInfo.notify method.\n// Results are reported asynchronously whenever setDiff marks the\n// QueryInfo object as dirty, though a call to the QueryManager's\n// broadcastQueries method may trigger the notification before it happens\n// automatically. This class used to be a simple interface type without\n// any field privacy or meaningful methods, which is why it still has so\n// many public fields. The effort to lock down and simplify the QueryInfo\n// interface is ongoing, and further improvements are welcome.\nexport class QueryInfo {\n document: DocumentNode | null = null;\n lastRequestId = 1;\n variables?: Record<string, any>;\n networkStatus?: NetworkStatus;\n networkError?: Error | null;\n graphQLErrors?: ReadonlyArray<GraphQLFormattedError>;\n stopped = false;\n\n private cancelWatch?: () => void;\n private cache: ApolloCache<any>;\n\n constructor(\n queryManager: QueryManager<any>,\n public readonly queryId = queryManager.generateQueryId()\n ) {\n const cache = (this.cache = queryManager.cache);\n\n // Track how often cache.evict is called, since we want eviction to\n // override the feud-stopping logic in the markResult method, by\n // causing shouldWrite to return true. Wrapping the cache.evict method\n // is a bit of a hack, but it saves us from having to make eviction\n // counting an official part of the ApolloCache API.\n if (!destructiveMethodCounts.has(cache)) {\n destructiveMethodCounts.set(cache, 0);\n wrapDestructiveCacheMethod(cache, \"evict\");\n wrapDestructiveCacheMethod(cache, \"modify\");\n wrapDestructiveCacheMethod(cache, \"reset\");\n }\n }\n\n public init(query: {\n document: DocumentNode;\n variables: Record<string, any> | undefined;\n // The initial networkStatus for this fetch, most often\n // NetworkStatus.loading, but also possibly fetchMore, poll, refetch,\n // or setVariables.\n networkStatus?: NetworkStatus;\n observableQuery?: ObservableQuery<any, any>;\n lastRequestId?: number;\n }): this {\n let networkStatus = query.networkStatus || NetworkStatus.loading;\n if (\n this.variables &&\n this.networkStatus !== NetworkStatus.loading &&\n !equal(this.variables, query.variables)\n ) {\n networkStatus = NetworkStatus.setVariables;\n }\n\n if (!equal(query.variables, this.variables)) {\n this.lastDiff = void 0;\n // Ensure we don't continue to receive cache updates for old variables\n this.cancel();\n }\n\n Object.assign(this, {\n document: query.document,\n variables: query.variables,\n networkError: null,\n graphQLErrors: this.graphQLErrors || [],\n networkStatus,\n });\n\n if (query.observableQuery) {\n this.setObservableQuery(query.observableQuery);\n }\n\n if (query.lastRequestId) {\n this.lastRequestId = query.lastRequestId;\n }\n\n return this;\n }\n\n resetDiff() {\n this.lastDiff = void 0;\n }\n\n getDiff(): Cache.DiffResult<any> {\n const options = this.getDiffOptions();\n\n if (this.lastDiff && equal(options, this.lastDiff.options)) {\n return this.lastDiff.diff;\n }\n\n this.updateWatch(this.variables);\n\n const oq = this.observableQuery;\n if (oq && oq.options.fetchPolicy === \"no-cache\") {\n return { complete: false };\n }\n\n const diff = muteDeprecations(\"canonizeResults\", () =>\n this.cache.diff(options)\n );\n this.updateLastDiff(diff, options);\n return diff;\n }\n\n private lastDiff?: {\n diff: Cache.DiffResult<any>;\n options: Cache.DiffOptions;\n };\n\n private updateLastDiff(\n diff: Cache.DiffResult<any> | null,\n options?: Cache.DiffOptions\n ) {\n this.lastDiff =\n diff ?\n {\n diff,\n options: options || this.getDiffOptions(),\n }\n : void 0;\n }\n\n private getDiffOptions(variables = this.variables): Cache.DiffOptions {\n return {\n query: this.document!,\n variables,\n returnPartialData: true,\n optimistic: true,\n canonizeResults: this.observableQuery?.options.canonizeResults,\n };\n }\n\n setDiff(diff: Cache.DiffResult<any> | null) {\n const oldDiff = this.lastDiff && this.lastDiff.diff;\n\n // If we are trying to deliver an incomplete cache result, we avoid\n // reporting it if the query has errored, otherwise we let the broadcast try\n // and repair the partial result by refetching the query. This check avoids\n // a situation where a query that errors and another succeeds with\n // overlapping data does not report the partial data result to the errored\n // query.\n //\n // See https://github.com/apollographql/apollo-client/issues/11400 for more\n // information on this issue.\n if (\n diff &&\n !diff.complete &&\n muteDeprecations(\n \"getLastError\",\n () => this.observableQuery?.getLastError()\n )\n ) {\n return;\n }\n\n this.updateLastDiff(diff);\n\n if (!equal(oldDiff && oldDiff.result, diff && diff.result)) {\n this.observableQuery?.[\"scheduleNotify\"]();\n }\n }\n\n public readonly observableQuery: ObservableQuery<any, any> | null = null;\n setObservableQuery(oq: ObservableQuery<any, any> | null) {\n if (oq === this.observableQuery) return;\n (this as any).observableQuery = oq;\n if (oq) {\n oq[\"queryInfo\"] = this;\n }\n }\n\n public stop() {\n if (!this.stopped) {\n this.stopped = true;\n\n // Cancel the pending notify timeout\n this.observableQuery?.[\"resetNotifications\"]();\n this.cancel();\n\n const oq = this.observableQuery;\n if (oq) oq.stopPolling();\n }\n }\n\n private cancel() {\n this.cancelWatch?.();\n this.cancelWatch = void 0;\n }\n\n private lastWatch?: Cache.WatchOptions;\n\n private updateWatch(variables = this.variables) {\n const oq = this.observableQuery;\n if (oq && oq.options.fetchPolicy === \"no-cache\") {\n return;\n }\n\n const watchOptions: Cache.WatchOptions = {\n // Although this.getDiffOptions returns Cache.DiffOptions instead of\n // Cache.WatchOptions, all the overlapping options should be the same, so\n // we can reuse getDiffOptions here, for consistency.\n ...this.getDiffOptions(variables),\n watcher: this,\n callback: (diff) => this.setDiff(diff),\n };\n\n if (!this.lastWatch || !equal(watchOptions, this.lastWatch)) {\n this.cancel();\n this.cancelWatch = this.cache.watch((this.lastWatch = watchOptions));\n }\n }\n\n private lastWrite?: {\n result: FetchResult<any>;\n variables: WatchQueryOptions[\"variables\"];\n dmCount: number | undefined;\n };\n\n public resetLastWrite() {\n this.lastWrite = void 0;\n }\n\n private shouldWrite(\n result: FetchResult<any>,\n variables: WatchQueryOptions[\"variables\"]\n ) {\n const { lastWrite } = this;\n return !(\n lastWrite &&\n // If cache.evict has been called since the last time we wrote this\n // data into the cache, there's a chance writing this result into\n // the cache will repair what was evicted.\n lastWrite.dmCount === destructiveMethodCounts.get(this.cache) &&\n equal(variables, lastWrite.variables) &&\n equal(result.data, lastWrite.result.data)\n );\n }\n\n public markResult<T>(\n result: FetchResult<T>,\n document: DocumentNode,\n options: Pick<\n WatchQueryOptions,\n \"variables\" | \"fetchPolicy\" | \"errorPolicy\"\n >,\n cacheWriteBehavior: CacheWriteBehavior\n ) {\n const merger = new DeepMerger();\n const graphQLErrors =\n isNonEmptyArray(result.errors) ? result.errors.slice(0) : [];\n\n // Cancel the pending notify timeout (if it exists) to prevent extraneous network\n // requests. To allow future notify timeouts, diff and dirty are reset as well.\n this.observableQuery?.[\"resetNotifications\"]();\n\n if (\"incremental\" in result && isNonEmptyArray(result.incremental)) {\n const mergedData = mergeIncrementalData(this.getDiff().result, result);\n result.data = mergedData;\n\n // Detect the first chunk of a deferred query and merge it with existing\n // cache data. This ensures a `cache-first` fetch policy that returns\n // partial cache data or a `cache-and-network` fetch policy that already\n // has full data in the cache does not complain when trying to merge the\n // initial deferred server data with existing cache data.\n } else if (\"hasNext\" in result && result.hasNext) {\n const diff = this.getDiff();\n result.data = merger.merge(diff.result, result.data);\n }\n\n this.graphQLErrors = graphQLErrors;\n\n if (options.fetchPolicy === \"no-cache\") {\n this.updateLastDiff(\n { result: result.data, complete: true },\n this.getDiffOptions(options.variables)\n );\n } else if (cacheWriteBehavior !== CacheWriteBehavior.FORBID) {\n if (shouldWriteResult(result, options.errorPolicy)) {\n // Using a transaction here so we have a chance to read the result\n // back from the cache before the watch callback fires as a result\n // of writeQuery, so we can store the new diff quietly and ignore\n // it when we receive it redundantly from the watch callback.\n this.cache.performTransaction((cache) => {\n if (this.shouldWrite(result, options.variables)) {\n cache.writeQuery({\n query: document,\n data: result.data as Unmasked<T>,\n variables: options.variables,\n overwrite: cacheWriteBehavior === CacheWriteBehavior.OVERWRITE,\n });\n\n this.lastWrite = {\n result,\n variables: options.variables,\n dmCount: destructiveMethodCounts.get(this.cache),\n };\n } else {\n // If result is the same as the last result we received from\n // the network (and the variables match too), avoid writing\n // result into the cache again. The wisdom of skipping this\n // cache write is far from obvious, since any cache write\n // could be the one that puts the cache back into a desired\n // state, fixing corruption or missing data. However, if we\n // always write every network result into the cache, we enable\n // feuds between queries competing to update the same data in\n // incompatible ways, which can lead to an endless cycle of\n // cache broadcasts and useless network requests. As with any\n // feud, eventually one side must step back from the brink,\n // letting the other side(s) have the last word(s). There may\n // be other points where we could break this cycle, such as\n // silencing the broadcast for cache.writeQuery (not a good\n // idea, since it just delays the feud a bit) or somehow\n // avoiding the network request that just happened (also bad,\n // because the server could return useful new data). All\n // options considered, skipping this cache write seems to be\n // the least damaging place to break the cycle, because it\n // reflects the intuition that we recently wrote this exact\n // result into the cache, so the cache *should* already/still\n // contain this data. If some other query has clobbered that\n // data in the meantime, that's too bad, but there will be no\n // winners if every query blindly reverts to its own version\n // of the data. This approach also gives the network a chance\n // to return new data, which will be written into the cache as\n // usual, notifying only those queries that are directly\n // affected by the cache updates, as usual. In the future, an\n // even more sophisticated cache could perhaps prevent or\n // mitigate the clobbering somehow, but that would make this\n // particular cache write even less important, and thus\n // skipping it would be even safer than it is today.\n if (this.lastDiff && this.lastDiff.diff.complete) {\n // Reuse data from the last good (complete) diff that we\n // received, when possible.\n result.data = this.lastDiff.diff.result;\n return;\n }\n // If the previous this.diff was incomplete, fall through to\n // re-reading the latest data with cache.diff, below.\n }\n\n const diffOptions = this.getDiffOptions(options.variables);\n const diff = muteDeprecations(\"canonizeResults\", () =>\n cache.diff<T>(diffOptions)\n );\n\n // In case the QueryManager stops this QueryInfo before its\n // results are delivered, it's important to avoid restarting the\n // cache watch when markResult is called. We also avoid updating\n // the watch if we are writing a result that doesn't match the current\n // variables to avoid race conditions from broadcasting the wrong\n // result.\n if (!this.stopped && equal(this.variables, options.variables)) {\n // Any time we're about to update this.diff, we need to make\n // sure we've started watching the cache.\n this.updateWatch(options.variables);\n }\n\n // If we're allowed to write to the cache, and we can read a\n // complete result from the cache, update result.data to be the\n // result from the cache, rather than the raw network result.\n // Set without setDiff to avoid triggering a notify call, since\n // we have other ways of notifying for this result.\n this.updateLastDiff(diff, diffOptions);\n if (diff.complete) {\n result.data = diff.result;\n }\n });\n } else {\n this.lastWrite = void 0;\n }\n }\n }\n\n public markReady() {\n this.networkError = null;\n return (this.networkStatus = NetworkStatus.ready);\n }\n\n public markError(error: ApolloError) {\n this.networkStatus = NetworkStatus.error;\n this.lastWrite = void 0;\n\n this.observableQuery?.[\"resetNotifications\"]();\n\n if (error.graphQLErrors) {\n this.graphQLErrors = error.graphQLErrors;\n }\n\n if (error.networkError) {\n this.networkError = error.networkError;\n }\n\n return error;\n }\n}\n\nexport function shouldWriteResult<T>(\n result: FetchResult<T>,\n errorPolicy: ErrorPolicy = \"none\"\n) {\n const ignoreErrors = errorPolicy === \"ignore\" || errorPolicy === \"all\";\n let writeWithErrors = !graphQLResultHasError(result);\n if (!writeWithErrors && ignoreErrors && result.data) {\n writeWithErrors = true;\n }\n return writeWithErrors;\n}\n"]}
@@ -76,7 +76,7 @@ var QueryManager = /** @class */ (function () {
76
76
  this.queries.forEach(function (_info, queryId) {
77
77
  _this.stopQueryNoBroadcast(queryId);
78
78
  });
79
- this.cancelPendingFetches(newInvariantError(28));
79
+ this.cancelPendingFetches(newInvariantError(35));
80
80
  };
81
81
  QueryManager.prototype.cancelPendingFetches = function (error) {
82
82
  this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
@@ -90,8 +90,8 @@ var QueryManager = /** @class */ (function () {
90
90
  return __generator(this, function (_j) {
91
91
  switch (_j.label) {
92
92
  case 0:
93
- invariant(mutation, 29);
94
- invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 30);
93
+ invariant(mutation, 36);
94
+ invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 37);
95
95
  mutationId = this.generateMutationId();
96
96
  mutation = this.cache.transformForLink(this.transform(mutation));
97
97
  hasClientExports = this.getDocumentInfo(mutation).hasClientExports;
@@ -473,10 +473,10 @@ var QueryManager = /** @class */ (function () {
473
473
  QueryManager.prototype.query = function (options, queryId) {
474
474
  var _this = this;
475
475
  if (queryId === void 0) { queryId = this.generateQueryId(); }
476
- invariant(options.query, 31);
477
- invariant(options.query.kind === "Document", 32);
478
- invariant(!options.returnPartialData, 33);
479
- invariant(!options.pollInterval, 34);
476
+ invariant(options.query, 38);
477
+ invariant(options.query.kind === "Document", 39);
478
+ invariant(!options.returnPartialData, 40);
479
+ invariant(!options.pollInterval, 41);
480
480
  var query = this.transform(options.query);
481
481
  return this.fetchQuery(queryId, __assign(__assign({}, options), { query: query }))
482
482
  .then(function (result) {
@@ -516,7 +516,7 @@ var QueryManager = /** @class */ (function () {
516
516
  // depend on values that previously existed in the data portion of the
517
517
  // store. So, we cancel the promises and observers that we have issued
518
518
  // so far and not yet resolved (in the case of queries).
519
- this.cancelPendingFetches(newInvariantError(35));
519
+ this.cancelPendingFetches(newInvariantError(42));
520
520
  this.queries.forEach(function (queryInfo) {
521
521
  if (queryInfo.observableQuery) {
522
522
  // Set loading to true so listeners don't trigger unless they want
@@ -604,10 +604,10 @@ var QueryManager = /** @class */ (function () {
604
604
  if (!included) {
605
605
  var queryName = queryNames.get(nameOrQueryString);
606
606
  if (queryName) {
607
- globalThis.__DEV__ !== false && invariant.warn(36, queryName);
607
+ globalThis.__DEV__ !== false && invariant.warn(43, queryName);
608
608
  }
609
609
  else {
610
- globalThis.__DEV__ !== false && invariant.warn(37);
610
+ globalThis.__DEV__ !== false && invariant.warn(44);
611
611
  }
612
612
  }
613
613
  });
@@ -620,7 +620,9 @@ var QueryManager = /** @class */ (function () {
620
620
  var observableQueryPromises = [];
621
621
  this.getObservableQueries(includeStandby ? "all" : "active").forEach(function (observableQuery, queryId) {
622
622
  var fetchPolicy = observableQuery.options.fetchPolicy;
623
- observableQuery.resetLastResults();
623
+ muteDeprecations("resetLastResults", function () {
624
+ return observableQuery.resetLastResults();
625
+ });
624
626
  if (includeStandby ||
625
627
  (fetchPolicy !== "standby" && fetchPolicy !== "cache-only")) {
626
628
  observableQueryPromises.push(observableQuery.refetch());
@@ -1041,7 +1043,7 @@ var QueryManager = /** @class */ (function () {
1041
1043
  !this.noCacheWarningsByQueryId.has(operationId)) {
1042
1044
  this.noCacheWarningsByQueryId.add(operationId);
1043
1045
  globalThis.__DEV__ !== false && invariant.warn(
1044
- 38,
1046
+ 45,
1045
1047
  (_c = getOperationName(document)) !== null && _c !== void 0 ? _c : "Unnamed ".concat(operationType !== null && operationType !== void 0 ? operationType : "operation")
1046
1048
  );
1047
1049
  }