@apollo/client 3.8.0-alpha.9 → 3.8.0-beta.1

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 (582) hide show
  1. package/apollo-client.cjs +1043 -686
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/cache/cache.cjs +34 -31
  5. package/cache/cache.cjs.map +1 -1
  6. package/cache/cache.cjs.native.js +34 -31
  7. package/cache/core/cache.d.ts +5 -4
  8. package/cache/core/cache.d.ts.map +1 -1
  9. package/cache/core/cache.js +1 -0
  10. package/cache/core/cache.js.map +1 -1
  11. package/cache/core/types/Cache.d.ts +2 -2
  12. package/cache/core/types/Cache.d.ts.map +1 -1
  13. package/cache/core/types/Cache.js.map +1 -1
  14. package/cache/core/types/DataProxy.d.ts +4 -4
  15. package/cache/core/types/DataProxy.d.ts.map +1 -1
  16. package/cache/core/types/DataProxy.js.map +1 -1
  17. package/cache/core/types/common.d.ts +3 -3
  18. package/cache/core/types/common.d.ts.map +1 -1
  19. package/cache/core/types/common.js.map +1 -1
  20. package/cache/inmemory/entityStore.d.ts +5 -5
  21. package/cache/inmemory/entityStore.d.ts.map +1 -1
  22. package/cache/inmemory/entityStore.js +2 -2
  23. package/cache/inmemory/entityStore.js.map +1 -1
  24. package/cache/inmemory/fragmentRegistry.d.ts +1 -1
  25. package/cache/inmemory/fragmentRegistry.d.ts.map +1 -1
  26. package/cache/inmemory/fragmentRegistry.js.map +1 -1
  27. package/cache/inmemory/helpers.d.ts +6 -5
  28. package/cache/inmemory/helpers.d.ts.map +1 -1
  29. package/cache/inmemory/helpers.js.map +1 -1
  30. package/cache/inmemory/inMemoryCache.d.ts +9 -7
  31. package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
  32. package/cache/inmemory/inMemoryCache.js +14 -16
  33. package/cache/inmemory/inMemoryCache.js.map +1 -1
  34. package/cache/inmemory/key-extractor.d.ts +1 -1
  35. package/cache/inmemory/key-extractor.d.ts.map +1 -1
  36. package/cache/inmemory/key-extractor.js +2 -2
  37. package/cache/inmemory/key-extractor.js.map +1 -1
  38. package/cache/inmemory/policies.d.ts +7 -6
  39. package/cache/inmemory/policies.d.ts.map +1 -1
  40. package/cache/inmemory/policies.js +6 -6
  41. package/cache/inmemory/policies.js.map +1 -1
  42. package/cache/inmemory/reactiveVars.d.ts +1 -1
  43. package/cache/inmemory/reactiveVars.d.ts.map +1 -1
  44. package/cache/inmemory/reactiveVars.js.map +1 -1
  45. package/cache/inmemory/readFromStore.d.ts +6 -6
  46. package/cache/inmemory/readFromStore.d.ts.map +1 -1
  47. package/cache/inmemory/readFromStore.js +10 -5
  48. package/cache/inmemory/readFromStore.js.map +1 -1
  49. package/cache/inmemory/types.d.ts +6 -6
  50. package/cache/inmemory/types.d.ts.map +1 -1
  51. package/cache/inmemory/types.js.map +1 -1
  52. package/cache/inmemory/writeToStore.d.ts +6 -6
  53. package/cache/inmemory/writeToStore.d.ts.map +1 -1
  54. package/cache/inmemory/writeToStore.js +7 -8
  55. package/cache/inmemory/writeToStore.js.map +1 -1
  56. package/config/jest/setup.d.ts +1 -0
  57. package/config/jest/setup.d.ts.map +1 -1
  58. package/config/jest/setup.js +3 -0
  59. package/config/jest/setup.js.map +1 -1
  60. package/core/ApolloClient.d.ts +12 -10
  61. package/core/ApolloClient.d.ts.map +1 -1
  62. package/core/ApolloClient.js +18 -16
  63. package/core/ApolloClient.js.map +1 -1
  64. package/core/LocalState.d.ts +7 -9
  65. package/core/LocalState.d.ts.map +1 -1
  66. package/core/LocalState.js +6 -10
  67. package/core/LocalState.js.map +1 -1
  68. package/core/ObservableQuery.d.ts +11 -8
  69. package/core/ObservableQuery.d.ts.map +1 -1
  70. package/core/ObservableQuery.js +48 -28
  71. package/core/ObservableQuery.js.map +1 -1
  72. package/core/QueryInfo.d.ts +9 -9
  73. package/core/QueryInfo.d.ts.map +1 -1
  74. package/core/QueryInfo.js.map +1 -1
  75. package/core/QueryManager.d.ts +14 -11
  76. package/core/QueryManager.d.ts.map +1 -1
  77. package/core/QueryManager.js +114 -108
  78. package/core/QueryManager.js.map +1 -1
  79. package/core/core.cjs +267 -172
  80. package/core/core.cjs.map +1 -1
  81. package/core/core.cjs.native.js +267 -172
  82. package/core/equalByQuery.d.ts +4 -0
  83. package/core/equalByQuery.d.ts.map +1 -0
  84. package/{react/hooks/compareResults.js → core/equalByQuery.js} +14 -10
  85. package/core/equalByQuery.js.map +1 -0
  86. package/core/index.d.ts +2 -2
  87. package/core/index.d.ts.map +1 -1
  88. package/core/index.js +2 -2
  89. package/core/index.js.map +1 -1
  90. package/core/networkStatus.d.ts +1 -0
  91. package/core/networkStatus.d.ts.map +1 -1
  92. package/core/networkStatus.js +3 -0
  93. package/core/networkStatus.js.map +1 -1
  94. package/core/types.d.ts +14 -14
  95. package/core/types.d.ts.map +1 -1
  96. package/core/types.js.map +1 -1
  97. package/core/watchQueryOptions.d.ts +6 -7
  98. package/core/watchQueryOptions.d.ts.map +1 -1
  99. package/core/watchQueryOptions.js.map +1 -1
  100. package/dev/dev.cjs +642 -0
  101. package/dev/dev.cjs.map +1 -0
  102. package/dev/dev.cjs.native.js +642 -0
  103. package/dev/index.d.ts +4 -0
  104. package/dev/index.d.ts.map +1 -0
  105. package/dev/index.js +4 -0
  106. package/dev/index.js.map +1 -0
  107. package/dev/loadDevMessages.d.ts +2 -0
  108. package/dev/loadDevMessages.d.ts.map +1 -0
  109. package/dev/loadDevMessages.js +6 -0
  110. package/dev/loadDevMessages.js.map +1 -0
  111. package/dev/loadErrorMessageHandler.d.ts +3 -0
  112. package/dev/loadErrorMessageHandler.d.ts.map +1 -0
  113. package/dev/loadErrorMessageHandler.js +26 -0
  114. package/dev/loadErrorMessageHandler.js.map +1 -0
  115. package/dev/loadErrorMessages.d.ts +2 -0
  116. package/dev/loadErrorMessages.d.ts.map +1 -0
  117. package/dev/loadErrorMessages.js +6 -0
  118. package/dev/loadErrorMessages.js.map +1 -0
  119. package/dev/package.json +8 -0
  120. package/errors/errors.cjs +17 -17
  121. package/errors/errors.cjs.map +1 -1
  122. package/errors/errors.cjs.native.js +17 -17
  123. package/errors/index.d.ts +26 -10
  124. package/errors/index.d.ts.map +1 -1
  125. package/errors/index.js +17 -19
  126. package/errors/index.js.map +1 -1
  127. package/invariantErrorCodes.d.ts +13 -0
  128. package/invariantErrorCodes.d.ts.map +1 -0
  129. package/invariantErrorCodes.js +331 -144
  130. package/invariantErrorCodes.js.map +1 -0
  131. package/link/batch/batchLink.d.ts +4 -3
  132. package/link/batch/batchLink.d.ts.map +1 -1
  133. package/link/batch/batchLink.js.map +1 -1
  134. package/link/batch/batching.d.ts +1 -1
  135. package/link/batch/batching.d.ts.map +1 -1
  136. package/link/batch/batching.js.map +1 -1
  137. package/link/batch-http/batch-http.cjs +23 -2
  138. package/link/batch-http/batch-http.cjs.map +1 -1
  139. package/link/batch-http/batch-http.cjs.native.js +23 -2
  140. package/link/batch-http/batchHttpLink.d.ts +3 -2
  141. package/link/batch-http/batchHttpLink.d.ts.map +1 -1
  142. package/link/batch-http/batchHttpLink.js +7 -2
  143. package/link/batch-http/batchHttpLink.js.map +1 -1
  144. package/link/context/index.d.ts +3 -2
  145. package/link/context/index.d.ts.map +1 -1
  146. package/link/context/index.js.map +1 -1
  147. package/link/core/ApolloLink.d.ts +3 -2
  148. package/link/core/ApolloLink.d.ts.map +1 -1
  149. package/link/core/ApolloLink.js +3 -13
  150. package/link/core/ApolloLink.js.map +1 -1
  151. package/link/core/core.cjs +2 -12
  152. package/link/core/core.cjs.map +1 -1
  153. package/link/core/core.cjs.native.js +2 -12
  154. package/link/core/types.d.ts +8 -3
  155. package/link/core/types.d.ts.map +1 -1
  156. package/link/core/types.js.map +1 -1
  157. package/link/error/index.d.ts +4 -3
  158. package/link/error/index.d.ts.map +1 -1
  159. package/link/error/index.js.map +1 -1
  160. package/link/http/HttpLink.d.ts +3 -2
  161. package/link/http/HttpLink.d.ts.map +1 -1
  162. package/link/http/HttpLink.js.map +1 -1
  163. package/link/http/checkFetcher.js +2 -2
  164. package/link/http/checkFetcher.js.map +1 -1
  165. package/link/http/createHttpLink.d.ts +1 -1
  166. package/link/http/createHttpLink.d.ts.map +1 -1
  167. package/link/http/createHttpLink.js +21 -20
  168. package/link/http/createHttpLink.js.map +1 -1
  169. package/link/http/http.cjs +73 -43
  170. package/link/http/http.cjs.map +1 -1
  171. package/link/http/http.cjs.native.js +73 -43
  172. package/link/http/iterators/nodeStream.d.ts +1 -1
  173. package/link/http/iterators/nodeStream.d.ts.map +1 -1
  174. package/link/http/iterators/nodeStream.js.map +1 -1
  175. package/link/http/parseAndCheckHttpResponse.d.ts +2 -2
  176. package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
  177. package/link/http/parseAndCheckHttpResponse.js +47 -26
  178. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  179. package/link/http/responseIterator.d.ts +1 -1
  180. package/link/http/responseIterator.d.ts.map +1 -1
  181. package/link/http/responseIterator.js.map +1 -1
  182. package/link/http/rewriteURIForGET.d.ts +1 -1
  183. package/link/http/rewriteURIForGET.d.ts.map +1 -1
  184. package/link/http/rewriteURIForGET.js.map +1 -1
  185. package/link/http/selectHttpOptionsAndBody.d.ts +3 -2
  186. package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
  187. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  188. package/link/http/selectURI.d.ts +1 -1
  189. package/link/http/selectURI.d.ts.map +1 -1
  190. package/link/http/selectURI.js.map +1 -1
  191. package/link/http/serializeFetchParameter.d.ts +1 -1
  192. package/link/http/serializeFetchParameter.d.ts.map +1 -1
  193. package/link/http/serializeFetchParameter.js +2 -2
  194. package/link/http/serializeFetchParameter.js.map +1 -1
  195. package/link/persisted-queries/index.d.ts +4 -3
  196. package/link/persisted-queries/index.d.ts.map +1 -1
  197. package/link/persisted-queries/index.js +16 -20
  198. package/link/persisted-queries/index.js.map +1 -1
  199. package/link/persisted-queries/persisted-queries.cjs +15 -19
  200. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  201. package/link/persisted-queries/persisted-queries.cjs.native.js +15 -19
  202. package/link/remove-typename/index.d.ts +2 -0
  203. package/link/remove-typename/index.d.ts.map +1 -0
  204. package/link/remove-typename/index.js +2 -0
  205. package/link/remove-typename/index.js.map +1 -0
  206. package/link/remove-typename/package.json +8 -0
  207. package/link/remove-typename/remove-typename.cjs +81 -0
  208. package/link/remove-typename/remove-typename.cjs.map +1 -0
  209. package/link/remove-typename/remove-typename.cjs.native.js +81 -0
  210. package/link/remove-typename/removeTypenameFromVariables.d.ts +11 -0
  211. package/link/remove-typename/removeTypenameFromVariables.d.ts.map +1 -0
  212. package/link/remove-typename/removeTypenameFromVariables.js +73 -0
  213. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -0
  214. package/link/retry/delayFunction.d.ts +1 -1
  215. package/link/retry/delayFunction.d.ts.map +1 -1
  216. package/link/retry/delayFunction.js.map +1 -1
  217. package/link/retry/retryFunction.d.ts +1 -1
  218. package/link/retry/retryFunction.d.ts.map +1 -1
  219. package/link/retry/retryFunction.js.map +1 -1
  220. package/link/retry/retryLink.d.ts +4 -3
  221. package/link/retry/retryLink.d.ts.map +1 -1
  222. package/link/retry/retryLink.js.map +1 -1
  223. package/link/schema/index.d.ts +3 -2
  224. package/link/schema/index.d.ts.map +1 -1
  225. package/link/schema/index.js.map +1 -1
  226. package/link/subscriptions/index.d.ts +2 -1
  227. package/link/subscriptions/index.d.ts.map +1 -1
  228. package/link/subscriptions/index.js +8 -3
  229. package/link/subscriptions/index.js.map +1 -1
  230. package/link/subscriptions/subscriptions.cjs +8 -3
  231. package/link/subscriptions/subscriptions.cjs.map +1 -1
  232. package/link/subscriptions/subscriptions.cjs.native.js +8 -3
  233. package/link/utils/createOperation.d.ts +1 -1
  234. package/link/utils/createOperation.d.ts.map +1 -1
  235. package/link/utils/createOperation.js.map +1 -1
  236. package/link/utils/filterOperationVariables.d.ts +5 -0
  237. package/link/utils/filterOperationVariables.d.ts.map +1 -0
  238. package/link/utils/filterOperationVariables.js +18 -0
  239. package/link/utils/filterOperationVariables.js.map +1 -0
  240. package/link/utils/index.d.ts +1 -0
  241. package/link/utils/index.d.ts.map +1 -1
  242. package/link/utils/index.js +1 -0
  243. package/link/utils/index.js.map +1 -1
  244. package/link/utils/throwServerError.d.ts +1 -1
  245. package/link/utils/throwServerError.d.ts.map +1 -1
  246. package/link/utils/throwServerError.js.map +1 -1
  247. package/link/utils/toPromise.d.ts +1 -1
  248. package/link/utils/toPromise.d.ts.map +1 -1
  249. package/link/utils/toPromise.js +1 -1
  250. package/link/utils/toPromise.js.map +1 -1
  251. package/link/utils/transformOperation.d.ts +1 -1
  252. package/link/utils/transformOperation.d.ts.map +1 -1
  253. package/link/utils/transformOperation.js.map +1 -1
  254. package/link/utils/utils.cjs +20 -2
  255. package/link/utils/utils.cjs.map +1 -1
  256. package/link/utils/utils.cjs.native.js +20 -2
  257. package/link/utils/validateOperation.d.ts +1 -1
  258. package/link/utils/validateOperation.d.ts.map +1 -1
  259. package/link/utils/validateOperation.js +2 -2
  260. package/link/utils/validateOperation.js.map +1 -1
  261. package/link/ws/index.d.ts +5 -3
  262. package/link/ws/index.d.ts.map +1 -1
  263. package/link/ws/index.js.map +1 -1
  264. package/package.json +36 -32
  265. package/react/cache/QueryReference.d.ts +34 -0
  266. package/react/cache/QueryReference.d.ts.map +1 -0
  267. package/react/cache/QueryReference.js +107 -0
  268. package/react/cache/QueryReference.js.map +1 -0
  269. package/react/cache/SuspenseCache.d.ts +10 -13
  270. package/react/cache/SuspenseCache.d.ts.map +1 -1
  271. package/react/cache/SuspenseCache.js +18 -41
  272. package/react/cache/SuspenseCache.js.map +1 -1
  273. package/react/cache/types.d.ts +2 -0
  274. package/react/cache/types.d.ts.map +1 -0
  275. package/react/cache/types.js +2 -0
  276. package/react/cache/types.js.map +1 -0
  277. package/react/components/Mutation.d.ts +2 -2
  278. package/react/components/Mutation.d.ts.map +1 -1
  279. package/react/components/Mutation.js.map +1 -1
  280. package/react/components/Query.d.ts +2 -2
  281. package/react/components/Query.d.ts.map +1 -1
  282. package/react/components/Query.js.map +1 -1
  283. package/react/components/Subscription.d.ts +2 -2
  284. package/react/components/Subscription.d.ts.map +1 -1
  285. package/react/components/Subscription.js.map +1 -1
  286. package/react/components/types.d.ts +4 -4
  287. package/react/components/types.d.ts.map +1 -1
  288. package/react/components/types.js.map +1 -1
  289. package/react/context/ApolloConsumer.d.ts +1 -1
  290. package/react/context/ApolloConsumer.d.ts.map +1 -1
  291. package/react/context/ApolloConsumer.js +2 -3
  292. package/react/context/ApolloConsumer.js.map +1 -1
  293. package/react/context/ApolloContext.d.ts +10 -3
  294. package/react/context/ApolloContext.d.ts.map +1 -1
  295. package/react/context/ApolloContext.js +10 -8
  296. package/react/context/ApolloContext.js.map +1 -1
  297. package/react/context/ApolloProvider.d.ts +2 -2
  298. package/react/context/ApolloProvider.d.ts.map +1 -1
  299. package/react/context/ApolloProvider.js +8 -13
  300. package/react/context/ApolloProvider.js.map +1 -1
  301. package/react/context/context.cjs +18 -22
  302. package/react/context/context.cjs.map +1 -1
  303. package/react/context/context.cjs.native.js +18 -22
  304. package/react/context/index.d.ts +1 -1
  305. package/react/context/index.d.ts.map +1 -1
  306. package/react/context/index.js +1 -1
  307. package/react/context/index.js.map +1 -1
  308. package/react/hoc/graphql.d.ts +3 -3
  309. package/react/hoc/graphql.d.ts.map +1 -1
  310. package/react/hoc/graphql.js.map +1 -1
  311. package/react/hoc/hoc-utils.d.ts +2 -2
  312. package/react/hoc/hoc-utils.d.ts.map +1 -1
  313. package/react/hoc/hoc-utils.js +2 -3
  314. package/react/hoc/hoc-utils.js.map +1 -1
  315. package/react/hoc/hoc.cjs +2 -4
  316. package/react/hoc/hoc.cjs.map +1 -1
  317. package/react/hoc/hoc.cjs.native.js +2 -4
  318. package/react/hoc/mutation-hoc.d.ts +4 -4
  319. package/react/hoc/mutation-hoc.d.ts.map +1 -1
  320. package/react/hoc/mutation-hoc.js.map +1 -1
  321. package/react/hoc/query-hoc.d.ts +2 -2
  322. package/react/hoc/query-hoc.d.ts.map +1 -1
  323. package/react/hoc/query-hoc.js.map +1 -1
  324. package/react/hoc/subscription-hoc.d.ts +2 -2
  325. package/react/hoc/subscription-hoc.d.ts.map +1 -1
  326. package/react/hoc/subscription-hoc.js.map +1 -1
  327. package/react/hoc/types.d.ts +4 -4
  328. package/react/hoc/types.d.ts.map +1 -1
  329. package/react/hoc/types.js.map +1 -1
  330. package/react/hoc/withApollo.d.ts +1 -1
  331. package/react/hoc/withApollo.d.ts.map +1 -1
  332. package/react/hoc/withApollo.js +2 -3
  333. package/react/hoc/withApollo.js.map +1 -1
  334. package/react/hooks/hooks.cjs +223 -219
  335. package/react/hooks/hooks.cjs.map +1 -1
  336. package/react/hooks/hooks.cjs.native.js +223 -219
  337. package/react/hooks/index.d.ts +2 -1
  338. package/react/hooks/index.d.ts.map +1 -1
  339. package/react/hooks/index.js +2 -1
  340. package/react/hooks/index.js.map +1 -1
  341. package/react/hooks/internal/__use.d.ts +4 -0
  342. package/react/hooks/internal/__use.d.ts.map +1 -0
  343. package/react/hooks/internal/__use.js +17 -0
  344. package/react/hooks/internal/__use.js.map +1 -0
  345. package/react/hooks/internal/index.d.ts +2 -0
  346. package/react/hooks/internal/index.d.ts.map +1 -1
  347. package/react/hooks/internal/index.js +2 -0
  348. package/react/hooks/internal/index.js.map +1 -1
  349. package/react/hooks/internal/useDeepMemo.d.ts +1 -1
  350. package/react/hooks/internal/useDeepMemo.d.ts.map +1 -1
  351. package/react/hooks/internal/useDeepMemo.js.map +1 -1
  352. package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +1 -1
  353. package/react/hooks/internal/useIsomorphicLayoutEffect.js +2 -2
  354. package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
  355. package/react/hooks/internal/useStrictModeSafeCleanupEffect.d.ts +2 -0
  356. package/react/hooks/internal/useStrictModeSafeCleanupEffect.d.ts.map +1 -0
  357. package/react/hooks/internal/useStrictModeSafeCleanupEffect.js +11 -0
  358. package/react/hooks/internal/useStrictModeSafeCleanupEffect.js.map +1 -0
  359. package/react/hooks/useApolloClient.d.ts +1 -1
  360. package/react/hooks/useApolloClient.d.ts.map +1 -1
  361. package/react/hooks/useApolloClient.js +2 -4
  362. package/react/hooks/useApolloClient.js.map +1 -1
  363. package/react/hooks/useBackgroundQuery.d.ts +18 -0
  364. package/react/hooks/useBackgroundQuery.d.ts.map +1 -0
  365. package/react/hooks/useBackgroundQuery.js +69 -0
  366. package/react/hooks/useBackgroundQuery.js.map +1 -0
  367. package/react/hooks/useFragment.d.ts +14 -9
  368. package/react/hooks/useFragment.d.ts.map +1 -1
  369. package/react/hooks/useFragment.js +2 -2
  370. package/react/hooks/useFragment.js.map +1 -1
  371. package/react/hooks/useLazyQuery.d.ts +4 -4
  372. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  373. package/react/hooks/useLazyQuery.js +13 -22
  374. package/react/hooks/useLazyQuery.js.map +1 -1
  375. package/react/hooks/useMutation.d.ts +4 -4
  376. package/react/hooks/useMutation.d.ts.map +1 -1
  377. package/react/hooks/useMutation.js +1 -1
  378. package/react/hooks/useMutation.js.map +1 -1
  379. package/react/hooks/useQuery.d.ts +6 -6
  380. package/react/hooks/useQuery.d.ts.map +1 -1
  381. package/react/hooks/useQuery.js +29 -28
  382. package/react/hooks/useQuery.js.map +1 -1
  383. package/react/hooks/useReactiveVar.d.ts +1 -1
  384. package/react/hooks/useReactiveVar.d.ts.map +1 -1
  385. package/react/hooks/useReactiveVar.js.map +1 -1
  386. package/react/hooks/useSubscription.d.ts +4 -4
  387. package/react/hooks/useSubscription.d.ts.map +1 -1
  388. package/react/hooks/useSubscription.js +27 -19
  389. package/react/hooks/useSubscription.js.map +1 -1
  390. package/react/hooks/useSuspenseCache.d.ts +1 -1
  391. package/react/hooks/useSuspenseCache.d.ts.map +1 -1
  392. package/react/hooks/useSuspenseCache.js +2 -4
  393. package/react/hooks/useSuspenseCache.js.map +1 -1
  394. package/react/hooks/useSuspenseQuery.d.ts +39 -7
  395. package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
  396. package/react/hooks/useSuspenseQuery.js +68 -149
  397. package/react/hooks/useSuspenseQuery.js.map +1 -1
  398. package/react/hooks/useSyncExternalStore.js +1 -1
  399. package/react/index.d.ts +1 -1
  400. package/react/index.d.ts.map +1 -1
  401. package/react/index.js +1 -1
  402. package/react/index.js.map +1 -1
  403. package/react/parser/index.d.ts +1 -1
  404. package/react/parser/index.d.ts.map +1 -1
  405. package/react/parser/index.js +20 -17
  406. package/react/parser/index.js.map +1 -1
  407. package/react/parser/parser.cjs +19 -16
  408. package/react/parser/parser.cjs.map +1 -1
  409. package/react/parser/parser.cjs.native.js +19 -16
  410. package/react/react.cjs +116 -35
  411. package/react/react.cjs.map +1 -1
  412. package/react/react.cjs.native.js +116 -35
  413. package/react/ssr/RenderPromises.d.ts +2 -2
  414. package/react/ssr/RenderPromises.d.ts.map +1 -1
  415. package/react/ssr/RenderPromises.js.map +1 -1
  416. package/react/ssr/renderToStringWithData.d.ts +1 -1
  417. package/react/ssr/renderToStringWithData.d.ts.map +1 -1
  418. package/react/ssr/renderToStringWithData.js.map +1 -1
  419. package/react/types/types.d.ts +10 -13
  420. package/react/types/types.d.ts.map +1 -1
  421. package/react/types/types.js.map +1 -1
  422. package/testing/core/core.cjs +1 -1
  423. package/testing/core/core.cjs.map +1 -1
  424. package/testing/core/core.cjs.native.js +1 -1
  425. package/testing/core/mocking/mockClient.d.ts +2 -2
  426. package/testing/core/mocking/mockClient.d.ts.map +1 -1
  427. package/testing/core/mocking/mockClient.js.map +1 -1
  428. package/testing/core/mocking/mockLink.d.ts +2 -1
  429. package/testing/core/mocking/mockLink.d.ts.map +1 -1
  430. package/testing/core/mocking/mockLink.js +3 -3
  431. package/testing/core/mocking/mockLink.js.map +1 -1
  432. package/testing/core/mocking/mockQueryManager.d.ts +1 -1
  433. package/testing/core/mocking/mockQueryManager.d.ts.map +1 -1
  434. package/testing/core/mocking/mockQueryManager.js.map +1 -1
  435. package/testing/core/mocking/mockSubscriptionLink.d.ts +3 -2
  436. package/testing/core/mocking/mockSubscriptionLink.d.ts.map +1 -1
  437. package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
  438. package/testing/core/mocking/mockWatchQuery.d.ts +2 -2
  439. package/testing/core/mocking/mockWatchQuery.d.ts.map +1 -1
  440. package/testing/core/mocking/mockWatchQuery.js.map +1 -1
  441. package/testing/core/observableToPromise.d.ts +2 -2
  442. package/testing/core/observableToPromise.d.ts.map +1 -1
  443. package/testing/core/observableToPromise.js.map +1 -1
  444. package/testing/core/subscribeAndCount.d.ts +1 -1
  445. package/testing/core/subscribeAndCount.d.ts.map +1 -1
  446. package/testing/core/subscribeAndCount.js.map +1 -1
  447. package/testing/matchers/index.d.ts +2 -0
  448. package/testing/matchers/index.d.ts.map +1 -0
  449. package/testing/matchers/index.js +6 -0
  450. package/testing/matchers/index.js.map +1 -0
  451. package/testing/matchers/toMatchDocument.d.ts +4 -0
  452. package/testing/matchers/toMatchDocument.d.ts.map +1 -0
  453. package/testing/matchers/toMatchDocument.js +34 -0
  454. package/testing/matchers/toMatchDocument.js.map +1 -0
  455. package/testing/react/MockedProvider.d.ts +8 -7
  456. package/testing/react/MockedProvider.d.ts.map +1 -1
  457. package/testing/react/MockedProvider.js +7 -6
  458. package/testing/react/MockedProvider.js.map +1 -1
  459. package/testing/testing.cjs +7 -51
  460. package/testing/testing.cjs.map +1 -1
  461. package/testing/testing.cjs.native.js +7 -51
  462. package/utilities/common/compact.d.ts +1 -1
  463. package/utilities/common/compact.d.ts.map +1 -1
  464. package/utilities/common/compact.js.map +1 -1
  465. package/utilities/common/errorHandling.d.ts +1 -1
  466. package/utilities/common/errorHandling.d.ts.map +1 -1
  467. package/utilities/common/errorHandling.js.map +1 -1
  468. package/utilities/common/incrementalResult.d.ts +2 -1
  469. package/utilities/common/incrementalResult.d.ts.map +1 -1
  470. package/utilities/common/incrementalResult.js +4 -0
  471. package/utilities/common/incrementalResult.js.map +1 -1
  472. package/utilities/common/mergeOptions.d.ts +1 -1
  473. package/utilities/common/mergeOptions.d.ts.map +1 -1
  474. package/utilities/common/mergeOptions.js +1 -1
  475. package/utilities/common/mergeOptions.js.map +1 -1
  476. package/utilities/common/objects.d.ts +1 -0
  477. package/utilities/common/objects.d.ts.map +1 -1
  478. package/utilities/common/objects.js +6 -0
  479. package/utilities/common/objects.js.map +1 -1
  480. package/utilities/common/omitDeep.d.ts +3 -0
  481. package/utilities/common/omitDeep.d.ts.map +1 -0
  482. package/utilities/common/omitDeep.js +41 -0
  483. package/utilities/common/omitDeep.js.map +1 -0
  484. package/utilities/common/responseIterator.d.ts +2 -2
  485. package/utilities/common/responseIterator.d.ts.map +1 -1
  486. package/utilities/common/responseIterator.js.map +1 -1
  487. package/utilities/common/stringifyForDisplay.d.ts +1 -1
  488. package/utilities/common/stringifyForDisplay.d.ts.map +1 -1
  489. package/utilities/common/stringifyForDisplay.js +3 -2
  490. package/utilities/common/stringifyForDisplay.js.map +1 -1
  491. package/utilities/common/stripTypename.d.ts +2 -0
  492. package/utilities/common/stripTypename.d.ts.map +1 -0
  493. package/utilities/common/stripTypename.js +5 -0
  494. package/utilities/common/stripTypename.js.map +1 -0
  495. package/utilities/globals/global.d.ts +6 -3
  496. package/utilities/globals/global.d.ts.map +1 -1
  497. package/utilities/globals/global.js.map +1 -1
  498. package/utilities/globals/globals.cjs +67 -1
  499. package/utilities/globals/globals.cjs.map +1 -1
  500. package/utilities/globals/globals.cjs.native.js +67 -1
  501. package/utilities/globals/index.d.ts +2 -2
  502. package/utilities/globals/index.d.ts.map +1 -1
  503. package/utilities/globals/index.js +2 -2
  504. package/utilities/globals/index.js.map +1 -1
  505. package/utilities/globals/invariantWrappers.d.ts +24 -0
  506. package/utilities/globals/invariantWrappers.d.ts.map +1 -0
  507. package/utilities/globals/invariantWrappers.js +53 -0
  508. package/utilities/globals/invariantWrappers.js.map +1 -0
  509. package/utilities/graphql/DocumentTransform.d.ts +24 -0
  510. package/utilities/graphql/DocumentTransform.d.ts.map +1 -0
  511. package/utilities/graphql/DocumentTransform.js +69 -0
  512. package/utilities/graphql/DocumentTransform.js.map +1 -0
  513. package/utilities/graphql/directives.d.ts +1 -1
  514. package/utilities/graphql/directives.d.ts.map +1 -1
  515. package/utilities/graphql/directives.js +6 -7
  516. package/utilities/graphql/directives.js.map +1 -1
  517. package/utilities/graphql/fragments.d.ts +1 -1
  518. package/utilities/graphql/fragments.d.ts.map +1 -1
  519. package/utilities/graphql/fragments.js +8 -5
  520. package/utilities/graphql/fragments.js.map +1 -1
  521. package/utilities/graphql/getFromAST.d.ts +1 -1
  522. package/utilities/graphql/getFromAST.d.ts.map +1 -1
  523. package/utilities/graphql/getFromAST.js +9 -9
  524. package/utilities/graphql/getFromAST.js.map +1 -1
  525. package/utilities/graphql/operations.d.ts +5 -0
  526. package/utilities/graphql/operations.d.ts.map +1 -0
  527. package/utilities/graphql/operations.js +16 -0
  528. package/utilities/graphql/operations.js.map +1 -0
  529. package/utilities/graphql/storeUtils.d.ts +2 -2
  530. package/utilities/graphql/storeUtils.d.ts.map +1 -1
  531. package/utilities/graphql/storeUtils.js +16 -7
  532. package/utilities/graphql/storeUtils.js.map +1 -1
  533. package/utilities/graphql/transform.d.ts +1 -1
  534. package/utilities/graphql/transform.d.ts.map +1 -1
  535. package/utilities/graphql/transform.js +30 -21
  536. package/utilities/graphql/transform.js.map +1 -1
  537. package/utilities/index.d.ts +7 -0
  538. package/utilities/index.d.ts.map +1 -1
  539. package/utilities/index.js +5 -0
  540. package/utilities/index.js.map +1 -1
  541. package/utilities/observables/Concast.d.ts +2 -1
  542. package/utilities/observables/Concast.d.ts.map +1 -1
  543. package/utilities/observables/Concast.js.map +1 -1
  544. package/utilities/observables/Observable.d.ts +2 -1
  545. package/utilities/observables/Observable.d.ts.map +1 -1
  546. package/utilities/observables/Observable.js +1 -1
  547. package/utilities/observables/Observable.js.map +1 -1
  548. package/utilities/observables/asyncMap.d.ts.map +1 -1
  549. package/utilities/observables/asyncMap.js.map +1 -1
  550. package/utilities/observables/iteration.d.ts +1 -1
  551. package/utilities/observables/iteration.d.ts.map +1 -1
  552. package/utilities/observables/iteration.js.map +1 -1
  553. package/utilities/policies/pagination.d.ts +1 -1
  554. package/utilities/policies/pagination.d.ts.map +1 -1
  555. package/utilities/policies/pagination.js.map +1 -1
  556. package/utilities/promises/decoration.d.ts +17 -0
  557. package/utilities/promises/decoration.d.ts.map +1 -0
  558. package/utilities/promises/decoration.js +37 -0
  559. package/utilities/promises/decoration.js.map +1 -0
  560. package/utilities/types/DeepOmit.d.ts +10 -0
  561. package/utilities/types/DeepOmit.d.ts.map +1 -0
  562. package/utilities/types/DeepOmit.js +2 -0
  563. package/utilities/types/DeepOmit.js.map +1 -0
  564. package/utilities/types/DeepPartial.d.ts +12 -0
  565. package/utilities/types/DeepPartial.d.ts.map +1 -0
  566. package/utilities/types/DeepPartial.js +2 -0
  567. package/utilities/types/DeepPartial.js.map +1 -0
  568. package/utilities/types/Primitive.d.ts +2 -0
  569. package/utilities/types/Primitive.d.ts.map +1 -0
  570. package/utilities/types/Primitive.js +2 -0
  571. package/utilities/types/Primitive.js.map +1 -0
  572. package/utilities/utilities.cjs +261 -59
  573. package/utilities/utilities.cjs.map +1 -1
  574. package/utilities/utilities.cjs.native.js +261 -59
  575. package/version.js +1 -1
  576. package/cache/inmemory/__mocks__/optimism.d.ts +0 -2
  577. package/cache/inmemory/__mocks__/optimism.d.ts.map +0 -1
  578. package/cache/inmemory/__mocks__/optimism.js +0 -14
  579. package/cache/inmemory/__mocks__/optimism.js.map +0 -1
  580. package/react/hooks/compareResults.d.ts +0 -3
  581. package/react/hooks/compareResults.d.ts.map +0 -1
  582. package/react/hooks/compareResults.js.map +0 -1
@@ -6,7 +6,7 @@ var globals = require('../utilities/globals');
6
6
  var tslib = require('tslib');
7
7
  var core = require('../link/core');
8
8
  var http = require('../link/http');
9
- var equality = require('@wry/equality');
9
+ var equal = require('@wry/equality');
10
10
  var utilities = require('../utilities');
11
11
  var cache = require('../cache');
12
12
  var errors = require('../errors');
@@ -15,16 +15,20 @@ var utils = require('../link/utils');
15
15
  var tsInvariant = require('ts-invariant');
16
16
  var graphqlTag = require('graphql-tag');
17
17
 
18
- var version = '3.8.0-alpha.9';
18
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
19
19
 
20
- function isNonEmptyArray(value) {
21
- return Array.isArray(value) && value.length > 0;
22
- }
20
+ var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
21
+
22
+ var version = '3.8.0-beta.1';
23
23
 
24
24
  function isNonNullObject(obj) {
25
25
  return obj !== null && typeof obj === 'object';
26
26
  }
27
27
 
28
+ function isNonEmptyArray(value) {
29
+ return Array.isArray(value) && value.length > 0;
30
+ }
31
+
28
32
  var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
29
33
  var defaultReconciler = function (target, source, property) {
30
34
  return this.merge(target[property], source[property]);
@@ -116,6 +120,73 @@ exports.NetworkStatus = void 0;
116
120
  function isNetworkRequestInFlight(networkStatus) {
117
121
  return networkStatus ? networkStatus < 7 : false;
118
122
  }
123
+ function isNetworkRequestSettled(networkStatus) {
124
+ return networkStatus === 7 || networkStatus === 8;
125
+ }
126
+
127
+ function equalByQuery(query, _a, _b, variables) {
128
+ var aData = _a.data, aRest = tslib.__rest(_a, ["data"]);
129
+ var bData = _b.data, bRest = tslib.__rest(_b, ["data"]);
130
+ return equal__default(aRest, bRest) && equalBySelectionSet(utilities.getMainDefinition(query).selectionSet, aData, bData, {
131
+ fragmentMap: utilities.createFragmentMap(utilities.getFragmentDefinitions(query)),
132
+ variables: variables,
133
+ });
134
+ }
135
+ function equalBySelectionSet(selectionSet, aResult, bResult, context) {
136
+ if (aResult === bResult) {
137
+ return true;
138
+ }
139
+ var seenSelections = new Set();
140
+ return selectionSet.selections.every(function (selection) {
141
+ if (seenSelections.has(selection))
142
+ return true;
143
+ seenSelections.add(selection);
144
+ if (!utilities.shouldInclude(selection, context.variables))
145
+ return true;
146
+ if (selectionHasNonreactiveDirective(selection))
147
+ return true;
148
+ if (utilities.isField(selection)) {
149
+ var resultKey = utilities.resultKeyNameFromField(selection);
150
+ var aResultChild = aResult && aResult[resultKey];
151
+ var bResultChild = bResult && bResult[resultKey];
152
+ var childSelectionSet = selection.selectionSet;
153
+ if (!childSelectionSet) {
154
+ return equal__default(aResultChild, bResultChild);
155
+ }
156
+ var aChildIsArray = Array.isArray(aResultChild);
157
+ var bChildIsArray = Array.isArray(bResultChild);
158
+ if (aChildIsArray !== bChildIsArray)
159
+ return false;
160
+ if (aChildIsArray && bChildIsArray) {
161
+ var length_1 = aResultChild.length;
162
+ if (bResultChild.length !== length_1) {
163
+ return false;
164
+ }
165
+ for (var i = 0; i < length_1; ++i) {
166
+ if (!equalBySelectionSet(childSelectionSet, aResultChild[i], bResultChild[i], context)) {
167
+ return false;
168
+ }
169
+ }
170
+ return true;
171
+ }
172
+ return equalBySelectionSet(childSelectionSet, aResultChild, bResultChild, context);
173
+ }
174
+ else {
175
+ var fragment = utilities.getFragmentFromSelection(selection, context.fragmentMap);
176
+ if (fragment) {
177
+ if (selectionHasNonreactiveDirective(fragment))
178
+ return true;
179
+ return equalBySelectionSet(fragment.selectionSet, aResult, bResult, context);
180
+ }
181
+ }
182
+ });
183
+ }
184
+ function selectionHasNonreactiveDirective(selection) {
185
+ return !!selection.directives && selection.directives.some(directiveIsNonreactive);
186
+ }
187
+ function directiveIsNonreactive(dir) {
188
+ return dir.name.value === "nonreactive";
189
+ }
119
190
 
120
191
  var assign = Object.assign, hasOwnProperty$1 = Object.hasOwnProperty;
121
192
  var ObservableQuery = (function (_super) {
@@ -123,14 +194,13 @@ var ObservableQuery = (function (_super) {
123
194
  function ObservableQuery(_a) {
124
195
  var queryManager = _a.queryManager, queryInfo = _a.queryInfo, options = _a.options;
125
196
  var _this = _super.call(this, function (observer) {
126
- var _a = options.fetchOnFirstSubscribe, fetchOnFirstSubscribe = _a === void 0 ? true : _a;
127
197
  try {
128
198
  var subObserver = observer._subscription._observer;
129
199
  if (subObserver && !subObserver.error) {
130
200
  subObserver.error = defaultSubscriptionObserverErrorCallback;
131
201
  }
132
202
  }
133
- catch (_b) { }
203
+ catch (_a) { }
134
204
  var first = !_this.observers.size;
135
205
  _this.observers.add(observer);
136
206
  var last = _this.last;
@@ -140,7 +210,7 @@ var ObservableQuery = (function (_super) {
140
210
  else if (last && last.result) {
141
211
  observer.next && observer.next(last.result);
142
212
  }
143
- if (first && fetchOnFirstSubscribe) {
213
+ if (first) {
144
214
  _this.reobserve().catch(function () { });
145
215
  }
146
216
  return function () {
@@ -164,7 +234,7 @@ var ObservableQuery = (function (_super) {
164
234
  }
165
235
  Object.defineProperty(ObservableQuery.prototype, "query", {
166
236
  get: function () {
167
- return this.queryManager.transform(this.options.query).document;
237
+ return this.lastQuery || this.options.query;
168
238
  },
169
239
  enumerable: false,
170
240
  configurable: true
@@ -206,13 +276,13 @@ var ObservableQuery = (function (_super) {
206
276
  if (fetchPolicy === 'network-only' ||
207
277
  fetchPolicy === 'no-cache' ||
208
278
  fetchPolicy === 'standby' ||
209
- this.queryManager.transform(this.options.query).hasForcedResolvers) ;
279
+ this.queryManager.getDocumentInfo(this.query).hasForcedResolvers) ;
210
280
  else {
211
281
  var diff = this.queryInfo.getDiff();
212
282
  if (diff.complete || this.options.returnPartialData) {
213
283
  result.data = diff.result;
214
284
  }
215
- if (equality.equal(result.data, {})) {
285
+ if (equal.equal(result.data, {})) {
216
286
  result.data = void 0;
217
287
  }
218
288
  if (diff.complete) {
@@ -243,15 +313,20 @@ var ObservableQuery = (function (_super) {
243
313
  return result;
244
314
  };
245
315
  ObservableQuery.prototype.isDifferentFromLastResult = function (newResult, variables) {
246
- return (!this.last ||
247
- !equality.equal(this.last.result, newResult) ||
248
- (variables && !equality.equal(this.last.variables, variables)));
316
+ if (!this.last) {
317
+ return true;
318
+ }
319
+ var resultIsDifferent = this.queryManager.getDocumentInfo(this.query).hasNonreactiveDirective
320
+ ? !equalByQuery(this.query, this.last.result, newResult, this.variables)
321
+ : !equal.equal(this.last.result, newResult);
322
+ return (resultIsDifferent ||
323
+ (variables && !equal.equal(this.last.variables, variables)));
249
324
  };
250
325
  ObservableQuery.prototype.getLast = function (key, variablesMustMatch) {
251
326
  var last = this.last;
252
327
  if (last &&
253
328
  last[key] &&
254
- (!variablesMustMatch || equality.equal(last.variables, this.variables))) {
329
+ (!variablesMustMatch || equal.equal(last.variables, this.variables))) {
255
330
  return last[key];
256
331
  }
257
332
  };
@@ -287,10 +362,14 @@ var ObservableQuery = (function (_super) {
287
362
  var queryDef = utilities.getQueryDefinition(this.query);
288
363
  var vars = queryDef.variableDefinitions;
289
364
  if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
290
- globals.__DEV__ && globals.invariant.warn("Called refetch(".concat(JSON.stringify(variables), ") for query ").concat(((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || JSON.stringify(queryDef), ", which does not declare a $variables variable.\nDid you mean to call refetch(variables) instead of refetch({ variables })?"));
365
+ globals.__DEV__ && globals.invariant.warn(
366
+ 19,
367
+ variables,
368
+ ((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || queryDef
369
+ );
291
370
  }
292
371
  }
293
- if (variables && !equality.equal(this.options.variables, variables)) {
372
+ if (variables && !equal.equal(this.options.variables, variables)) {
294
373
  reobserveOptions.variables = this.options.variables = tslib.__assign(tslib.__assign({}, this.options.variables), variables);
295
374
  }
296
375
  this.queryInfo.resetLastWrite();
@@ -298,8 +377,12 @@ var ObservableQuery = (function (_super) {
298
377
  };
299
378
  ObservableQuery.prototype.fetchMore = function (fetchMoreOptions) {
300
379
  var _this = this;
301
- var combinedOptions = tslib.__assign(tslib.__assign({}, (fetchMoreOptions.query ? fetchMoreOptions : tslib.__assign(tslib.__assign(tslib.__assign(tslib.__assign({}, this.options), { query: this.query }), fetchMoreOptions), { variables: tslib.__assign(tslib.__assign({}, this.options.variables), fetchMoreOptions.variables) }))), { fetchPolicy: "no-cache" });
380
+ var combinedOptions = tslib.__assign(tslib.__assign({}, (fetchMoreOptions.query ? fetchMoreOptions : tslib.__assign(tslib.__assign(tslib.__assign(tslib.__assign({}, this.options), { query: this.options.query }), fetchMoreOptions), { variables: tslib.__assign(tslib.__assign({}, this.options.variables), fetchMoreOptions.variables) }))), { fetchPolicy: "no-cache" });
381
+ combinedOptions.query = this.transformDocument(combinedOptions.query);
302
382
  var qid = this.queryManager.generateQueryId();
383
+ this.lastQuery = fetchMoreOptions.query
384
+ ? this.transformDocument(this.options.query)
385
+ : combinedOptions.query;
303
386
  var queryInfo = this.queryInfo;
304
387
  var originalNetworkStatus = queryInfo.networkStatus;
305
388
  queryInfo.networkStatus = exports.NetworkStatus.fetchMore;
@@ -371,7 +454,7 @@ var ObservableQuery = (function (_super) {
371
454
  options.onError(err);
372
455
  return;
373
456
  }
374
- globals.__DEV__ && globals.invariant.error('Unhandled GraphQL subscription error', err);
457
+ globals.__DEV__ && globals.invariant.error(20, err);
375
458
  },
376
459
  });
377
460
  this.subscriptions.add(subscription);
@@ -385,7 +468,7 @@ var ObservableQuery = (function (_super) {
385
468
  return this.reobserve(newOptions);
386
469
  };
387
470
  ObservableQuery.prototype.setVariables = function (variables) {
388
- if (equality.equal(this.variables, variables)) {
471
+ if (equal.equal(this.variables, variables)) {
389
472
  return this.observers.size
390
473
  ? this.result()
391
474
  : Promise.resolve();
@@ -450,7 +533,7 @@ var ObservableQuery = (function (_super) {
450
533
  };
451
534
  ObservableQuery.prototype.fetch = function (options, newNetworkStatus) {
452
535
  this.queryManager.setObservableQuery(this);
453
- return this.queryManager.fetchQueryObservable(this.queryId, options, newNetworkStatus);
536
+ return this.queryManager['fetchConcastWithInfo'](this.queryId, options, newNetworkStatus);
454
537
  };
455
538
  ObservableQuery.prototype.updatePolling = function () {
456
539
  var _this = this;
@@ -469,7 +552,7 @@ var ObservableQuery = (function (_super) {
469
552
  pollingInfo.interval === pollInterval) {
470
553
  return;
471
554
  }
472
- globals.__DEV__ ? globals.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : globals.invariant(pollInterval, 13);
555
+ globals.invariant(pollInterval, 21);
473
556
  var info = pollingInfo || (this.pollingInfo = {});
474
557
  info.interval = pollInterval;
475
558
  var maybeFetch = function () {
@@ -495,13 +578,13 @@ var ObservableQuery = (function (_super) {
495
578
  };
496
579
  ObservableQuery.prototype.updateLastResult = function (newResult, variables) {
497
580
  if (variables === void 0) { variables = this.variables; }
498
- this.last = tslib.__assign(tslib.__assign({}, this.last), { result: this.queryManager.assumeImmutableResults
499
- ? newResult
500
- : utilities.cloneDeep(newResult), variables: variables });
501
- if (!utilities.isNonEmptyArray(newResult.errors)) {
502
- delete this.last.error;
581
+ var error = this.getLastError();
582
+ if (error && this.last && !equal.equal(variables, this.last.variables)) {
583
+ error = void 0;
503
584
  }
504
- return this.last;
585
+ return this.last = tslib.__assign({ result: this.queryManager.assumeImmutableResults
586
+ ? newResult
587
+ : utilities.cloneDeep(newResult), variables: variables }, (error ? { error: error } : null));
505
588
  };
506
589
  ObservableQuery.prototype.reobserveAsConcast = function (newOptions, newNetworkStatus) {
507
590
  var _this = this;
@@ -515,11 +598,13 @@ var ObservableQuery = (function (_super) {
515
598
  var options = useDisposableConcast
516
599
  ? mergedOptions
517
600
  : assign(this.options, mergedOptions);
601
+ var query = this.transformDocument(options.query);
602
+ this.lastQuery = query;
518
603
  if (!useDisposableConcast) {
519
604
  this.updatePolling();
520
605
  if (newOptions &&
521
606
  newOptions.variables &&
522
- !equality.equal(newOptions.variables, oldVariables) &&
607
+ !equal.equal(newOptions.variables, oldVariables) &&
523
608
  options.fetchPolicy !== "standby" &&
524
609
  options.fetchPolicy === oldFetchPolicy) {
525
610
  this.applyNextFetchPolicy("variables-changed", options);
@@ -528,8 +613,9 @@ var ObservableQuery = (function (_super) {
528
613
  }
529
614
  }
530
615
  }
616
+ var fetchOptions = query === options.query ? options : tslib.__assign(tslib.__assign({}, options), { query: query });
531
617
  var variables = options.variables && tslib.__assign({}, options.variables);
532
- var concast = this.fetch(options, newNetworkStatus);
618
+ var _a = this.fetch(fetchOptions, newNetworkStatus), concast = _a.concast, fromLink = _a.fromLink;
533
619
  var observer = {
534
620
  next: function (result) {
535
621
  _this.reportResult(result, variables);
@@ -538,7 +624,7 @@ var ObservableQuery = (function (_super) {
538
624
  _this.reportError(error, variables);
539
625
  },
540
626
  };
541
- if (!useDisposableConcast) {
627
+ if (!useDisposableConcast && (fromLink || !this.concast)) {
542
628
  if (this.concast && this.observer) {
543
629
  this.concast.removeObserver(this.observer);
544
630
  }
@@ -556,11 +642,12 @@ var ObservableQuery = (function (_super) {
556
642
  };
557
643
  ObservableQuery.prototype.reportResult = function (result, variables) {
558
644
  var lastError = this.getLastError();
559
- if (lastError || this.isDifferentFromLastResult(result, variables)) {
560
- if (lastError || !result.partial || this.options.returnPartialData) {
561
- this.updateLastResult(result, variables);
562
- }
563
- utilities.iterateObserversSafely(this.observers, 'next', result);
645
+ var isDifferent = this.isDifferentFromLastResult(result, variables);
646
+ if (lastError || !result.partial || this.options.returnPartialData) {
647
+ this.updateLastResult(result, variables);
648
+ }
649
+ if (lastError || isDifferent) {
650
+ utilities.iterateObserversSafely(this.observers, "next", result);
564
651
  }
565
652
  };
566
653
  ObservableQuery.prototype.reportError = function (error, variables) {
@@ -586,6 +673,9 @@ var ObservableQuery = (function (_super) {
586
673
  this.observers.clear();
587
674
  this.isTornDown = true;
588
675
  };
676
+ ObservableQuery.prototype.transformDocument = function (document) {
677
+ return this.queryManager.transform(document);
678
+ };
589
679
  return ObservableQuery;
590
680
  }(utilities.Observable));
591
681
  utilities.fixObservableSubclass(ObservableQuery);
@@ -607,11 +697,11 @@ function reobserveCacheFirst(obsQuery) {
607
697
  return obsQuery.reobserve();
608
698
  }
609
699
  function defaultSubscriptionObserverErrorCallback(error) {
610
- globals.__DEV__ && globals.invariant.error('Unhandled error', error.message, error.stack);
700
+ globals.__DEV__ && globals.invariant.error(22, error.message, error.stack);
611
701
  }
612
702
  function logMissingFieldErrors(missing) {
613
703
  if (globals.__DEV__ && missing) {
614
- globals.__DEV__ && globals.invariant.debug("Missing cache result fields: ".concat(JSON.stringify(missing)), missing);
704
+ globals.__DEV__ && globals.invariant.debug(23, missing);
615
705
  }
616
706
  }
617
707
 
@@ -674,12 +764,8 @@ var LocalState = (function () {
674
764
  }
675
765
  return null;
676
766
  };
677
- LocalState.prototype.serverQuery = function (document, options) {
678
- if (options === void 0) { options = Object.create(null); }
679
- var _a = options.removeClientFields, removeClientFields = _a === void 0 ? true : _a;
680
- return removeClientFields
681
- ? utilities.removeClientSetsFromDocument(document)
682
- : document;
767
+ LocalState.prototype.serverQuery = function (document) {
768
+ return utilities.removeClientSetsFromDocument(document);
683
769
  };
684
770
  LocalState.prototype.prepareContext = function (context) {
685
771
  var cache = this.cache;
@@ -794,7 +880,7 @@ var LocalState = (function () {
794
880
  }
795
881
  else {
796
882
  fragment = fragmentMap[selection.name.value];
797
- globals.__DEV__ ? globals.invariant(fragment, "No fragment named ".concat(selection.name.value)) : globals.invariant(fragment, 11);
883
+ globals.invariant(fragment, 17, selection.name.value);
798
884
  }
799
885
  if (fragment && fragment.typeCondition) {
800
886
  typeCondition = fragment.typeCondition.name.value;
@@ -907,7 +993,7 @@ var LocalState = (function () {
907
993
  },
908
994
  FragmentSpread: function (spread, _, __, ___, ancestors) {
909
995
  var fragment = fragmentMap[spread.name.value];
910
- globals.__DEV__ ? globals.invariant(fragment, "No fragment named ".concat(spread.name.value)) : globals.invariant(fragment, 12);
996
+ globals.invariant(fragment, 18, spread.name.value);
911
997
  var fragmentSelections = collectByDefinition(fragment);
912
998
  if (fragmentSelections.size > 0) {
913
999
  ancestors.forEach(function (node) {
@@ -969,10 +1055,10 @@ var QueryInfo = (function () {
969
1055
  var networkStatus = query.networkStatus || exports.NetworkStatus.loading;
970
1056
  if (this.variables &&
971
1057
  this.networkStatus !== exports.NetworkStatus.loading &&
972
- !equality.equal(this.variables, query.variables)) {
1058
+ !equal.equal(this.variables, query.variables)) {
973
1059
  networkStatus = exports.NetworkStatus.setVariables;
974
1060
  }
975
- if (!equality.equal(query.variables, this.variables)) {
1061
+ if (!equal.equal(query.variables, this.variables)) {
976
1062
  this.lastDiff = void 0;
977
1063
  }
978
1064
  Object.assign(this, {
@@ -997,7 +1083,7 @@ var QueryInfo = (function () {
997
1083
  QueryInfo.prototype.getDiff = function (variables) {
998
1084
  if (variables === void 0) { variables = this.variables; }
999
1085
  var options = this.getDiffOptions(variables);
1000
- if (this.lastDiff && equality.equal(options, this.lastDiff.options)) {
1086
+ if (this.lastDiff && equal.equal(options, this.lastDiff.options)) {
1001
1087
  return this.lastDiff.diff;
1002
1088
  }
1003
1089
  this.updateWatch(this.variables = variables);
@@ -1031,7 +1117,7 @@ var QueryInfo = (function () {
1031
1117
  var oldDiff = this.lastDiff && this.lastDiff.diff;
1032
1118
  this.updateLastDiff(diff);
1033
1119
  if (!this.dirty &&
1034
- !equality.equal(oldDiff && oldDiff.result, diff && diff.result)) {
1120
+ !equal.equal(oldDiff && oldDiff.result, diff && diff.result)) {
1035
1121
  this.dirty = true;
1036
1122
  if (!this.notifyTimeout) {
1037
1123
  this.notifyTimeout = setTimeout(function () { return _this.notify(); }, 0);
@@ -1106,7 +1192,7 @@ var QueryInfo = (function () {
1106
1192
  }
1107
1193
  var watchOptions = tslib.__assign(tslib.__assign({}, this.getDiffOptions(variables)), { watcher: this, callback: function (diff) { return _this.setDiff(diff); } });
1108
1194
  if (!this.lastWatch ||
1109
- !equality.equal(watchOptions, this.lastWatch)) {
1195
+ !equal.equal(watchOptions, this.lastWatch)) {
1110
1196
  this.cancel();
1111
1197
  this.cancel = this.cache.watch(this.lastWatch = watchOptions);
1112
1198
  }
@@ -1118,8 +1204,8 @@ var QueryInfo = (function () {
1118
1204
  var lastWrite = this.lastWrite;
1119
1205
  return !(lastWrite &&
1120
1206
  lastWrite.dmCount === destructiveMethodCounts.get(this.cache) &&
1121
- equality.equal(variables, lastWrite.variables) &&
1122
- equality.equal(result.data, lastWrite.result.data));
1207
+ equal.equal(variables, lastWrite.variables) &&
1208
+ equal.equal(result.data, lastWrite.result.data));
1123
1209
  };
1124
1210
  QueryInfo.prototype.markResult = function (result, document, options, cacheWriteBehavior) {
1125
1211
  var _this = this;
@@ -1211,7 +1297,8 @@ function shouldWriteResult(result, errorPolicy) {
1211
1297
  var hasOwnProperty = Object.prototype.hasOwnProperty;
1212
1298
  var QueryManager = (function () {
1213
1299
  function QueryManager(_a) {
1214
- var cache = _a.cache, link = _a.link, defaultOptions = _a.defaultOptions, _b = _a.queryDeduplication, queryDeduplication = _b === void 0 ? false : _b, onBroadcast = _a.onBroadcast, _c = _a.ssrMode, ssrMode = _c === void 0 ? false : _c, _d = _a.clientAwareness, clientAwareness = _d === void 0 ? {} : _d, localState = _a.localState, assumeImmutableResults = _a.assumeImmutableResults;
1300
+ var cache = _a.cache, link = _a.link, defaultOptions = _a.defaultOptions, documentTransform = _a.documentTransform, _b = _a.queryDeduplication, queryDeduplication = _b === void 0 ? false : _b, onBroadcast = _a.onBroadcast, _c = _a.ssrMode, ssrMode = _c === void 0 ? false : _c, _d = _a.clientAwareness, clientAwareness = _d === void 0 ? {} : _d, localState = _a.localState, _e = _a.assumeImmutableResults, assumeImmutableResults = _e === void 0 ? !!cache.assumeImmutableResults : _e;
1301
+ var _this = this;
1215
1302
  this.clientAwareness = {};
1216
1303
  this.queries = new Map();
1217
1304
  this.fetchCancelFns = new Map();
@@ -1220,6 +1307,7 @@ var QueryManager = (function () {
1220
1307
  this.requestIdCounter = 1;
1221
1308
  this.mutationIdCounter = 1;
1222
1309
  this.inFlightLinkObservables = new Map();
1310
+ var defaultDocumentTransform = new utilities.DocumentTransform(function (document) { return _this.cache.transformDocument(document); }, { cache: false });
1223
1311
  this.cache = cache;
1224
1312
  this.link = link;
1225
1313
  this.defaultOptions = defaultOptions || Object.create(null);
@@ -1227,7 +1315,12 @@ var QueryManager = (function () {
1227
1315
  this.clientAwareness = clientAwareness;
1228
1316
  this.localState = localState || new LocalState({ cache: cache });
1229
1317
  this.ssrMode = ssrMode;
1230
- this.assumeImmutableResults = !!assumeImmutableResults;
1318
+ this.assumeImmutableResults = assumeImmutableResults;
1319
+ this.documentTransform = documentTransform
1320
+ ? defaultDocumentTransform
1321
+ .concat(documentTransform)
1322
+ .concat(defaultDocumentTransform)
1323
+ : defaultDocumentTransform;
1231
1324
  if ((this.onBroadcast = onBroadcast)) {
1232
1325
  this.mutationStore = Object.create(null);
1233
1326
  }
@@ -1237,7 +1330,7 @@ var QueryManager = (function () {
1237
1330
  this.queries.forEach(function (_info, queryId) {
1238
1331
  _this.stopQueryNoBroadcast(queryId);
1239
1332
  });
1240
- this.cancelPendingFetches(globals.__DEV__ ? new globals.InvariantError('QueryManager stopped while query was in flight') : new globals.InvariantError(14));
1333
+ this.cancelPendingFetches(globals.newInvariantError(24));
1241
1334
  };
1242
1335
  QueryManager.prototype.cancelPendingFetches = function (error) {
1243
1336
  this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
@@ -1247,23 +1340,22 @@ var QueryManager = (function () {
1247
1340
  var _b, _c;
1248
1341
  var mutation = _a.mutation, variables = _a.variables, optimisticResponse = _a.optimisticResponse, updateQueries = _a.updateQueries, _d = _a.refetchQueries, refetchQueries = _d === void 0 ? [] : _d, _e = _a.awaitRefetchQueries, awaitRefetchQueries = _e === void 0 ? false : _e, updateWithProxyFn = _a.update, onQueryUpdated = _a.onQueryUpdated, _f = _a.fetchPolicy, fetchPolicy = _f === void 0 ? ((_b = this.defaultOptions.mutate) === null || _b === void 0 ? void 0 : _b.fetchPolicy) || "network-only" : _f, _g = _a.errorPolicy, errorPolicy = _g === void 0 ? ((_c = this.defaultOptions.mutate) === null || _c === void 0 ? void 0 : _c.errorPolicy) || "none" : _g, keepRootFields = _a.keepRootFields, context = _a.context;
1249
1342
  return tslib.__awaiter(this, void 0, void 0, function () {
1250
- var mutationId, _h, document, hasClientExports, mutationStoreValue, self;
1251
- return tslib.__generator(this, function (_j) {
1252
- switch (_j.label) {
1343
+ var mutationId, hasClientExports, mutationStoreValue, self;
1344
+ return tslib.__generator(this, function (_h) {
1345
+ switch (_h.label) {
1253
1346
  case 0:
1254
- globals.__DEV__ ? globals.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : globals.invariant(mutation, 15);
1255
- globals.__DEV__ ? globals.invariant(fetchPolicy === 'network-only' ||
1256
- fetchPolicy === 'no-cache', "Mutations support only 'network-only' or 'no-cache' fetchPolicy strings. The default `network-only` behavior automatically writes mutation results to the cache. Passing `no-cache` skips the cache write.") : globals.invariant(fetchPolicy === 'network-only' ||
1257
- fetchPolicy === 'no-cache', 16);
1347
+ globals.invariant(mutation, 25);
1348
+ globals.invariant(fetchPolicy === 'network-only' ||
1349
+ fetchPolicy === 'no-cache', 26);
1258
1350
  mutationId = this.generateMutationId();
1259
- _h = this.transform(mutation), document = _h.document, hasClientExports = _h.hasClientExports;
1260
- mutation = this.cache.transformForLink(document);
1351
+ mutation = this.cache.transformForLink(this.transform(mutation));
1352
+ hasClientExports = this.getDocumentInfo(mutation).hasClientExports;
1261
1353
  variables = this.getVariables(mutation, variables);
1262
1354
  if (!hasClientExports) return [3, 2];
1263
1355
  return [4, this.localState.addExportedVariables(mutation, variables, context)];
1264
1356
  case 1:
1265
- variables = (_j.sent());
1266
- _j.label = 2;
1357
+ variables = (_h.sent());
1358
+ _h.label = 2;
1267
1359
  case 2:
1268
1360
  mutationStoreValue = this.mutationStore &&
1269
1361
  (this.mutationStore[mutationId] = {
@@ -1366,7 +1458,7 @@ var QueryManager = (function () {
1366
1458
  if (utilities.isExecutionPatchIncrementalResult(result) && utilities.isNonEmptyArray(result.incremental)) {
1367
1459
  var diff = cache.diff({
1368
1460
  id: "ROOT_MUTATION",
1369
- query: this.transform(mutation.document).asQuery,
1461
+ query: this.getDocumentInfo(mutation.document).asQuery,
1370
1462
  variables: mutation.variables,
1371
1463
  optimistic: false,
1372
1464
  returnPartialData: true,
@@ -1437,7 +1529,7 @@ var QueryManager = (function () {
1437
1529
  if (!skipCache) {
1438
1530
  var diff = cache.diff({
1439
1531
  id: "ROOT_MUTATION",
1440
- query: _this.transform(mutation.document).asQuery,
1532
+ query: _this.getDocumentInfo(mutation.document).asQuery,
1441
1533
  variables: mutation.variables,
1442
1534
  optimistic: false,
1443
1535
  returnPartialData: true,
@@ -1495,7 +1587,7 @@ var QueryManager = (function () {
1495
1587
  }, mutation.mutationId);
1496
1588
  };
1497
1589
  QueryManager.prototype.fetchQuery = function (queryId, options, networkStatus) {
1498
- return this.fetchQueryObservable(queryId, options, networkStatus).promise;
1590
+ return this.fetchConcastWithInfo(queryId, options, networkStatus).concast.promise;
1499
1591
  };
1500
1592
  QueryManager.prototype.getQueryStore = function () {
1501
1593
  var store = Object.create(null);
@@ -1517,22 +1609,23 @@ var QueryManager = (function () {
1517
1609
  }
1518
1610
  };
1519
1611
  QueryManager.prototype.transform = function (document) {
1612
+ return this.documentTransform.transformDocument(document);
1613
+ };
1614
+ QueryManager.prototype.getDocumentInfo = function (document) {
1520
1615
  var transformCache = this.transformCache;
1521
- var _a = (this.defaultOptions.transformQuery || Object.create(null)).removeClientFields, removeClientFields = _a === void 0 ? true : _a;
1522
1616
  if (!transformCache.has(document)) {
1523
- var transformed = this.cache.transformDocument(document);
1524
- var noConnection = utilities.removeConnectionDirectiveFromDocument(transformed);
1525
- var clientQuery = this.localState.clientQuery(transformed);
1526
- var serverQuery = noConnection &&
1527
- this.localState.serverQuery(noConnection, { removeClientFields: removeClientFields });
1528
- var cacheEntry_1 = {
1529
- document: transformed,
1530
- hasClientExports: utilities.hasClientExports(transformed),
1531
- hasForcedResolvers: this.localState.shouldForceResolvers(transformed),
1532
- clientQuery: clientQuery,
1533
- serverQuery: serverQuery,
1534
- defaultVars: utilities.getDefaultValues(utilities.getOperationDefinition(transformed)),
1535
- asQuery: tslib.__assign(tslib.__assign({}, transformed), { definitions: transformed.definitions.map(function (def) {
1617
+ var cacheEntry = {
1618
+ hasClientExports: utilities.hasClientExports(document),
1619
+ hasForcedResolvers: this.localState.shouldForceResolvers(document),
1620
+ hasNonreactiveDirective: utilities.hasDirectives(['nonreactive'], document),
1621
+ clientQuery: this.localState.clientQuery(document),
1622
+ serverQuery: utilities.removeDirectivesFromDocument([
1623
+ { name: 'client', remove: true },
1624
+ { name: 'connection' },
1625
+ { name: 'nonreactive' },
1626
+ ], document),
1627
+ defaultVars: utilities.getDefaultValues(utilities.getOperationDefinition(document)),
1628
+ asQuery: tslib.__assign(tslib.__assign({}, document), { definitions: document.definitions.map(function (def) {
1536
1629
  if (def.kind === "OperationDefinition" &&
1537
1630
  def.operation !== "query") {
1538
1631
  return tslib.__assign(tslib.__assign({}, def), { operation: "query" });
@@ -1540,23 +1633,16 @@ var QueryManager = (function () {
1540
1633
  return def;
1541
1634
  }) })
1542
1635
  };
1543
- var add = function (doc) {
1544
- if (doc && !transformCache.has(doc)) {
1545
- transformCache.set(doc, cacheEntry_1);
1546
- }
1547
- };
1548
- add(document);
1549
- add(transformed);
1550
- add(clientQuery);
1551
- add(serverQuery);
1636
+ transformCache.set(document, cacheEntry);
1552
1637
  }
1553
1638
  return transformCache.get(document);
1554
1639
  };
1555
1640
  QueryManager.prototype.getVariables = function (document, variables) {
1556
- return tslib.__assign(tslib.__assign({}, this.transform(document).defaultVars), variables);
1641
+ return tslib.__assign(tslib.__assign({}, this.getDocumentInfo(document).defaultVars), variables);
1557
1642
  };
1558
1643
  QueryManager.prototype.watchQuery = function (options) {
1559
- options = tslib.__assign(tslib.__assign({}, options), { variables: this.getVariables(options.query, options.variables) });
1644
+ var query = this.transform(options.query);
1645
+ options = tslib.__assign(tslib.__assign({}, options), { variables: this.getVariables(query, options.variables) });
1560
1646
  if (typeof options.notifyOnNetworkStatusChange === 'undefined') {
1561
1647
  options.notifyOnNetworkStatusChange = false;
1562
1648
  }
@@ -1566,9 +1652,10 @@ var QueryManager = (function () {
1566
1652
  queryInfo: queryInfo,
1567
1653
  options: options,
1568
1654
  });
1655
+ observable['lastQuery'] = query;
1569
1656
  this.queries.set(observable.queryId, queryInfo);
1570
1657
  queryInfo.init({
1571
- document: observable.query,
1658
+ document: query,
1572
1659
  observableQuery: observable,
1573
1660
  variables: observable.variables,
1574
1661
  });
@@ -1577,12 +1664,11 @@ var QueryManager = (function () {
1577
1664
  QueryManager.prototype.query = function (options, queryId) {
1578
1665
  var _this = this;
1579
1666
  if (queryId === void 0) { queryId = this.generateQueryId(); }
1580
- globals.__DEV__ ? globals.invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
1581
- 'in the query option.') : globals.invariant(options.query, 17);
1582
- globals.__DEV__ ? globals.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : globals.invariant(options.query.kind === 'Document', 18);
1583
- globals.__DEV__ ? globals.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : globals.invariant(!options.returnPartialData, 19);
1584
- globals.__DEV__ ? globals.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : globals.invariant(!options.pollInterval, 20);
1585
- return this.fetchQuery(queryId, options).finally(function () { return _this.stopQuery(queryId); });
1667
+ globals.invariant(options.query, 27);
1668
+ globals.invariant(options.query.kind === 'Document', 28);
1669
+ globals.invariant(!options.returnPartialData, 29);
1670
+ globals.invariant(!options.pollInterval, 30);
1671
+ return this.fetchQuery(queryId, tslib.__assign(tslib.__assign({}, options), { query: this.transform(options.query) })).finally(function () { return _this.stopQuery(queryId); });
1586
1672
  };
1587
1673
  QueryManager.prototype.generateQueryId = function () {
1588
1674
  return String(this.queryIdCounter++);
@@ -1606,7 +1692,7 @@ var QueryManager = (function () {
1606
1692
  if (options === void 0) { options = {
1607
1693
  discardWatches: true,
1608
1694
  }; }
1609
- this.cancelPendingFetches(globals.__DEV__ ? new globals.InvariantError('Store reset while query was in flight (not completed in link chain)') : new globals.InvariantError(21));
1695
+ this.cancelPendingFetches(globals.newInvariantError(31));
1610
1696
  this.queries.forEach(function (queryInfo) {
1611
1697
  if (queryInfo.observableQuery) {
1612
1698
  queryInfo.networkStatus = exports.NetworkStatus.loading;
@@ -1632,7 +1718,7 @@ var QueryManager = (function () {
1632
1718
  queryNamesAndDocs.set(desc, false);
1633
1719
  }
1634
1720
  else if (utilities.isDocumentNode(desc)) {
1635
- queryNamesAndDocs.set(_this.transform(desc).document, false);
1721
+ queryNamesAndDocs.set(_this.transform(desc), false);
1636
1722
  }
1637
1723
  else if (utilities.isNonNullObject(desc) && desc.query) {
1638
1724
  legacyQueryOptions.add(desc);
@@ -1682,7 +1768,7 @@ var QueryManager = (function () {
1682
1768
  if (globals.__DEV__ && queryNamesAndDocs.size) {
1683
1769
  queryNamesAndDocs.forEach(function (included, nameOrDoc) {
1684
1770
  if (!included) {
1685
- globals.__DEV__ && globals.invariant.warn("Unknown query ".concat(typeof nameOrDoc === "string" ? "named " : "").concat(JSON.stringify(nameOrDoc, null, 2), " requested in refetchQueries options.include array"));
1771
+ globals.__DEV__ && globals.invariant.warn(typeof nameOrDoc === "string" ? 32 : 33, nameOrDoc);
1686
1772
  }
1687
1773
  });
1688
1774
  }
@@ -1711,7 +1797,7 @@ var QueryManager = (function () {
1711
1797
  QueryManager.prototype.startGraphQLSubscription = function (_a) {
1712
1798
  var _this = this;
1713
1799
  var query = _a.query, fetchPolicy = _a.fetchPolicy, errorPolicy = _a.errorPolicy, variables = _a.variables, _b = _a.context, context = _b === void 0 ? {} : _b;
1714
- query = this.transform(query).document;
1800
+ query = this.transform(query);
1715
1801
  variables = this.getVariables(query, variables);
1716
1802
  var makeObservable = function (variables) {
1717
1803
  return _this.getObservableFromLink(query, context, variables).map(function (result) {
@@ -1726,15 +1812,22 @@ var QueryManager = (function () {
1726
1812
  }
1727
1813
  _this.broadcastQueries();
1728
1814
  }
1729
- if (utilities.graphQLResultHasError(result)) {
1730
- throw new errors.ApolloError({
1731
- graphQLErrors: result.errors,
1732
- });
1815
+ var hasErrors = utilities.graphQLResultHasError(result);
1816
+ var hasProtocolErrors = errors.graphQLResultHasProtocolErrors(result);
1817
+ if (hasErrors || hasProtocolErrors) {
1818
+ var errors$1 = {};
1819
+ if (hasErrors) {
1820
+ errors$1.graphQLErrors = result.errors;
1821
+ }
1822
+ if (hasProtocolErrors) {
1823
+ errors$1.protocolErrors = result.extensions[errors.PROTOCOL_ERRORS_SYMBOL];
1824
+ }
1825
+ throw new errors.ApolloError(errors$1);
1733
1826
  }
1734
1827
  return result;
1735
1828
  });
1736
1829
  };
1737
- if (this.transform(query).hasClientExports) {
1830
+ if (this.getDocumentInfo(query).hasClientExports) {
1738
1831
  var observablePromise_1 = this.localState.addExportedVariables(query, variables, context).then(makeObservable);
1739
1832
  return new utilities.Observable(function (observer) {
1740
1833
  var sub = null;
@@ -1772,9 +1865,9 @@ var QueryManager = (function () {
1772
1865
  var _a;
1773
1866
  if (deduplication === void 0) { deduplication = (_a = context === null || context === void 0 ? void 0 : context.queryDeduplication) !== null && _a !== void 0 ? _a : this.queryDeduplication; }
1774
1867
  var observable;
1775
- var serverQuery = this.transform(query).serverQuery;
1868
+ var _b = this.getDocumentInfo(query), serverQuery = _b.serverQuery, clientQuery = _b.clientQuery;
1776
1869
  if (serverQuery) {
1777
- var _b = this, inFlightLinkObservables_1 = _b.inFlightLinkObservables, link = _b.link;
1870
+ var _c = this, inFlightLinkObservables_1 = _c.inFlightLinkObservables, link = _c.link;
1778
1871
  var operation = {
1779
1872
  query: serverQuery,
1780
1873
  variables: variables,
@@ -1812,7 +1905,6 @@ var QueryManager = (function () {
1812
1905
  ]);
1813
1906
  context = this.prepareContext(context);
1814
1907
  }
1815
- var clientQuery = this.transform(query).clientQuery;
1816
1908
  if (clientQuery) {
1817
1909
  observable = utilities.asyncMap(observable, function (result) {
1818
1910
  return _this.localState.runResolvers({
@@ -1827,7 +1919,7 @@ var QueryManager = (function () {
1827
1919
  };
1828
1920
  QueryManager.prototype.getResultsFromLink = function (queryInfo, cacheWriteBehavior, options) {
1829
1921
  var requestId = queryInfo.lastRequestId = this.generateRequestId();
1830
- var linkDocument = this.cache.transformForLink(this.transform(queryInfo.document).document);
1922
+ var linkDocument = this.cache.transformForLink(options.query);
1831
1923
  return utilities.asyncMap(this.getObservableFromLink(linkDocument, options.context, options.variables), function (result) {
1832
1924
  var graphQLErrors = utilities.getGraphQLErrorsFromResult(result);
1833
1925
  var hasErrors = graphQLErrors.length > 0;
@@ -1860,10 +1952,10 @@ var QueryManager = (function () {
1860
1952
  throw error;
1861
1953
  });
1862
1954
  };
1863
- QueryManager.prototype.fetchQueryObservable = function (queryId, options, networkStatus) {
1955
+ QueryManager.prototype.fetchConcastWithInfo = function (queryId, options, networkStatus) {
1864
1956
  var _this = this;
1865
1957
  if (networkStatus === void 0) { networkStatus = exports.NetworkStatus.loading; }
1866
- var query = this.transform(options.query).document;
1958
+ var query = options.query;
1867
1959
  var variables = this.getVariables(query, options.variables);
1868
1960
  var queryInfo = this.getQuery(queryId);
1869
1961
  var defaults = this.defaultOptions.watchQuery;
@@ -1879,24 +1971,36 @@ var QueryManager = (function () {
1879
1971
  });
1880
1972
  var fromVariables = function (variables) {
1881
1973
  normalized.variables = variables;
1882
- var concastSources = _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
1974
+ var sourcesWithInfo = _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
1883
1975
  if (normalized.fetchPolicy !== "standby" &&
1884
- concastSources.length > 0 &&
1976
+ sourcesWithInfo.sources.length > 0 &&
1885
1977
  queryInfo.observableQuery) {
1886
1978
  queryInfo.observableQuery["applyNextFetchPolicy"]("after-fetch", options);
1887
1979
  }
1888
- return concastSources;
1980
+ return sourcesWithInfo;
1889
1981
  };
1890
1982
  var cleanupCancelFn = function () { return _this.fetchCancelFns.delete(queryId); };
1891
1983
  this.fetchCancelFns.set(queryId, function (reason) {
1892
1984
  cleanupCancelFn();
1893
1985
  setTimeout(function () { return concast.cancel(reason); });
1894
1986
  });
1895
- var concast = new utilities.Concast(this.transform(normalized.query).hasClientExports
1896
- ? this.localState.addExportedVariables(normalized.query, normalized.variables, normalized.context).then(fromVariables)
1897
- : fromVariables(normalized.variables));
1987
+ var concast, containsDataFromLink;
1988
+ if (this.getDocumentInfo(normalized.query).hasClientExports) {
1989
+ concast = new utilities.Concast(this.localState
1990
+ .addExportedVariables(normalized.query, normalized.variables, normalized.context)
1991
+ .then(fromVariables).then(function (sourcesWithInfo) { return sourcesWithInfo.sources; }));
1992
+ containsDataFromLink = true;
1993
+ }
1994
+ else {
1995
+ var sourcesWithInfo = fromVariables(normalized.variables);
1996
+ containsDataFromLink = sourcesWithInfo.fromLink;
1997
+ concast = new utilities.Concast(sourcesWithInfo.sources);
1998
+ }
1898
1999
  concast.promise.then(cleanupCancelFn, cleanupCancelFn);
1899
- return concast;
2000
+ return {
2001
+ concast: concast,
2002
+ fromLink: containsDataFromLink,
2003
+ };
1900
2004
  };
1901
2005
  QueryManager.prototype.refetchQueries = function (_a) {
1902
2006
  var _this = this;
@@ -1971,7 +2075,7 @@ var QueryManager = (function () {
1971
2075
  var query = _a.query, variables = _a.variables, fetchPolicy = _a.fetchPolicy, refetchWritePolicy = _a.refetchWritePolicy, errorPolicy = _a.errorPolicy, returnPartialData = _a.returnPartialData, context = _a.context, notifyOnNetworkStatusChange = _a.notifyOnNetworkStatusChange;
1972
2076
  var oldNetworkStatus = queryInfo.networkStatus;
1973
2077
  queryInfo.init({
1974
- document: this.transform(query).document,
2078
+ document: query,
1975
2079
  variables: variables,
1976
2080
  networkStatus: networkStatus,
1977
2081
  });
@@ -1981,11 +2085,11 @@ var QueryManager = (function () {
1981
2085
  var data = diff.result;
1982
2086
  if (globals.__DEV__ &&
1983
2087
  !returnPartialData &&
1984
- !equality.equal(data, {})) {
2088
+ !equal.equal(data, {})) {
1985
2089
  logMissingFieldErrors(diff.missing);
1986
2090
  }
1987
2091
  var fromData = function (data) { return utilities.Observable.of(tslib.__assign({ data: data, loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus }, (diff.complete ? null : { partial: true }))); };
1988
- if (data && _this.transform(query).hasForcedResolvers) {
2092
+ if (data && _this.getDocumentInfo(query).hasForcedResolvers) {
1989
2093
  return _this.localState.runResolvers({
1990
2094
  document: query,
1991
2095
  remoteResult: { data: data },
@@ -2006,6 +2110,7 @@ var QueryManager = (function () {
2006
2110
  refetchWritePolicy !== "merge") ? 1
2007
2111
  : 2;
2008
2112
  var resultsFromLink = function () { return _this.getResultsFromLink(queryInfo, cacheWriteBehavior, {
2113
+ query: query,
2009
2114
  variables: variables,
2010
2115
  context: context,
2011
2116
  fetchPolicy: fetchPolicy,
@@ -2020,54 +2125,40 @@ var QueryManager = (function () {
2020
2125
  case "cache-first": {
2021
2126
  var diff = readCache();
2022
2127
  if (diff.complete) {
2023
- return [
2024
- resultsFromCache(diff, queryInfo.markReady()),
2025
- ];
2128
+ return { fromLink: false, sources: [resultsFromCache(diff, queryInfo.markReady())] };
2026
2129
  }
2027
2130
  if (returnPartialData || shouldNotify) {
2028
- return [
2029
- resultsFromCache(diff),
2030
- resultsFromLink(),
2031
- ];
2131
+ return { fromLink: true, sources: [resultsFromCache(diff), resultsFromLink()] };
2032
2132
  }
2033
- return [
2034
- resultsFromLink(),
2035
- ];
2133
+ return { fromLink: true, sources: [resultsFromLink()] };
2036
2134
  }
2037
2135
  case "cache-and-network": {
2038
2136
  var diff = readCache();
2039
2137
  if (diff.complete || returnPartialData || shouldNotify) {
2040
- return [
2041
- resultsFromCache(diff),
2042
- resultsFromLink(),
2043
- ];
2138
+ return { fromLink: true, sources: [resultsFromCache(diff), resultsFromLink()] };
2044
2139
  }
2045
- return [
2046
- resultsFromLink(),
2047
- ];
2140
+ return { fromLink: true, sources: [resultsFromLink()] };
2048
2141
  }
2049
2142
  case "cache-only":
2050
- return [
2051
- resultsFromCache(readCache(), queryInfo.markReady()),
2052
- ];
2143
+ return { fromLink: false, sources: [resultsFromCache(readCache(), queryInfo.markReady())] };
2053
2144
  case "network-only":
2054
2145
  if (shouldNotify) {
2055
- return [
2056
- resultsFromCache(readCache()),
2057
- resultsFromLink(),
2058
- ];
2146
+ return { fromLink: true, sources: [resultsFromCache(readCache()), resultsFromLink()] };
2059
2147
  }
2060
- return [resultsFromLink()];
2148
+ return { fromLink: true, sources: [resultsFromLink()] };
2061
2149
  case "no-cache":
2062
2150
  if (shouldNotify) {
2063
- return [
2064
- resultsFromCache(queryInfo.getDiff()),
2065
- resultsFromLink(),
2066
- ];
2151
+ return {
2152
+ fromLink: true,
2153
+ sources: [
2154
+ resultsFromCache(queryInfo.getDiff()),
2155
+ resultsFromLink(),
2156
+ ],
2157
+ };
2067
2158
  }
2068
- return [resultsFromLink()];
2159
+ return { fromLink: true, sources: [resultsFromLink()] };
2069
2160
  case "standby":
2070
- return [];
2161
+ return { fromLink: false, sources: [] };
2071
2162
  }
2072
2163
  };
2073
2164
  QueryManager.prototype.getQuery = function (queryId) {
@@ -2090,20 +2181,18 @@ var ApolloClient = (function () {
2090
2181
  var _this = this;
2091
2182
  this.resetStoreCallbacks = [];
2092
2183
  this.clearStoreCallbacks = [];
2093
- var uri = options.uri, credentials = options.credentials, headers = options.headers, cache = options.cache, _a = options.ssrMode, ssrMode = _a === void 0 ? false : _a, _b = options.ssrForceFetchDelay, ssrForceFetchDelay = _b === void 0 ? 0 : _b, _c = options.connectToDevTools, connectToDevTools = _c === void 0 ? typeof window === 'object' &&
2184
+ if (!options.cache) {
2185
+ throw globals.newInvariantError(13);
2186
+ }
2187
+ var uri = options.uri, credentials = options.credentials, headers = options.headers, cache = options.cache, documentTransform = options.documentTransform, _a = options.ssrMode, ssrMode = _a === void 0 ? false : _a, _b = options.ssrForceFetchDelay, ssrForceFetchDelay = _b === void 0 ? 0 : _b, _c = options.connectToDevTools, connectToDevTools = _c === void 0 ? typeof window === 'object' &&
2094
2188
  !window.__APOLLO_CLIENT__ &&
2095
- globals.__DEV__ : _c, _d = options.queryDeduplication, queryDeduplication = _d === void 0 ? true : _d, defaultOptions = options.defaultOptions, _e = options.assumeImmutableResults, assumeImmutableResults = _e === void 0 ? false : _e, resolvers = options.resolvers, typeDefs = options.typeDefs, fragmentMatcher = options.fragmentMatcher, clientAwarenessName = options.name, clientAwarenessVersion = options.version;
2189
+ globals.__DEV__ : _c, _d = options.queryDeduplication, queryDeduplication = _d === void 0 ? true : _d, defaultOptions = options.defaultOptions, _e = options.assumeImmutableResults, assumeImmutableResults = _e === void 0 ? cache.assumeImmutableResults : _e, resolvers = options.resolvers, typeDefs = options.typeDefs, fragmentMatcher = options.fragmentMatcher, clientAwarenessName = options.name, clientAwarenessVersion = options.version;
2096
2190
  var link = options.link;
2097
2191
  if (!link) {
2098
2192
  link = uri
2099
2193
  ? new http.HttpLink({ uri: uri, credentials: credentials, headers: headers })
2100
2194
  : core.ApolloLink.empty();
2101
2195
  }
2102
- if (!cache) {
2103
- throw globals.__DEV__ ? new globals.InvariantError("To initialize Apollo Client, you must specify a 'cache' property " +
2104
- "in the options object. \n" +
2105
- "For more information, please visit: https://go.apollo.dev/c/docs") : new globals.InvariantError(9);
2106
- }
2107
2196
  this.link = link;
2108
2197
  this.cache = cache;
2109
2198
  this.disableNetworkFetches = ssrMode || ssrForceFetchDelay > 0;
@@ -2140,8 +2229,7 @@ var ApolloClient = (function () {
2140
2229
  }
2141
2230
  }
2142
2231
  if (url) {
2143
- globals.__DEV__ && globals.invariant.log("Download the Apollo DevTools for a better development " +
2144
- "experience: " + url);
2232
+ globals.__DEV__ && globals.invariant.log(14, url);
2145
2233
  }
2146
2234
  }
2147
2235
  }
@@ -2156,6 +2244,7 @@ var ApolloClient = (function () {
2156
2244
  cache: this.cache,
2157
2245
  link: this.link,
2158
2246
  defaultOptions: this.defaultOptions,
2247
+ documentTransform: documentTransform,
2159
2248
  queryDeduplication: queryDeduplication,
2160
2249
  ssrMode: ssrMode,
2161
2250
  clientAwareness: {
@@ -2178,6 +2267,13 @@ var ApolloClient = (function () {
2178
2267
  } : void 0,
2179
2268
  });
2180
2269
  }
2270
+ Object.defineProperty(ApolloClient.prototype, "documentTransform", {
2271
+ get: function () {
2272
+ return this.queryManager.documentTransform;
2273
+ },
2274
+ enumerable: false,
2275
+ configurable: true
2276
+ });
2181
2277
  ApolloClient.prototype.stop = function () {
2182
2278
  this.queryManager.stop();
2183
2279
  };
@@ -2196,10 +2292,7 @@ var ApolloClient = (function () {
2196
2292
  if (this.defaultOptions.query) {
2197
2293
  options = utilities.mergeOptions(this.defaultOptions.query, options);
2198
2294
  }
2199
- globals.__DEV__ ? globals.invariant(options.fetchPolicy !== 'cache-and-network', 'The cache-and-network fetchPolicy does not work with client.query, because ' +
2200
- 'client.query can only return a single result. Please use client.watchQuery ' +
2201
- 'to receive multiple results from the cache and the network, or consider ' +
2202
- 'using a different fetchPolicy, such as cache-first or network-only.') : globals.invariant(options.fetchPolicy !== 'cache-and-network', 10);
2295
+ globals.invariant(options.fetchPolicy !== 'cache-and-network', 15);
2203
2296
  if (this.disableNetworkFetches && options.fetchPolicy === 'network-only') {
2204
2297
  options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: 'cache-first' });
2205
2298
  }
@@ -2288,7 +2381,7 @@ var ApolloClient = (function () {
2288
2381
  result.queries = queries;
2289
2382
  result.results = results;
2290
2383
  result.catch(function (error) {
2291
- globals.__DEV__ && globals.invariant.debug("In client.refetchQueries, Promise.all promise rejected with error ".concat(error));
2384
+ globals.__DEV__ && globals.invariant.debug(16, error);
2292
2385
  });
2293
2386
  return result;
2294
2387
  };
@@ -2322,6 +2415,7 @@ var ApolloClient = (function () {
2322
2415
 
2323
2416
  tsInvariant.setVerbosity(globals.__DEV__ ? "log" : "silent");
2324
2417
 
2418
+ exports.DocumentTransform = utilities.DocumentTransform;
2325
2419
  exports.Observable = utilities.Observable;
2326
2420
  exports.isReference = utilities.isReference;
2327
2421
  exports.makeReference = utilities.makeReference;
@@ -2346,6 +2440,7 @@ exports.gql = graphqlTag.gql;
2346
2440
  exports.resetCaches = graphqlTag.resetCaches;
2347
2441
  exports.ApolloClient = ApolloClient;
2348
2442
  exports.ObservableQuery = ObservableQuery;
2443
+ exports.isNetworkRequestSettled = isNetworkRequestSettled;
2349
2444
  for (var k in core) {
2350
2445
  if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = core[k];
2351
2446
  }