@apollo/client 3.8.0-alpha.1 → 3.8.0-alpha.11

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 (373) hide show
  1. package/README.md +3 -1
  2. package/apollo-client.cjs +661 -468
  3. package/apollo-client.cjs.map +1 -1
  4. package/apollo-client.min.cjs +1 -1
  5. package/cache/cache.cjs +56 -44
  6. package/cache/cache.cjs.map +1 -1
  7. package/cache/cache.cjs.native.js +56 -44
  8. package/cache/core/cache.d.ts +2 -1
  9. package/cache/core/cache.d.ts.map +1 -1
  10. package/cache/core/cache.js +1 -0
  11. package/cache/core/cache.js.map +1 -1
  12. package/cache/core/types/DataProxy.d.ts +3 -2
  13. package/cache/core/types/DataProxy.d.ts.map +1 -1
  14. package/cache/core/types/DataProxy.js.map +1 -1
  15. package/cache/core/types/common.d.ts +7 -7
  16. package/cache/core/types/common.d.ts.map +1 -1
  17. package/cache/inmemory/entityStore.d.ts +1 -1
  18. package/cache/inmemory/entityStore.d.ts.map +1 -1
  19. package/cache/inmemory/entityStore.js +1 -1
  20. package/cache/inmemory/helpers.d.ts +2 -2
  21. package/cache/inmemory/helpers.d.ts.map +1 -1
  22. package/cache/inmemory/helpers.js +2 -2
  23. package/cache/inmemory/helpers.js.map +1 -1
  24. package/cache/inmemory/inMemoryCache.d.ts +4 -2
  25. package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
  26. package/cache/inmemory/inMemoryCache.js +2 -1
  27. package/cache/inmemory/inMemoryCache.js.map +1 -1
  28. package/cache/inmemory/key-extractor.js +1 -1
  29. package/cache/inmemory/object-canon.d.ts +0 -1
  30. package/cache/inmemory/object-canon.d.ts.map +1 -1
  31. package/cache/inmemory/object-canon.js +1 -1
  32. package/cache/inmemory/object-canon.js.map +1 -1
  33. package/cache/inmemory/policies.d.ts +12 -12
  34. package/cache/inmemory/policies.d.ts.map +1 -1
  35. package/cache/inmemory/policies.js +15 -4
  36. package/cache/inmemory/policies.js.map +1 -1
  37. package/cache/inmemory/reactiveVars.d.ts +1 -1
  38. package/cache/inmemory/reactiveVars.d.ts.map +1 -1
  39. package/cache/inmemory/readFromStore.d.ts +2 -2
  40. package/cache/inmemory/readFromStore.d.ts.map +1 -1
  41. package/cache/inmemory/readFromStore.js +1 -1
  42. package/cache/inmemory/readFromStore.js.map +1 -1
  43. package/cache/inmemory/types.d.ts +4 -4
  44. package/cache/inmemory/types.d.ts.map +1 -1
  45. package/cache/inmemory/writeToStore.d.ts +1 -1
  46. package/cache/inmemory/writeToStore.d.ts.map +1 -1
  47. package/cache/inmemory/writeToStore.js +1 -1
  48. package/cache/inmemory/writeToStore.js.map +1 -1
  49. package/core/ApolloClient.d.ts +10 -9
  50. package/core/ApolloClient.d.ts.map +1 -1
  51. package/core/ApolloClient.js +17 -11
  52. package/core/ApolloClient.js.map +1 -1
  53. package/core/LocalState.d.ts +12 -7
  54. package/core/LocalState.d.ts.map +1 -1
  55. package/core/LocalState.js +71 -17
  56. package/core/LocalState.js.map +1 -1
  57. package/core/ObservableQuery.d.ts +6 -7
  58. package/core/ObservableQuery.d.ts.map +1 -1
  59. package/core/ObservableQuery.js +6 -10
  60. package/core/ObservableQuery.js.map +1 -1
  61. package/core/QueryInfo.d.ts +1 -1
  62. package/core/QueryInfo.d.ts.map +1 -1
  63. package/core/QueryInfo.js +1 -1
  64. package/core/QueryInfo.js.map +1 -1
  65. package/core/QueryManager.d.ts +7 -7
  66. package/core/QueryManager.d.ts.map +1 -1
  67. package/core/QueryManager.js +24 -14
  68. package/core/QueryManager.js.map +1 -1
  69. package/core/core.cjs +142 -83
  70. package/core/core.cjs.map +1 -1
  71. package/core/core.cjs.native.js +142 -83
  72. package/core/index.js +2 -2
  73. package/core/index.js.map +1 -1
  74. package/core/networkStatus.d.ts +1 -0
  75. package/core/networkStatus.d.ts.map +1 -1
  76. package/core/networkStatus.js +3 -0
  77. package/core/networkStatus.js.map +1 -1
  78. package/core/types.d.ts +24 -17
  79. package/core/types.d.ts.map +1 -1
  80. package/core/types.js +1 -0
  81. package/core/types.js.map +1 -1
  82. package/core/watchQueryOptions.d.ts +11 -12
  83. package/core/watchQueryOptions.d.ts.map +1 -1
  84. package/core/watchQueryOptions.js.map +1 -1
  85. package/errors/index.d.ts +2 -2
  86. package/errors/index.d.ts.map +1 -1
  87. package/invariantErrorCodes.js +58 -52
  88. package/link/batch/batch.cjs +5 -3
  89. package/link/batch/batch.cjs.map +1 -1
  90. package/link/batch/batch.cjs.native.js +5 -3
  91. package/link/batch/batching.d.ts +2 -2
  92. package/link/batch/batching.d.ts.map +1 -1
  93. package/link/batch/batching.js +5 -3
  94. package/link/batch/batching.js.map +1 -1
  95. package/link/batch-http/batch-http.cjs +12 -2
  96. package/link/batch-http/batch-http.cjs.map +1 -1
  97. package/link/batch-http/batch-http.cjs.native.js +12 -2
  98. package/link/batch-http/batchHttpLink.d.ts.map +1 -1
  99. package/link/batch-http/batchHttpLink.js +13 -3
  100. package/link/batch-http/batchHttpLink.js.map +1 -1
  101. package/link/context/index.d.ts +2 -1
  102. package/link/context/index.d.ts.map +1 -1
  103. package/link/context/index.js.map +1 -1
  104. package/link/core/ApolloLink.js +2 -2
  105. package/link/core/core.cjs +2 -2
  106. package/link/core/core.cjs.map +1 -1
  107. package/link/core/core.cjs.native.js +2 -2
  108. package/link/core/types.d.ts +15 -15
  109. package/link/core/types.d.ts.map +1 -1
  110. package/link/core/types.js.map +1 -1
  111. package/link/http/checkFetcher.js +2 -2
  112. package/link/http/createHttpLink.d.ts +0 -1
  113. package/link/http/createHttpLink.d.ts.map +1 -1
  114. package/link/http/createHttpLink.js +10 -2
  115. package/link/http/createHttpLink.js.map +1 -1
  116. package/link/http/http.cjs +20 -38
  117. package/link/http/http.cjs.map +1 -1
  118. package/link/http/http.cjs.native.js +20 -38
  119. package/link/http/iterators/async.js.map +1 -1
  120. package/link/http/iterators/nodeStream.js.map +1 -1
  121. package/link/http/iterators/promise.js.map +1 -1
  122. package/link/http/iterators/reader.js.map +1 -1
  123. package/link/http/parseAndCheckHttpResponse.d.ts +2 -2
  124. package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
  125. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  126. package/link/http/responseIterator.js +1 -1
  127. package/link/http/responseIterator.js.map +1 -1
  128. package/link/http/selectHttpOptionsAndBody.d.ts +2 -2
  129. package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
  130. package/link/http/selectHttpOptionsAndBody.js +3 -1
  131. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  132. package/link/http/serializeFetchParameter.d.ts +1 -1
  133. package/link/http/serializeFetchParameter.d.ts.map +1 -1
  134. package/link/http/serializeFetchParameter.js +2 -2
  135. package/link/persisted-queries/index.d.ts +2 -2
  136. package/link/persisted-queries/index.d.ts.map +1 -1
  137. package/link/persisted-queries/index.js +3 -3
  138. package/link/persisted-queries/persisted-queries.cjs +3 -3
  139. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  140. package/link/persisted-queries/persisted-queries.cjs.native.js +3 -3
  141. package/link/utils/throwServerError.d.ts +1 -1
  142. package/link/utils/throwServerError.d.ts.map +1 -1
  143. package/link/utils/toPromise.js +1 -1
  144. package/link/utils/utils.cjs +2 -2
  145. package/link/utils/utils.cjs.map +1 -1
  146. package/link/utils/utils.cjs.native.js +2 -2
  147. package/link/utils/validateOperation.js +2 -2
  148. package/package.json +26 -24
  149. package/react/cache/QuerySubscription.d.ts +26 -0
  150. package/react/cache/QuerySubscription.d.ts.map +1 -0
  151. package/react/cache/QuerySubscription.js +88 -0
  152. package/react/cache/QuerySubscription.js.map +1 -0
  153. package/react/cache/SuspenseCache.d.ts +9 -13
  154. package/react/cache/SuspenseCache.d.ts.map +1 -1
  155. package/react/cache/SuspenseCache.js +17 -40
  156. package/react/cache/SuspenseCache.js.map +1 -1
  157. package/react/components/Query.d.ts +2 -2
  158. package/react/components/Query.d.ts.map +1 -1
  159. package/react/components/Query.js.map +1 -1
  160. package/react/components/Subscription.d.ts +2 -2
  161. package/react/components/Subscription.d.ts.map +1 -1
  162. package/react/components/Subscription.js.map +1 -1
  163. package/react/components/types.d.ts +2 -2
  164. package/react/components/types.d.ts.map +1 -1
  165. package/react/components/types.js.map +1 -1
  166. package/react/context/ApolloConsumer.js +2 -2
  167. package/react/context/ApolloProvider.js +2 -2
  168. package/react/context/context.cjs +4 -4
  169. package/react/context/context.cjs.map +1 -1
  170. package/react/context/context.cjs.native.js +4 -4
  171. package/react/hoc/graphql.d.ts +2 -1
  172. package/react/hoc/graphql.d.ts.map +1 -1
  173. package/react/hoc/graphql.js.map +1 -1
  174. package/react/hoc/hoc-utils.d.ts +1 -1
  175. package/react/hoc/hoc-utils.d.ts.map +1 -1
  176. package/react/hoc/hoc-utils.js +2 -2
  177. package/react/hoc/hoc.cjs +4 -4
  178. package/react/hoc/hoc.cjs.map +1 -1
  179. package/react/hoc/hoc.cjs.native.js +4 -4
  180. package/react/hoc/mutation-hoc.d.ts +2 -2
  181. package/react/hoc/mutation-hoc.d.ts.map +1 -1
  182. package/react/hoc/mutation-hoc.js.map +1 -1
  183. package/react/hoc/query-hoc.d.ts +1 -1
  184. package/react/hoc/query-hoc.d.ts.map +1 -1
  185. package/react/hoc/query-hoc.js.map +1 -1
  186. package/react/hoc/subscription-hoc.d.ts +1 -1
  187. package/react/hoc/subscription-hoc.d.ts.map +1 -1
  188. package/react/hoc/subscription-hoc.js.map +1 -1
  189. package/react/hoc/types.d.ts +6 -6
  190. package/react/hoc/types.d.ts.map +1 -1
  191. package/react/hoc/types.js.map +1 -1
  192. package/react/hoc/withApollo.js +2 -2
  193. package/react/hooks/hooks.cjs +190 -174
  194. package/react/hooks/hooks.cjs.map +1 -1
  195. package/react/hooks/hooks.cjs.native.js +190 -174
  196. package/react/hooks/internal/__use.d.ts +2 -0
  197. package/react/hooks/internal/__use.d.ts.map +1 -0
  198. package/react/hooks/internal/__use.js +13 -0
  199. package/react/hooks/internal/__use.js.map +1 -0
  200. package/react/hooks/internal/index.d.ts +3 -0
  201. package/react/hooks/internal/index.d.ts.map +1 -1
  202. package/react/hooks/internal/index.js +3 -0
  203. package/react/hooks/internal/index.js.map +1 -1
  204. package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts +3 -0
  205. package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +1 -0
  206. package/react/hooks/internal/useIsomorphicLayoutEffect.js +6 -0
  207. package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -0
  208. package/react/hooks/internal/useStrictModeSafeCleanupEffect.d.ts +2 -0
  209. package/react/hooks/internal/useStrictModeSafeCleanupEffect.d.ts.map +1 -0
  210. package/react/hooks/internal/useStrictModeSafeCleanupEffect.js +11 -0
  211. package/react/hooks/internal/useStrictModeSafeCleanupEffect.js.map +1 -0
  212. package/react/hooks/useApolloClient.js +2 -2
  213. package/react/hooks/useFragment.d.ts +4 -2
  214. package/react/hooks/useFragment.d.ts.map +1 -1
  215. package/react/hooks/useFragment.js +9 -8
  216. package/react/hooks/useFragment.js.map +1 -1
  217. package/react/hooks/useLazyQuery.d.ts +2 -2
  218. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  219. package/react/hooks/useLazyQuery.js +22 -8
  220. package/react/hooks/useLazyQuery.js.map +1 -1
  221. package/react/hooks/useMutation.d.ts +2 -2
  222. package/react/hooks/useMutation.d.ts.map +1 -1
  223. package/react/hooks/useMutation.js +9 -8
  224. package/react/hooks/useMutation.js.map +1 -1
  225. package/react/hooks/useQuery.d.ts +6 -5
  226. package/react/hooks/useQuery.d.ts.map +1 -1
  227. package/react/hooks/useQuery.js +21 -7
  228. package/react/hooks/useQuery.js.map +1 -1
  229. package/react/hooks/useSubscription.d.ts +2 -3
  230. package/react/hooks/useSubscription.d.ts.map +1 -1
  231. package/react/hooks/useSubscription.js +1 -2
  232. package/react/hooks/useSubscription.js.map +1 -1
  233. package/react/hooks/useSuspenseCache.d.ts +2 -1
  234. package/react/hooks/useSuspenseCache.d.ts.map +1 -1
  235. package/react/hooks/useSuspenseCache.js +7 -5
  236. package/react/hooks/useSuspenseCache.js.map +1 -1
  237. package/react/hooks/useSuspenseQuery.d.ts +16 -4
  238. package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
  239. package/react/hooks/useSuspenseQuery.js +73 -136
  240. package/react/hooks/useSuspenseQuery.js.map +1 -1
  241. package/react/hooks/useSyncExternalStore.d.ts +1 -1
  242. package/react/hooks/useSyncExternalStore.d.ts.map +1 -1
  243. package/react/hooks/useSyncExternalStore.js +1 -1
  244. package/react/hooks/useSyncExternalStore.js.map +1 -1
  245. package/react/parser/index.js +6 -6
  246. package/react/parser/parser.cjs +10 -10
  247. package/react/parser/parser.cjs.map +1 -1
  248. package/react/parser/parser.cjs.native.js +10 -10
  249. package/react/react.cjs +112 -38
  250. package/react/react.cjs.map +1 -1
  251. package/react/react.cjs.native.js +112 -38
  252. package/react/ssr/RenderPromises.d.ts +4 -4
  253. package/react/ssr/RenderPromises.d.ts.map +1 -1
  254. package/react/ssr/RenderPromises.js.map +1 -1
  255. package/react/ssr/getDataFromTree.d.ts +1 -1
  256. package/react/ssr/getDataFromTree.d.ts.map +1 -1
  257. package/react/types/types.d.ts +26 -25
  258. package/react/types/types.d.ts.map +1 -1
  259. package/react/types/types.js.map +1 -1
  260. package/testing/core/core.cjs +30 -3
  261. package/testing/core/core.cjs.map +1 -1
  262. package/testing/core/core.cjs.native.js +30 -3
  263. package/testing/core/index.d.ts +2 -1
  264. package/testing/core/index.d.ts.map +1 -1
  265. package/testing/core/index.js +1 -0
  266. package/testing/core/index.js.map +1 -1
  267. package/testing/core/itAsync.js.map +1 -1
  268. package/testing/core/mocking/mockFetch.js.map +1 -1
  269. package/testing/core/mocking/mockLink.d.ts +8 -4
  270. package/testing/core/mocking/mockLink.d.ts.map +1 -1
  271. package/testing/core/mocking/mockLink.js +14 -4
  272. package/testing/core/mocking/mockLink.js.map +1 -1
  273. package/testing/core/mocking/mockQueryManager.d.ts +1 -1
  274. package/testing/core/mocking/mockQueryManager.d.ts.map +1 -1
  275. package/testing/core/mocking/mockQueryManager.js +3 -3
  276. package/testing/core/mocking/mockQueryManager.js.map +1 -1
  277. package/testing/core/mocking/mockWatchQuery.d.ts +1 -1
  278. package/testing/core/mocking/mockWatchQuery.d.ts.map +1 -1
  279. package/testing/core/mocking/mockWatchQuery.js +4 -5
  280. package/testing/core/mocking/mockWatchQuery.js.map +1 -1
  281. package/testing/core/observableToPromise.d.ts +2 -2
  282. package/testing/core/observableToPromise.d.ts.map +1 -1
  283. package/testing/core/observableToPromise.js.map +1 -1
  284. package/testing/core/wait.d.ts +3 -0
  285. package/testing/core/wait.d.ts.map +1 -0
  286. package/testing/core/wait.js +16 -0
  287. package/testing/core/wait.js.map +1 -0
  288. package/testing/react/MockedProvider.d.ts +1 -0
  289. package/testing/react/MockedProvider.d.ts.map +1 -1
  290. package/testing/react/MockedProvider.js +2 -2
  291. package/testing/react/MockedProvider.js.map +1 -1
  292. package/testing/testing.cjs +112 -40
  293. package/testing/testing.cjs.map +1 -1
  294. package/testing/testing.cjs.native.js +112 -40
  295. package/utilities/common/arrays.d.ts +1 -0
  296. package/utilities/common/arrays.d.ts.map +1 -1
  297. package/utilities/common/arrays.js +1 -0
  298. package/utilities/common/arrays.js.map +1 -1
  299. package/utilities/common/cloneDeep.js.map +1 -1
  300. package/utilities/common/errorHandling.d.ts +2 -2
  301. package/utilities/common/errorHandling.d.ts.map +1 -1
  302. package/utilities/common/errorHandling.js.map +1 -1
  303. package/utilities/common/incrementalResult.d.ts +4 -4
  304. package/utilities/common/incrementalResult.d.ts.map +1 -1
  305. package/utilities/common/incrementalResult.js.map +1 -1
  306. package/utilities/common/maybeDeepFreeze.d.ts +0 -1
  307. package/utilities/common/maybeDeepFreeze.d.ts.map +1 -1
  308. package/utilities/common/maybeDeepFreeze.js +1 -1
  309. package/utilities/common/maybeDeepFreeze.js.map +1 -1
  310. package/utilities/common/mergeDeep.d.ts +2 -2
  311. package/utilities/common/mergeDeep.d.ts.map +1 -1
  312. package/utilities/common/mergeOptions.d.ts +3 -3
  313. package/utilities/common/mergeOptions.d.ts.map +1 -1
  314. package/utilities/common/mergeOptions.js +1 -1
  315. package/utilities/common/mergeOptions.js.map +1 -1
  316. package/utilities/globals/DEV.d.ts +1 -1
  317. package/utilities/globals/DEV.d.ts.map +1 -1
  318. package/utilities/globals/DEV.js +1 -17
  319. package/utilities/globals/DEV.js.map +1 -1
  320. package/utilities/globals/global.d.ts +5 -2
  321. package/utilities/globals/global.d.ts.map +1 -1
  322. package/utilities/globals/global.js.map +1 -1
  323. package/utilities/globals/globals.cjs +5 -22
  324. package/utilities/globals/globals.cjs.map +1 -1
  325. package/utilities/globals/globals.cjs.native.js +5 -22
  326. package/utilities/globals/index.d.ts +1 -1
  327. package/utilities/globals/index.d.ts.map +1 -1
  328. package/utilities/globals/index.js +1 -4
  329. package/utilities/globals/index.js.map +1 -1
  330. package/utilities/graphql/directives.d.ts +2 -2
  331. package/utilities/graphql/directives.d.ts.map +1 -1
  332. package/utilities/graphql/directives.js +5 -5
  333. package/utilities/graphql/directives.js.map +1 -1
  334. package/utilities/graphql/fragments.d.ts +1 -1
  335. package/utilities/graphql/fragments.d.ts.map +1 -1
  336. package/utilities/graphql/fragments.js +4 -4
  337. package/utilities/graphql/getFromAST.d.ts.map +1 -1
  338. package/utilities/graphql/getFromAST.js +16 -12
  339. package/utilities/graphql/getFromAST.js.map +1 -1
  340. package/utilities/graphql/storeUtils.d.ts +3 -3
  341. package/utilities/graphql/storeUtils.d.ts.map +1 -1
  342. package/utilities/graphql/storeUtils.js +2 -2
  343. package/utilities/graphql/storeUtils.js.map +1 -1
  344. package/utilities/graphql/transform.d.ts +9 -9
  345. package/utilities/graphql/transform.d.ts.map +1 -1
  346. package/utilities/graphql/transform.js +168 -91
  347. package/utilities/graphql/transform.js.map +1 -1
  348. package/utilities/index.d.ts +2 -0
  349. package/utilities/index.d.ts.map +1 -1
  350. package/utilities/index.js +2 -0
  351. package/utilities/index.js.map +1 -1
  352. package/utilities/observables/Concast.d.ts +5 -5
  353. package/utilities/observables/Concast.d.ts.map +1 -1
  354. package/utilities/observables/Concast.js +2 -2
  355. package/utilities/observables/Concast.js.map +1 -1
  356. package/utilities/observables/asyncMap.js.map +1 -1
  357. package/utilities/policies/pagination.d.ts +7 -7
  358. package/utilities/policies/pagination.d.ts.map +1 -1
  359. package/utilities/policies/pagination.js.map +1 -1
  360. package/utilities/promises/decoration.d.ts +15 -0
  361. package/utilities/promises/decoration.d.ts.map +1 -0
  362. package/utilities/promises/decoration.js +25 -0
  363. package/utilities/promises/decoration.js.map +1 -0
  364. package/utilities/types/IsStrictlyAny.d.ts +3 -3
  365. package/utilities/types/IsStrictlyAny.d.ts.map +1 -1
  366. package/utilities/utilities.cjs +256 -128
  367. package/utilities/utilities.cjs.map +1 -1
  368. package/utilities/utilities.cjs.native.js +256 -128
  369. package/version.js +1 -1
  370. package/cache/inmemory/__mocks__/optimism.d.ts +0 -2
  371. package/cache/inmemory/__mocks__/optimism.d.ts.map +0 -1
  372. package/cache/inmemory/__mocks__/optimism.js +0 -14
  373. package/cache/inmemory/__mocks__/optimism.js.map +0 -1
@@ -7,15 +7,15 @@ var tslib = require('tslib');
7
7
  var core = require('../link/core');
8
8
  var http = require('../link/http');
9
9
  var equality = require('@wry/equality');
10
- var cache = require('../cache');
11
10
  var utilities = require('../utilities');
11
+ var cache = require('../cache');
12
12
  var errors = require('../errors');
13
13
  var graphql = require('graphql');
14
14
  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.1';
18
+ var version = '3.8.0-alpha.11';
19
19
 
20
20
  function isNonEmptyArray(value) {
21
21
  return Array.isArray(value) && value.length > 0;
@@ -83,13 +83,6 @@ var DeepMerger = (function () {
83
83
  function isExecutionPatchIncrementalResult(value) {
84
84
  return "incremental" in value;
85
85
  }
86
- function isExecutionPatchInitialResult(value) {
87
- return "hasNext" in value && "data" in value;
88
- }
89
- function isExecutionPatchResult(value) {
90
- return (isExecutionPatchIncrementalResult(value) ||
91
- isExecutionPatchInitialResult(value));
92
- }
93
86
  function mergeIncrementalData(prevResult, result) {
94
87
  var mergedData = prevResult;
95
88
  var merger = new DeepMerger();
@@ -130,14 +123,13 @@ var ObservableQuery = (function (_super) {
130
123
  function ObservableQuery(_a) {
131
124
  var queryManager = _a.queryManager, queryInfo = _a.queryInfo, options = _a.options;
132
125
  var _this = _super.call(this, function (observer) {
133
- var _a = options.fetchOnFirstSubscribe, fetchOnFirstSubscribe = _a === void 0 ? true : _a;
134
126
  try {
135
127
  var subObserver = observer._subscription._observer;
136
128
  if (subObserver && !subObserver.error) {
137
129
  subObserver.error = defaultSubscriptionObserverErrorCallback;
138
130
  }
139
131
  }
140
- catch (_b) { }
132
+ catch (_a) { }
141
133
  var first = !_this.observers.size;
142
134
  _this.observers.add(observer);
143
135
  var last = _this.last;
@@ -147,7 +139,7 @@ var ObservableQuery = (function (_super) {
147
139
  else if (last && last.result) {
148
140
  observer.next && observer.next(last.result);
149
141
  }
150
- if (first && fetchOnFirstSubscribe) {
142
+ if (first) {
151
143
  _this.reobserve().catch(function () { });
152
144
  }
153
145
  return function () {
@@ -235,7 +227,7 @@ var ObservableQuery = (function (_super) {
235
227
  else {
236
228
  result.partial = true;
237
229
  }
238
- if (__DEV__ &&
230
+ if (globals.__DEV__ &&
239
231
  !diff.complete &&
240
232
  !this.options.partialRefetch &&
241
233
  !result.loading &&
@@ -290,11 +282,11 @@ var ObservableQuery = (function (_super) {
290
282
  else {
291
283
  reobserveOptions.fetchPolicy = 'network-only';
292
284
  }
293
- if (__DEV__ && variables && hasOwnProperty$1.call(variables, "variables")) {
285
+ if (globals.__DEV__ && variables && hasOwnProperty$1.call(variables, "variables")) {
294
286
  var queryDef = utilities.getQueryDefinition(this.query);
295
287
  var vars = queryDef.variableDefinitions;
296
288
  if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
297
- __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 })?"));
289
+ 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 })?"));
298
290
  }
299
291
  }
300
292
  if (variables && !equality.equal(this.options.variables, variables)) {
@@ -378,7 +370,7 @@ var ObservableQuery = (function (_super) {
378
370
  options.onError(err);
379
371
  return;
380
372
  }
381
- __DEV__ && globals.invariant.error('Unhandled GraphQL subscription error', err);
373
+ globals.__DEV__ && globals.invariant.error('Unhandled GraphQL subscription error', err);
382
374
  },
383
375
  });
384
376
  this.subscriptions.add(subscription);
@@ -476,7 +468,7 @@ var ObservableQuery = (function (_super) {
476
468
  pollingInfo.interval === pollInterval) {
477
469
  return;
478
470
  }
479
- __DEV__ ? globals.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : globals.invariant(pollInterval, 12);
471
+ globals.__DEV__ ? globals.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : globals.invariant(pollInterval, 13);
480
472
  var info = pollingInfo || (this.pollingInfo = {});
481
473
  info.interval = pollInterval;
482
474
  var maybeFetch = function () {
@@ -510,7 +502,7 @@ var ObservableQuery = (function (_super) {
510
502
  }
511
503
  return this.last;
512
504
  };
513
- ObservableQuery.prototype.reobserveAsConcast = function (newOptions, newNetworkStatus) {
505
+ ObservableQuery.prototype.reobserve = function (newOptions, newNetworkStatus) {
514
506
  var _this = this;
515
507
  this.isTornDown = false;
516
508
  var useDisposableConcast = newNetworkStatus === exports.NetworkStatus.refetch ||
@@ -553,10 +545,7 @@ var ObservableQuery = (function (_super) {
553
545
  this.observer = observer;
554
546
  }
555
547
  concast.addObserver(observer);
556
- return concast;
557
- };
558
- ObservableQuery.prototype.reobserve = function (newOptions, newNetworkStatus) {
559
- return this.reobserveAsConcast(newOptions, newNetworkStatus).promise;
548
+ return concast.promise;
560
549
  };
561
550
  ObservableQuery.prototype.observe = function () {
562
551
  this.reportResult(this.getCurrentResult(false), this.variables);
@@ -614,17 +603,18 @@ function reobserveCacheFirst(obsQuery) {
614
603
  return obsQuery.reobserve();
615
604
  }
616
605
  function defaultSubscriptionObserverErrorCallback(error) {
617
- __DEV__ && globals.invariant.error('Unhandled error', error.message, error.stack);
606
+ globals.__DEV__ && globals.invariant.error('Unhandled error', error.message, error.stack);
618
607
  }
619
608
  function logMissingFieldErrors(missing) {
620
- if (__DEV__ && missing) {
621
- __DEV__ && globals.invariant.debug("Missing cache result fields: ".concat(JSON.stringify(missing)), missing);
609
+ if (globals.__DEV__ && missing) {
610
+ globals.__DEV__ && globals.invariant.debug("Missing cache result fields: ".concat(JSON.stringify(missing)), missing);
622
611
  }
623
612
  }
624
613
 
625
614
  var LocalState = (function () {
626
615
  function LocalState(_a) {
627
616
  var cache = _a.cache, client = _a.client, resolvers = _a.resolvers, fragmentMatcher = _a.fragmentMatcher;
617
+ this.selectionsToResolveCache = new WeakMap();
628
618
  this.cache = cache;
629
619
  if (client) {
630
620
  this.client = client;
@@ -680,8 +670,12 @@ var LocalState = (function () {
680
670
  }
681
671
  return null;
682
672
  };
683
- LocalState.prototype.serverQuery = function (document) {
684
- return utilities.removeClientSetsFromDocument(document);
673
+ LocalState.prototype.serverQuery = function (document, options) {
674
+ if (options === void 0) { options = Object.create(null); }
675
+ var _a = options.removeClientFields, removeClientFields = _a === void 0 ? true : _a;
676
+ return removeClientFields
677
+ ? utilities.removeClientSetsFromDocument(document)
678
+ : document;
685
679
  };
686
680
  LocalState.prototype.prepareContext = function (context) {
687
681
  var cache = this.cache;
@@ -735,13 +729,13 @@ var LocalState = (function () {
735
729
  if (fragmentMatcher === void 0) { fragmentMatcher = function () { return true; }; }
736
730
  if (onlyRunForcedResolvers === void 0) { onlyRunForcedResolvers = false; }
737
731
  return tslib.__awaiter(this, void 0, void 0, function () {
738
- var mainDefinition, fragments, fragmentMap, definitionOperation, defaultOperationType, _a, cache, client, execContext;
732
+ var mainDefinition, fragments, fragmentMap, selectionsToResolve, definitionOperation, defaultOperationType, _a, cache, client, execContext, isClientFieldDescendant;
739
733
  return tslib.__generator(this, function (_b) {
740
734
  mainDefinition = utilities.getMainDefinition(document);
741
735
  fragments = utilities.getFragmentDefinitions(document);
742
736
  fragmentMap = utilities.createFragmentMap(fragments);
743
- definitionOperation = mainDefinition
744
- .operation;
737
+ selectionsToResolve = this.collectSelectionsToResolve(mainDefinition, fragmentMap);
738
+ definitionOperation = mainDefinition.operation;
745
739
  defaultOperationType = definitionOperation
746
740
  ? definitionOperation.charAt(0).toUpperCase() +
747
741
  definitionOperation.slice(1)
@@ -754,16 +748,18 @@ var LocalState = (function () {
754
748
  fragmentMatcher: fragmentMatcher,
755
749
  defaultOperationType: defaultOperationType,
756
750
  exportedVariables: {},
751
+ selectionsToResolve: selectionsToResolve,
757
752
  onlyRunForcedResolvers: onlyRunForcedResolvers,
758
753
  };
759
- return [2, this.resolveSelectionSet(mainDefinition.selectionSet, rootValue, execContext).then(function (result) { return ({
754
+ isClientFieldDescendant = false;
755
+ return [2, this.resolveSelectionSet(mainDefinition.selectionSet, isClientFieldDescendant, rootValue, execContext).then(function (result) { return ({
760
756
  result: result,
761
757
  exportedVariables: execContext.exportedVariables,
762
758
  }); })];
763
759
  });
764
760
  });
765
761
  };
766
- LocalState.prototype.resolveSelectionSet = function (selectionSet, rootValue, execContext) {
762
+ LocalState.prototype.resolveSelectionSet = function (selectionSet, isClientFieldDescendant, rootValue, execContext) {
767
763
  return tslib.__awaiter(this, void 0, void 0, function () {
768
764
  var fragmentMap, context, variables, resultsToMerge, execute;
769
765
  var _this = this;
@@ -773,11 +769,14 @@ var LocalState = (function () {
773
769
  execute = function (selection) { return tslib.__awaiter(_this, void 0, void 0, function () {
774
770
  var fragment, typeCondition;
775
771
  return tslib.__generator(this, function (_a) {
772
+ if (!isClientFieldDescendant && !execContext.selectionsToResolve.has(selection)) {
773
+ return [2];
774
+ }
776
775
  if (!utilities.shouldInclude(selection, variables)) {
777
776
  return [2];
778
777
  }
779
778
  if (utilities.isField(selection)) {
780
- return [2, this.resolveField(selection, rootValue, execContext).then(function (fieldResult) {
779
+ return [2, this.resolveField(selection, isClientFieldDescendant, rootValue, execContext).then(function (fieldResult) {
781
780
  var _a;
782
781
  if (typeof fieldResult !== 'undefined') {
783
782
  resultsToMerge.push((_a = {},
@@ -791,12 +790,12 @@ var LocalState = (function () {
791
790
  }
792
791
  else {
793
792
  fragment = fragmentMap[selection.name.value];
794
- __DEV__ ? globals.invariant(fragment, "No fragment named ".concat(selection.name.value)) : globals.invariant(fragment, 11);
793
+ globals.__DEV__ ? globals.invariant(fragment, "No fragment named ".concat(selection.name.value)) : globals.invariant(fragment, 11);
795
794
  }
796
795
  if (fragment && fragment.typeCondition) {
797
796
  typeCondition = fragment.typeCondition.name.value;
798
797
  if (execContext.fragmentMatcher(rootValue, typeCondition, context)) {
799
- return [2, this.resolveSelectionSet(fragment.selectionSet, rootValue, execContext).then(function (fragmentResult) {
798
+ return [2, this.resolveSelectionSet(fragment.selectionSet, isClientFieldDescendant, rootValue, execContext).then(function (fragmentResult) {
800
799
  resultsToMerge.push(fragmentResult);
801
800
  })];
802
801
  }
@@ -810,11 +809,14 @@ var LocalState = (function () {
810
809
  });
811
810
  });
812
811
  };
813
- LocalState.prototype.resolveField = function (field, rootValue, execContext) {
812
+ LocalState.prototype.resolveField = function (field, isClientFieldDescendant, rootValue, execContext) {
814
813
  return tslib.__awaiter(this, void 0, void 0, function () {
815
814
  var variables, fieldName, aliasedFieldName, aliasUsed, defaultResult, resultPromise, resolverType, resolverMap, resolve;
816
815
  var _this = this;
817
816
  return tslib.__generator(this, function (_a) {
817
+ if (!rootValue) {
818
+ return [2, null];
819
+ }
818
820
  variables = execContext.variables;
819
821
  fieldName = field.name.value;
820
822
  aliasedFieldName = utilities.resultKeyNameFromField(field);
@@ -838,6 +840,7 @@ var LocalState = (function () {
838
840
  }
839
841
  }
840
842
  return [2, resultPromise.then(function (result) {
843
+ var _a, _b;
841
844
  if (result === void 0) { result = defaultResult; }
842
845
  if (field.directives) {
843
846
  field.directives.forEach(function (directive) {
@@ -856,30 +859,70 @@ var LocalState = (function () {
856
859
  if (result == null) {
857
860
  return result;
858
861
  }
862
+ var isClientField = (_b = (_a = field.directives) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.name.value === 'client'; })) !== null && _b !== void 0 ? _b : false;
859
863
  if (Array.isArray(result)) {
860
- return _this.resolveSubSelectedArray(field, result, execContext);
864
+ return _this.resolveSubSelectedArray(field, isClientFieldDescendant || isClientField, result, execContext);
861
865
  }
862
866
  if (field.selectionSet) {
863
- return _this.resolveSelectionSet(field.selectionSet, result, execContext);
867
+ return _this.resolveSelectionSet(field.selectionSet, isClientFieldDescendant || isClientField, result, execContext);
864
868
  }
865
869
  })];
866
870
  });
867
871
  });
868
872
  };
869
- LocalState.prototype.resolveSubSelectedArray = function (field, result, execContext) {
873
+ LocalState.prototype.resolveSubSelectedArray = function (field, isClientFieldDescendant, result, execContext) {
870
874
  var _this = this;
871
875
  return Promise.all(result.map(function (item) {
872
876
  if (item === null) {
873
877
  return null;
874
878
  }
875
879
  if (Array.isArray(item)) {
876
- return _this.resolveSubSelectedArray(field, item, execContext);
880
+ return _this.resolveSubSelectedArray(field, isClientFieldDescendant, item, execContext);
877
881
  }
878
882
  if (field.selectionSet) {
879
- return _this.resolveSelectionSet(field.selectionSet, item, execContext);
883
+ return _this.resolveSelectionSet(field.selectionSet, isClientFieldDescendant, item, execContext);
880
884
  }
881
885
  }));
882
886
  };
887
+ LocalState.prototype.collectSelectionsToResolve = function (mainDefinition, fragmentMap) {
888
+ var isSingleASTNode = function (node) { return !Array.isArray(node); };
889
+ var selectionsToResolveCache = this.selectionsToResolveCache;
890
+ function collectByDefinition(definitionNode) {
891
+ if (!selectionsToResolveCache.has(definitionNode)) {
892
+ var matches_1 = new Set();
893
+ selectionsToResolveCache.set(definitionNode, matches_1);
894
+ graphql.visit(definitionNode, {
895
+ Directive: function (node, _, __, ___, ancestors) {
896
+ if (node.name.value === 'client') {
897
+ ancestors.forEach(function (node) {
898
+ if (isSingleASTNode(node) && graphql.isSelectionNode(node)) {
899
+ matches_1.add(node);
900
+ }
901
+ });
902
+ }
903
+ },
904
+ FragmentSpread: function (spread, _, __, ___, ancestors) {
905
+ var fragment = fragmentMap[spread.name.value];
906
+ globals.__DEV__ ? globals.invariant(fragment, "No fragment named ".concat(spread.name.value)) : globals.invariant(fragment, 12);
907
+ var fragmentSelections = collectByDefinition(fragment);
908
+ if (fragmentSelections.size > 0) {
909
+ ancestors.forEach(function (node) {
910
+ if (isSingleASTNode(node) && graphql.isSelectionNode(node)) {
911
+ matches_1.add(node);
912
+ }
913
+ });
914
+ matches_1.add(spread);
915
+ fragmentSelections.forEach(function (selection) {
916
+ matches_1.add(selection);
917
+ });
918
+ }
919
+ }
920
+ });
921
+ }
922
+ return selectionsToResolveCache.get(definitionNode);
923
+ }
924
+ return collectByDefinition(mainDefinition);
925
+ };
883
926
  return LocalState;
884
927
  }());
885
928
 
@@ -1082,7 +1125,7 @@ var QueryInfo = (function () {
1082
1125
  : [];
1083
1126
  this.reset();
1084
1127
  if ('incremental' in result && utilities.isNonEmptyArray(result.incremental)) {
1085
- var mergedData = mergeIncrementalData(this.getDiff().result, result);
1128
+ var mergedData = utilities.mergeIncrementalData(this.getDiff().result, result);
1086
1129
  result.data = mergedData;
1087
1130
  }
1088
1131
  else if ('hasNext' in result && result.hasNext) {
@@ -1164,7 +1207,7 @@ function shouldWriteResult(result, errorPolicy) {
1164
1207
  var hasOwnProperty = Object.prototype.hasOwnProperty;
1165
1208
  var QueryManager = (function () {
1166
1209
  function QueryManager(_a) {
1167
- 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;
1210
+ 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, _e = _a.assumeImmutableResults, assumeImmutableResults = _e === void 0 ? !!cache.assumeImmutableResults : _e;
1168
1211
  this.clientAwareness = {};
1169
1212
  this.queries = new Map();
1170
1213
  this.fetchCancelFns = new Map();
@@ -1180,7 +1223,7 @@ var QueryManager = (function () {
1180
1223
  this.clientAwareness = clientAwareness;
1181
1224
  this.localState = localState || new LocalState({ cache: cache });
1182
1225
  this.ssrMode = ssrMode;
1183
- this.assumeImmutableResults = !!assumeImmutableResults;
1226
+ this.assumeImmutableResults = assumeImmutableResults;
1184
1227
  if ((this.onBroadcast = onBroadcast)) {
1185
1228
  this.mutationStore = Object.create(null);
1186
1229
  }
@@ -1190,7 +1233,7 @@ var QueryManager = (function () {
1190
1233
  this.queries.forEach(function (_info, queryId) {
1191
1234
  _this.stopQueryNoBroadcast(queryId);
1192
1235
  });
1193
- this.cancelPendingFetches(__DEV__ ? new globals.InvariantError('QueryManager stopped while query was in flight') : new globals.InvariantError(13));
1236
+ this.cancelPendingFetches(globals.__DEV__ ? new globals.InvariantError('QueryManager stopped while query was in flight') : new globals.InvariantError(14));
1194
1237
  };
1195
1238
  QueryManager.prototype.cancelPendingFetches = function (error) {
1196
1239
  this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
@@ -1204,10 +1247,10 @@ var QueryManager = (function () {
1204
1247
  return tslib.__generator(this, function (_j) {
1205
1248
  switch (_j.label) {
1206
1249
  case 0:
1207
- __DEV__ ? globals.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : globals.invariant(mutation, 14);
1208
- __DEV__ ? globals.invariant(fetchPolicy === 'network-only' ||
1250
+ globals.__DEV__ ? globals.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : globals.invariant(mutation, 15);
1251
+ globals.__DEV__ ? globals.invariant(fetchPolicy === 'network-only' ||
1209
1252
  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' ||
1210
- fetchPolicy === 'no-cache', 15);
1253
+ fetchPolicy === 'no-cache', 16);
1211
1254
  mutationId = this.generateMutationId();
1212
1255
  _h = this.transform(mutation), document = _h.document, hasClientExports = _h.hasClientExports;
1213
1256
  mutation = this.cache.transformForLink(document);
@@ -1308,7 +1351,7 @@ var QueryManager = (function () {
1308
1351
  var cacheWrites = [];
1309
1352
  var skipCache = mutation.fetchPolicy === "no-cache";
1310
1353
  if (!skipCache && shouldWriteResult(result, mutation.errorPolicy)) {
1311
- if (!isExecutionPatchIncrementalResult(result)) {
1354
+ if (!utilities.isExecutionPatchIncrementalResult(result)) {
1312
1355
  cacheWrites.push({
1313
1356
  result: result.data,
1314
1357
  dataId: 'ROOT_MUTATION',
@@ -1316,7 +1359,7 @@ var QueryManager = (function () {
1316
1359
  variables: mutation.variables,
1317
1360
  });
1318
1361
  }
1319
- if (isExecutionPatchIncrementalResult(result) && utilities.isNonEmptyArray(result.incremental)) {
1362
+ if (utilities.isExecutionPatchIncrementalResult(result) && utilities.isNonEmptyArray(result.incremental)) {
1320
1363
  var diff = cache.diff({
1321
1364
  id: "ROOT_MUTATION",
1322
1365
  query: this.transform(mutation.document).asQuery,
@@ -1324,7 +1367,10 @@ var QueryManager = (function () {
1324
1367
  optimistic: false,
1325
1368
  returnPartialData: true,
1326
1369
  });
1327
- var mergedData = mergeIncrementalData(diff.result, result);
1370
+ var mergedData = void 0;
1371
+ if (diff.result) {
1372
+ mergedData = mergeIncrementalData(diff.result, result);
1373
+ }
1328
1374
  if (typeof mergedData !== 'undefined') {
1329
1375
  result.data = mergedData;
1330
1376
  cacheWrites.push({
@@ -1381,8 +1427,8 @@ var QueryManager = (function () {
1381
1427
  cacheWrites.forEach(function (write) { return cache.write(write); });
1382
1428
  }
1383
1429
  var update = mutation.update;
1384
- var isFinalResult = !isExecutionPatchResult(result) ||
1385
- (isExecutionPatchIncrementalResult(result) && !result.hasNext);
1430
+ var isFinalResult = !utilities.isExecutionPatchResult(result) ||
1431
+ (utilities.isExecutionPatchIncrementalResult(result) && !result.hasNext);
1386
1432
  if (update) {
1387
1433
  if (!skipCache) {
1388
1434
  var diff = cache.diff({
@@ -1440,7 +1486,7 @@ var QueryManager = (function () {
1440
1486
  _this.markMutationResult(tslib.__assign(tslib.__assign({}, mutation), { result: { data: data } }), cache);
1441
1487
  }
1442
1488
  catch (error) {
1443
- __DEV__ && globals.invariant.error(error);
1489
+ globals.__DEV__ && globals.invariant.error(error);
1444
1490
  }
1445
1491
  }, mutation.mutationId);
1446
1492
  };
@@ -1468,11 +1514,13 @@ var QueryManager = (function () {
1468
1514
  };
1469
1515
  QueryManager.prototype.transform = function (document) {
1470
1516
  var transformCache = this.transformCache;
1517
+ var _a = (this.defaultOptions.transformQuery || Object.create(null)).removeClientFields, removeClientFields = _a === void 0 ? true : _a;
1471
1518
  if (!transformCache.has(document)) {
1472
1519
  var transformed = this.cache.transformDocument(document);
1473
1520
  var noConnection = utilities.removeConnectionDirectiveFromDocument(transformed);
1474
1521
  var clientQuery = this.localState.clientQuery(transformed);
1475
- var serverQuery = noConnection && this.localState.serverQuery(noConnection);
1522
+ var serverQuery = noConnection &&
1523
+ this.localState.serverQuery(noConnection, { removeClientFields: removeClientFields });
1476
1524
  var cacheEntry_1 = {
1477
1525
  document: transformed,
1478
1526
  hasClientExports: utilities.hasClientExports(transformed),
@@ -1525,11 +1573,11 @@ var QueryManager = (function () {
1525
1573
  QueryManager.prototype.query = function (options, queryId) {
1526
1574
  var _this = this;
1527
1575
  if (queryId === void 0) { queryId = this.generateQueryId(); }
1528
- __DEV__ ? globals.invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
1529
- 'in the query option.') : globals.invariant(options.query, 16);
1530
- __DEV__ ? globals.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : globals.invariant(options.query.kind === 'Document', 17);
1531
- __DEV__ ? globals.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : globals.invariant(!options.returnPartialData, 18);
1532
- __DEV__ ? globals.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : globals.invariant(!options.pollInterval, 19);
1576
+ globals.__DEV__ ? globals.invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
1577
+ 'in the query option.') : globals.invariant(options.query, 17);
1578
+ 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);
1579
+ globals.__DEV__ ? globals.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : globals.invariant(!options.returnPartialData, 19);
1580
+ globals.__DEV__ ? globals.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : globals.invariant(!options.pollInterval, 20);
1533
1581
  return this.fetchQuery(queryId, options).finally(function () { return _this.stopQuery(queryId); });
1534
1582
  };
1535
1583
  QueryManager.prototype.generateQueryId = function () {
@@ -1554,7 +1602,7 @@ var QueryManager = (function () {
1554
1602
  if (options === void 0) { options = {
1555
1603
  discardWatches: true,
1556
1604
  }; }
1557
- this.cancelPendingFetches(__DEV__ ? new globals.InvariantError('Store reset while query was in flight (not completed in link chain)') : new globals.InvariantError(20));
1605
+ this.cancelPendingFetches(globals.__DEV__ ? new globals.InvariantError('Store reset while query was in flight (not completed in link chain)') : new globals.InvariantError(21));
1558
1606
  this.queries.forEach(function (queryInfo) {
1559
1607
  if (queryInfo.observableQuery) {
1560
1608
  queryInfo.networkStatus = exports.NetworkStatus.loading;
@@ -1627,10 +1675,10 @@ var QueryManager = (function () {
1627
1675
  queries.set(queryId, oq);
1628
1676
  });
1629
1677
  }
1630
- if (__DEV__ && queryNamesAndDocs.size) {
1678
+ if (globals.__DEV__ && queryNamesAndDocs.size) {
1631
1679
  queryNamesAndDocs.forEach(function (included, nameOrDoc) {
1632
1680
  if (!included) {
1633
- __DEV__ && globals.invariant.warn("Unknown query ".concat(typeof nameOrDoc === "string" ? "named " : "").concat(JSON.stringify(nameOrDoc, null, 2), " requested in refetchQueries options.include array"));
1681
+ globals.__DEV__ && globals.invariant.warn("Unknown query ".concat(typeof nameOrDoc === "string" ? "named " : "").concat(JSON.stringify(nameOrDoc, null, 2), " requested in refetchQueries options.include array"));
1634
1682
  }
1635
1683
  });
1636
1684
  }
@@ -1927,7 +1975,7 @@ var QueryManager = (function () {
1927
1975
  var resultsFromCache = function (diff, networkStatus) {
1928
1976
  if (networkStatus === void 0) { networkStatus = queryInfo.networkStatus || exports.NetworkStatus.loading; }
1929
1977
  var data = diff.result;
1930
- if (__DEV__ &&
1978
+ if (globals.__DEV__ &&
1931
1979
  !returnPartialData &&
1932
1980
  !equality.equal(data, {})) {
1933
1981
  logMissingFieldErrors(diff.missing);
@@ -1942,6 +1990,11 @@ var QueryManager = (function () {
1942
1990
  onlyRunForcedResolvers: true,
1943
1991
  }).then(function (resolved) { return fromData(resolved.data || void 0); });
1944
1992
  }
1993
+ if (errorPolicy === 'none' &&
1994
+ networkStatus === exports.NetworkStatus.refetch &&
1995
+ Array.isArray(diff.missing)) {
1996
+ return fromData(void 0);
1997
+ }
1945
1998
  return fromData(data);
1946
1999
  };
1947
2000
  var cacheWriteBehavior = fetchPolicy === "no-cache" ? 0 :
@@ -2033,20 +2086,20 @@ var ApolloClient = (function () {
2033
2086
  var _this = this;
2034
2087
  this.resetStoreCallbacks = [];
2035
2088
  this.clearStoreCallbacks = [];
2089
+ if (!options.cache) {
2090
+ throw globals.__DEV__ ? new globals.InvariantError("To initialize Apollo Client, you must specify a 'cache' property " +
2091
+ "in the options object. \n" +
2092
+ "For more information, please visit: https://go.apollo.dev/c/docs") : new globals.InvariantError(9);
2093
+ }
2036
2094
  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' &&
2037
2095
  !window.__APOLLO_CLIENT__ &&
2038
- __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;
2096
+ 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;
2039
2097
  var link = options.link;
2040
2098
  if (!link) {
2041
2099
  link = uri
2042
2100
  ? new http.HttpLink({ uri: uri, credentials: credentials, headers: headers })
2043
2101
  : core.ApolloLink.empty();
2044
2102
  }
2045
- if (!cache) {
2046
- throw __DEV__ ? new globals.InvariantError("To initialize Apollo Client, you must specify a 'cache' property " +
2047
- "in the options object. \n" +
2048
- "For more information, please visit: https://go.apollo.dev/c/docs") : new globals.InvariantError(9);
2049
- }
2050
2103
  this.link = link;
2051
2104
  this.cache = cache;
2052
2105
  this.disableNetworkFetches = ssrMode || ssrForceFetchDelay > 0;
@@ -2064,7 +2117,7 @@ var ApolloClient = (function () {
2064
2117
  if (connectToDevTools && typeof window === 'object') {
2065
2118
  window.__APOLLO_CLIENT__ = this;
2066
2119
  }
2067
- if (!hasSuggestedDevtools && connectToDevTools && __DEV__) {
2120
+ if (!hasSuggestedDevtools && connectToDevTools && globals.__DEV__) {
2068
2121
  hasSuggestedDevtools = true;
2069
2122
  if (typeof window !== 'undefined' &&
2070
2123
  window.document &&
@@ -2083,7 +2136,7 @@ var ApolloClient = (function () {
2083
2136
  }
2084
2137
  }
2085
2138
  if (url) {
2086
- __DEV__ && globals.invariant.log("Download the Apollo DevTools for a better development " +
2139
+ globals.__DEV__ && globals.invariant.log("Download the Apollo DevTools for a better development " +
2087
2140
  "experience: " + url);
2088
2141
  }
2089
2142
  }
@@ -2139,7 +2192,7 @@ var ApolloClient = (function () {
2139
2192
  if (this.defaultOptions.query) {
2140
2193
  options = utilities.mergeOptions(this.defaultOptions.query, options);
2141
2194
  }
2142
- __DEV__ ? globals.invariant(options.fetchPolicy !== 'cache-and-network', 'The cache-and-network fetchPolicy does not work with client.query, because ' +
2195
+ globals.__DEV__ ? globals.invariant(options.fetchPolicy !== 'cache-and-network', 'The cache-and-network fetchPolicy does not work with client.query, because ' +
2143
2196
  'client.query can only return a single result. Please use client.watchQuery ' +
2144
2197
  'to receive multiple results from the cache and the network, or consider ' +
2145
2198
  'using a different fetchPolicy, such as cache-first or network-only.') : globals.invariant(options.fetchPolicy !== 'cache-and-network', 10);
@@ -2166,12 +2219,18 @@ var ApolloClient = (function () {
2166
2219
  return this.cache.readFragment(options, optimistic);
2167
2220
  };
2168
2221
  ApolloClient.prototype.writeQuery = function (options) {
2169
- this.cache.writeQuery(options);
2170
- this.queryManager.broadcastQueries();
2222
+ var ref = this.cache.writeQuery(options);
2223
+ if (options.broadcast !== false) {
2224
+ this.queryManager.broadcastQueries();
2225
+ }
2226
+ return ref;
2171
2227
  };
2172
2228
  ApolloClient.prototype.writeFragment = function (options) {
2173
- this.cache.writeFragment(options);
2174
- this.queryManager.broadcastQueries();
2229
+ var ref = this.cache.writeFragment(options);
2230
+ if (options.broadcast !== false) {
2231
+ this.queryManager.broadcastQueries();
2232
+ }
2233
+ return ref;
2175
2234
  };
2176
2235
  ApolloClient.prototype.__actionHookForDevTools = function (cb) {
2177
2236
  this.devToolsHookCb = cb;
@@ -2225,7 +2284,7 @@ var ApolloClient = (function () {
2225
2284
  result.queries = queries;
2226
2285
  result.results = results;
2227
2286
  result.catch(function (error) {
2228
- __DEV__ && globals.invariant.debug("In client.refetchQueries, Promise.all promise rejected with error ".concat(error));
2287
+ globals.__DEV__ && globals.invariant.debug("In client.refetchQueries, Promise.all promise rejected with error ".concat(error));
2229
2288
  });
2230
2289
  return result;
2231
2290
  };
@@ -2257,18 +2316,18 @@ var ApolloClient = (function () {
2257
2316
  return ApolloClient;
2258
2317
  }());
2259
2318
 
2260
- tsInvariant.setVerbosity(globals.DEV ? "log" : "silent");
2319
+ tsInvariant.setVerbosity(globals.__DEV__ ? "log" : "silent");
2261
2320
 
2321
+ exports.Observable = utilities.Observable;
2322
+ exports.isReference = utilities.isReference;
2323
+ exports.makeReference = utilities.makeReference;
2324
+ exports.mergeOptions = utilities.mergeOptions;
2262
2325
  exports.ApolloCache = cache.ApolloCache;
2263
2326
  exports.Cache = cache.Cache;
2264
2327
  exports.InMemoryCache = cache.InMemoryCache;
2265
2328
  exports.MissingFieldError = cache.MissingFieldError;
2266
2329
  exports.defaultDataIdFromObject = cache.defaultDataIdFromObject;
2267
2330
  exports.makeVar = cache.makeVar;
2268
- exports.Observable = utilities.Observable;
2269
- exports.isReference = utilities.isReference;
2270
- exports.makeReference = utilities.makeReference;
2271
- exports.mergeOptions = utilities.mergeOptions;
2272
2331
  exports.ApolloError = errors.ApolloError;
2273
2332
  exports.isApolloError = errors.isApolloError;
2274
2333
  exports.fromError = utils.fromError;
package/core/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DEV } from "../utilities/globals/index.js";
1
+ import { __DEV__ } from "../utilities/globals/index.js";
2
2
  export { ApolloClient, mergeOptions, } from "./ApolloClient.js";
3
3
  export { ObservableQuery, } from "./ObservableQuery.js";
4
4
  export { NetworkStatus } from "./networkStatus.js";
@@ -12,6 +12,6 @@ export { fromError, toPromise, fromPromise, throwServerError, } from "../link/ut
12
12
  export { Observable, isReference, makeReference, } from "../utilities/index.js";
13
13
  import { setVerbosity } from "ts-invariant";
14
14
  export { setVerbosity as setLogVerbosity };
15
- setVerbosity(DEV ? "log" : "silent");
15
+ setVerbosity(__DEV__ ? "log" : "silent");
16
16
  export { gql, resetCaches, disableFragmentWarnings, enableExperimentalFragmentVariables, disableExperimentalFragmentVariables, } from 'graphql-tag';
17
17
  //# sourceMappingURL=index.js.map
package/core/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAE3C,OAAO,EACL,YAAY,EAGZ,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,GAGhB,MAAM,mBAAmB,CAAC;AAY3B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,cAAc,SAAS,CAAC;AAKxB,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAIvD,OAAO,EAGL,KAAK,EACL,WAAW,EAGX,aAAa,EAEb,iBAAiB,EACjB,uBAAuB,EAEvB,OAAO,GAQR,MAAM,UAAU,CAAC;AAElB,cAAc,yBAAyB,CAAC;AAIxC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EAEX,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAIvB,OAAO,EACL,UAAU,EAIV,WAAW,EACX,aAAa,GAEd,MAAM,cAAc,CAAC;AAQtB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,IAAI,eAAe,EAAE,CAAA;AAC1C,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAcrC,OAAO,EACL,GAAG,EACH,WAAW,EACX,uBAAuB,EACvB,mCAAmC,EACnC,oCAAoC,GACrC,MAAM,aAAa,CAAC","sourcesContent":["/* Core */\n\nimport { DEV } from '../utilities/globals';\n\nexport {\n ApolloClient,\n ApolloClientOptions,\n DefaultOptions,\n mergeOptions,\n} from './ApolloClient';\nexport {\n ObservableQuery,\n FetchMoreOptions,\n UpdateQueryOptions,\n} from './ObservableQuery';\nexport {\n QueryOptions,\n WatchQueryOptions,\n MutationOptions,\n SubscriptionOptions,\n FetchPolicy,\n WatchQueryFetchPolicy,\n ErrorPolicy,\n FetchMoreQueryOptions,\n SubscribeToMoreOptions,\n} from './watchQueryOptions';\nexport { NetworkStatus } from './networkStatus';\nexport * from './types';\nexport {\n Resolver,\n FragmentMatcher,\n} from './LocalState';\nexport { isApolloError, ApolloError } from '../errors';\n\n/* Cache */\n\nexport {\n // All the exports (types and values) from ../cache, minus cacheSlot,\n // which we want to keep semi-private.\n Cache,\n ApolloCache,\n Transaction,\n DataProxy,\n InMemoryCache,\n InMemoryCacheConfig,\n MissingFieldError,\n defaultDataIdFromObject,\n ReactiveVar,\n makeVar,\n TypePolicies,\n TypePolicy,\n FieldPolicy,\n FieldReadFunction,\n FieldMergeFunction,\n FieldFunctionOptions,\n PossibleTypesMap,\n} from '../cache';\n\nexport * from '../cache/inmemory/types';\n\n/* Link */\n\nexport * from '../link/core';\nexport * from '../link/http';\nexport {\n fromError,\n toPromise,\n fromPromise,\n ServerError,\n throwServerError,\n} from '../link/utils';\n\n/* Utilities */\n\nexport {\n Observable,\n Observer,\n ObservableSubscription,\n Reference,\n isReference,\n makeReference,\n StoreObject,\n} from '../utilities';\n\n/* Supporting */\n\n// The verbosity of invariant.{log,warn,error} can be controlled globally\n// (for anyone using the same ts-invariant package) by passing \"log\",\n// \"warn\", \"error\", or \"silent\" to setVerbosity (\"log\" is the default).\n// Note that all invariant.* logging is hidden in production.\nimport { setVerbosity } from \"ts-invariant\";\nexport { setVerbosity as setLogVerbosity }\nsetVerbosity(DEV ? \"log\" : \"silent\");\n\n// Note that importing `gql` by itself, then destructuring\n// additional properties separately before exporting, is intentional.\n// Due to the way the `graphql-tag` library is setup, certain bundlers\n// can't find the properties added to the exported `gql` function without\n// additional guidance (e.g. Rollup - see\n// https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module).\n// Instead of having people that are using bundlers with `@apollo/client` add\n// extra bundler config to help `graphql-tag` exports be found (which would be\n// awkward since they aren't importing `graphql-tag` themselves), this\n// workaround of pulling the extra properties off the `gql` function,\n// then re-exporting them separately, helps keeps bundlers happy without any\n// additional config changes.\nexport {\n gql,\n resetCaches,\n disableFragmentWarnings,\n enableExperimentalFragmentVariables,\n disableExperimentalFragmentVariables,\n} from 'graphql-tag';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EACL,YAAY,EAGZ,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,GAGhB,MAAM,mBAAmB,CAAC;AAY3B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,cAAc,SAAS,CAAC;AAKxB,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAIvD,OAAO,EAGL,KAAK,EACL,WAAW,EAGX,aAAa,EAEb,iBAAiB,EACjB,uBAAuB,EAEvB,OAAO,GAQR,MAAM,UAAU,CAAC;AAElB,cAAc,yBAAyB,CAAC;AAIxC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EAEX,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAIvB,OAAO,EACL,UAAU,EAIV,WAAW,EACX,aAAa,GAEd,MAAM,cAAc,CAAC;AAQtB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,IAAI,eAAe,EAAE,CAAA;AAC1C,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAczC,OAAO,EACL,GAAG,EACH,WAAW,EACX,uBAAuB,EACvB,mCAAmC,EACnC,oCAAoC,GACrC,MAAM,aAAa,CAAC","sourcesContent":["/* Core */\n\nimport { __DEV__ } from '../utilities/globals';\n\nexport {\n ApolloClient,\n ApolloClientOptions,\n DefaultOptions,\n mergeOptions,\n} from './ApolloClient';\nexport {\n ObservableQuery,\n FetchMoreOptions,\n UpdateQueryOptions,\n} from './ObservableQuery';\nexport {\n QueryOptions,\n WatchQueryOptions,\n MutationOptions,\n SubscriptionOptions,\n FetchPolicy,\n WatchQueryFetchPolicy,\n ErrorPolicy,\n FetchMoreQueryOptions,\n SubscribeToMoreOptions,\n} from './watchQueryOptions';\nexport { NetworkStatus } from './networkStatus';\nexport * from './types';\nexport {\n Resolver,\n FragmentMatcher,\n} from './LocalState';\nexport { isApolloError, ApolloError } from '../errors';\n\n/* Cache */\n\nexport {\n // All the exports (types and values) from ../cache, minus cacheSlot,\n // which we want to keep semi-private.\n Cache,\n ApolloCache,\n Transaction,\n DataProxy,\n InMemoryCache,\n InMemoryCacheConfig,\n MissingFieldError,\n defaultDataIdFromObject,\n ReactiveVar,\n makeVar,\n TypePolicies,\n TypePolicy,\n FieldPolicy,\n FieldReadFunction,\n FieldMergeFunction,\n FieldFunctionOptions,\n PossibleTypesMap,\n} from '../cache';\n\nexport * from '../cache/inmemory/types';\n\n/* Link */\n\nexport * from '../link/core';\nexport * from '../link/http';\nexport {\n fromError,\n toPromise,\n fromPromise,\n ServerError,\n throwServerError,\n} from '../link/utils';\n\n/* Utilities */\n\nexport {\n Observable,\n Observer,\n ObservableSubscription,\n Reference,\n isReference,\n makeReference,\n StoreObject,\n} from '../utilities';\n\n/* Supporting */\n\n// The verbosity of invariant.{log,warn,error} can be controlled globally\n// (for anyone using the same ts-invariant package) by passing \"log\",\n// \"warn\", \"error\", or \"silent\" to setVerbosity (\"log\" is the default).\n// Note that all invariant.* logging is hidden in production.\nimport { setVerbosity } from \"ts-invariant\";\nexport { setVerbosity as setLogVerbosity }\nsetVerbosity(__DEV__ ? \"log\" : \"silent\");\n\n// Note that importing `gql` by itself, then destructuring\n// additional properties separately before exporting, is intentional.\n// Due to the way the `graphql-tag` library is setup, certain bundlers\n// can't find the properties added to the exported `gql` function without\n// additional guidance (e.g. Rollup - see\n// https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module).\n// Instead of having people that are using bundlers with `@apollo/client` add\n// extra bundler config to help `graphql-tag` exports be found (which would be\n// awkward since they aren't importing `graphql-tag` themselves), this\n// workaround of pulling the extra properties off the `gql` function,\n// then re-exporting them separately, helps keeps bundlers happy without any\n// additional config changes.\nexport {\n gql,\n resetCaches,\n disableFragmentWarnings,\n enableExperimentalFragmentVariables,\n disableExperimentalFragmentVariables,\n} from 'graphql-tag';\n"]}
@@ -8,4 +8,5 @@ export declare enum NetworkStatus {
8
8
  error = 8
9
9
  }
10
10
  export declare function isNetworkRequestInFlight(networkStatus?: NetworkStatus): boolean;
11
+ export declare function isNetworkRequestSettled(networkStatus?: NetworkStatus): boolean;
11
12
  //# sourceMappingURL=networkStatus.d.ts.map