@apollo/client 3.9.0-alpha.1 → 3.9.0-alpha.3

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 (180) hide show
  1. package/apollo-client.cjs +221 -180
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/cache/cache.cjs +52 -40
  5. package/cache/cache.cjs.map +1 -1
  6. package/cache/cache.cjs.native.js +52 -40
  7. package/cache/core/types/common.d.ts +2 -2
  8. package/cache/core/types/common.d.ts.map +1 -1
  9. package/cache/core/types/common.js.map +1 -1
  10. package/cache/index.d.ts +1 -2
  11. package/cache/index.d.ts.map +1 -1
  12. package/cache/index.js +1 -2
  13. package/cache/index.js.map +1 -1
  14. package/cache/inmemory/entityStore.d.ts.map +1 -1
  15. package/cache/inmemory/entityStore.js +35 -0
  16. package/cache/inmemory/entityStore.js.map +1 -1
  17. package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
  18. package/cache/inmemory/inMemoryCache.js +1 -2
  19. package/cache/inmemory/inMemoryCache.js.map +1 -1
  20. package/cache/inmemory/key-extractor.js +1 -1
  21. package/cache/inmemory/object-canon.d.ts +0 -5
  22. package/cache/inmemory/object-canon.d.ts.map +1 -1
  23. package/cache/inmemory/object-canon.js +0 -22
  24. package/cache/inmemory/object-canon.js.map +1 -1
  25. package/cache/inmemory/policies.d.ts.map +1 -1
  26. package/cache/inmemory/policies.js +4 -6
  27. package/cache/inmemory/policies.js.map +1 -1
  28. package/cache/inmemory/readFromStore.d.ts.map +1 -1
  29. package/cache/inmemory/readFromStore.js +4 -4
  30. package/cache/inmemory/readFromStore.js.map +1 -1
  31. package/cache/inmemory/writeToStore.d.ts.map +1 -1
  32. package/cache/inmemory/writeToStore.js +5 -6
  33. package/cache/inmemory/writeToStore.js.map +1 -1
  34. package/core/ApolloClient.d.ts +2 -0
  35. package/core/ApolloClient.d.ts.map +1 -1
  36. package/core/ApolloClient.js +12 -4
  37. package/core/ApolloClient.js.map +1 -1
  38. package/core/LocalState.js +2 -2
  39. package/core/ObservableQuery.d.ts.map +1 -1
  40. package/core/ObservableQuery.js +10 -11
  41. package/core/ObservableQuery.js.map +1 -1
  42. package/core/QueryInfo.d.ts +0 -2
  43. package/core/QueryInfo.d.ts.map +1 -1
  44. package/core/QueryInfo.js +0 -2
  45. package/core/QueryInfo.js.map +1 -1
  46. package/core/QueryManager.d.ts +4 -2
  47. package/core/QueryManager.d.ts.map +1 -1
  48. package/core/QueryManager.js +15 -14
  49. package/core/QueryManager.js.map +1 -1
  50. package/core/core.cjs +39 -33
  51. package/core/core.cjs.map +1 -1
  52. package/core/core.cjs.native.js +39 -33
  53. package/dev/dev.cjs +125 -101
  54. package/dev/dev.cjs.map +1 -1
  55. package/dev/dev.cjs.native.js +125 -101
  56. package/dev/loadErrorMessageHandler.js +2 -2
  57. package/dev/loadErrorMessageHandler.js.map +1 -1
  58. package/invariantErrorCodes.js +96 -81
  59. package/link/core/ApolloLink.js +2 -2
  60. package/link/core/core.cjs +2 -2
  61. package/link/core/core.cjs.map +1 -1
  62. package/link/core/core.cjs.native.js +2 -2
  63. package/link/http/checkFetcher.js +1 -1
  64. package/link/http/createHttpLink.js +1 -1
  65. package/link/http/http.cjs +3 -3
  66. package/link/http/http.cjs.map +1 -1
  67. package/link/http/http.cjs.native.js +3 -3
  68. package/link/http/serializeFetchParameter.js +1 -1
  69. package/link/persisted-queries/index.js +2 -2
  70. package/link/persisted-queries/persisted-queries.cjs +2 -2
  71. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  72. package/link/persisted-queries/persisted-queries.cjs.native.js +2 -2
  73. package/link/utils/toPromise.js +1 -1
  74. package/link/utils/utils.cjs +2 -2
  75. package/link/utils/utils.cjs.map +1 -1
  76. package/link/utils/utils.cjs.native.js +2 -2
  77. package/link/utils/validateOperation.js +1 -1
  78. package/package.json +27 -26
  79. package/react/cache/QueryReference.d.ts.map +1 -1
  80. package/react/cache/QueryReference.js +7 -2
  81. package/react/cache/QueryReference.js.map +1 -1
  82. package/react/context/ApolloConsumer.js +1 -1
  83. package/react/context/ApolloContext.js +1 -1
  84. package/react/context/ApolloProvider.js +1 -1
  85. package/react/context/context.cjs +3 -3
  86. package/react/context/context.cjs.map +1 -1
  87. package/react/context/context.cjs.native.js +3 -3
  88. package/react/hoc/hoc-utils.js +1 -1
  89. package/react/hoc/hoc.cjs +2 -2
  90. package/react/hoc/hoc.cjs.map +1 -1
  91. package/react/hoc/hoc.cjs.native.js +2 -2
  92. package/react/hoc/withApollo.js +1 -1
  93. package/react/hooks/hooks.cjs +15 -10
  94. package/react/hooks/hooks.cjs.map +1 -1
  95. package/react/hooks/hooks.cjs.native.js +15 -10
  96. package/react/hooks/index.d.ts +1 -0
  97. package/react/hooks/index.d.ts.map +1 -1
  98. package/react/hooks/index.js.map +1 -1
  99. package/react/hooks/useApolloClient.js +1 -1
  100. package/react/hooks/useQuery.js +1 -1
  101. package/react/hooks/useReadQuery.d.ts +7 -4
  102. package/react/hooks/useReadQuery.d.ts.map +1 -1
  103. package/react/hooks/useReadQuery.js +1 -1
  104. package/react/hooks/useReadQuery.js.map +1 -1
  105. package/react/hooks/useSubscription.js +2 -2
  106. package/react/hooks/useSuspenseQuery.js +2 -2
  107. package/react/hooks/useSyncExternalStore.js +1 -1
  108. package/react/parser/index.js +5 -5
  109. package/react/parser/parser.cjs +5 -5
  110. package/react/parser/parser.cjs.map +1 -1
  111. package/react/parser/parser.cjs.native.js +5 -5
  112. package/testing/core/core.cjs +2 -2
  113. package/testing/core/core.cjs.map +1 -1
  114. package/testing/core/core.cjs.native.js +2 -2
  115. package/testing/core/mocking/mockLink.js +2 -2
  116. package/testing/internal/ObservableStream.d.ts +26 -0
  117. package/testing/internal/ObservableStream.d.ts.map +1 -0
  118. package/testing/internal/ObservableStream.js +101 -0
  119. package/testing/internal/ObservableStream.js.map +1 -0
  120. package/testing/internal/index.d.ts +1 -0
  121. package/testing/internal/index.d.ts.map +1 -1
  122. package/testing/internal/index.js +1 -0
  123. package/testing/internal/index.js.map +1 -1
  124. package/testing/react/MockedProvider.d.ts +1 -0
  125. package/testing/react/MockedProvider.d.ts.map +1 -1
  126. package/testing/react/MockedProvider.js +2 -1
  127. package/testing/react/MockedProvider.js.map +1 -1
  128. package/testing/testing.cjs +2 -1
  129. package/testing/testing.cjs.map +1 -1
  130. package/testing/testing.cjs.native.js +2 -1
  131. package/utilities/common/canonicalStringify.d.ts +4 -0
  132. package/utilities/common/canonicalStringify.d.ts.map +1 -0
  133. package/utilities/common/canonicalStringify.js +37 -0
  134. package/utilities/common/canonicalStringify.js.map +1 -0
  135. package/utilities/globals/globals.cjs +29 -19
  136. package/utilities/globals/globals.cjs.map +1 -1
  137. package/utilities/globals/globals.cjs.native.js +29 -19
  138. package/utilities/globals/invariantWrappers.d.ts.map +1 -1
  139. package/utilities/globals/invariantWrappers.js +28 -18
  140. package/utilities/globals/invariantWrappers.js.map +1 -1
  141. package/utilities/graphql/DocumentTransform.js +1 -1
  142. package/utilities/graphql/directives.js +4 -4
  143. package/utilities/graphql/fragments.js +3 -3
  144. package/utilities/graphql/getFromAST.js +8 -8
  145. package/utilities/graphql/storeUtils.d.ts +7 -2
  146. package/utilities/graphql/storeUtils.d.ts.map +1 -1
  147. package/utilities/graphql/storeUtils.js +8 -20
  148. package/utilities/graphql/storeUtils.js.map +1 -1
  149. package/utilities/graphql/transform.js +2 -2
  150. package/utilities/index.d.ts +2 -1
  151. package/utilities/index.d.ts.map +1 -1
  152. package/utilities/index.js +1 -0
  153. package/utilities/index.js.map +1 -1
  154. package/utilities/observables/asyncMap.d.ts.map +1 -1
  155. package/utilities/observables/asyncMap.js +17 -34
  156. package/utilities/observables/asyncMap.js.map +1 -1
  157. package/utilities/subscriptions/relay/index.d.ts +6 -0
  158. package/utilities/subscriptions/relay/index.d.ts.map +1 -0
  159. package/utilities/subscriptions/relay/index.js +43 -0
  160. package/utilities/subscriptions/relay/index.js.map +1 -0
  161. package/utilities/subscriptions/relay/package.json +8 -0
  162. package/utilities/subscriptions/relay/relay.cjs +368 -0
  163. package/utilities/subscriptions/relay/relay.cjs.map +1 -0
  164. package/utilities/subscriptions/relay/relay.cjs.native.js +368 -0
  165. package/utilities/subscriptions/shared.d.ts +9 -0
  166. package/utilities/subscriptions/shared.d.ts.map +1 -0
  167. package/utilities/subscriptions/shared.js +7 -0
  168. package/utilities/subscriptions/shared.js.map +1 -0
  169. package/utilities/subscriptions/urql/index.d.ts +7 -0
  170. package/utilities/subscriptions/urql/index.d.ts.map +1 -0
  171. package/utilities/subscriptions/urql/index.js +40 -0
  172. package/utilities/subscriptions/urql/index.js.map +1 -0
  173. package/utilities/subscriptions/urql/package.json +8 -0
  174. package/utilities/subscriptions/urql/urql.cjs +364 -0
  175. package/utilities/subscriptions/urql/urql.cjs.map +1 -0
  176. package/utilities/subscriptions/urql/urql.cjs.native.js +364 -0
  177. package/utilities/utilities.cjs +80 -72
  178. package/utilities/utilities.cjs.map +1 -1
  179. package/utilities/utilities.cjs.native.js +80 -72
  180. package/version.js +1 -1
package/core/core.cjs CHANGED
@@ -19,7 +19,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
19
19
 
20
20
  var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
21
21
 
22
- var version = "3.9.0-alpha.1";
22
+ var version = "3.9.0-alpha.3";
23
23
 
24
24
  function isNonNullObject(obj) {
25
25
  return obj !== null && typeof obj === "object";
@@ -369,7 +369,7 @@ var ObservableQuery = (function (_super) {
369
369
  var vars = queryDef.variableDefinitions;
370
370
  if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
371
371
  globalThis.__DEV__ !== false && globals.invariant.warn(
372
- 18,
372
+ 20,
373
373
  variables,
374
374
  ((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || queryDef
375
375
  );
@@ -467,7 +467,7 @@ var ObservableQuery = (function (_super) {
467
467
  options.onError(err);
468
468
  return;
469
469
  }
470
- globalThis.__DEV__ !== false && globals.invariant.error(19, err);
470
+ globalThis.__DEV__ !== false && globals.invariant.error(21, err);
471
471
  },
472
472
  });
473
473
  this.subscriptions.add(subscription);
@@ -546,9 +546,9 @@ var ObservableQuery = (function (_super) {
546
546
  }
547
547
  return options.fetchPolicy;
548
548
  };
549
- ObservableQuery.prototype.fetch = function (options, newNetworkStatus) {
549
+ ObservableQuery.prototype.fetch = function (options, newNetworkStatus, query) {
550
550
  this.queryManager.setObservableQuery(this);
551
- return this.queryManager["fetchConcastWithInfo"](this.queryId, options, newNetworkStatus);
551
+ return this.queryManager["fetchConcastWithInfo"](this.queryId, options, newNetworkStatus, query);
552
552
  };
553
553
  ObservableQuery.prototype.updatePolling = function () {
554
554
  var _this = this;
@@ -566,7 +566,7 @@ var ObservableQuery = (function (_super) {
566
566
  if (pollingInfo && pollingInfo.interval === pollInterval) {
567
567
  return;
568
568
  }
569
- globals.invariant(pollInterval, 20);
569
+ globals.invariant(pollInterval, 22);
570
570
  var info = pollingInfo || (this.pollingInfo = {});
571
571
  info.interval = pollInterval;
572
572
  var maybeFetch = function () {
@@ -630,15 +630,14 @@ var ObservableQuery = (function (_super) {
630
630
  }
631
631
  }
632
632
  }
633
- var fetchOptions = query === options.query ? options : tslib.__assign(tslib.__assign({}, options), { query: query });
634
- this.waitForOwnResult && (this.waitForOwnResult = skipCacheDataFor(fetchOptions.fetchPolicy));
633
+ this.waitForOwnResult && (this.waitForOwnResult = skipCacheDataFor(options.fetchPolicy));
635
634
  var finishWaitingForOwnResult = function () {
636
635
  if (_this.concast === concast) {
637
636
  _this.waitForOwnResult = false;
638
637
  }
639
638
  };
640
- var variables = fetchOptions.variables && tslib.__assign({}, fetchOptions.variables);
641
- var _a = this.fetch(fetchOptions, newNetworkStatus), concast = _a.concast, fromLink = _a.fromLink;
639
+ var variables = options.variables && tslib.__assign({}, options.variables);
640
+ var _a = this.fetch(options, newNetworkStatus, query), concast = _a.concast, fromLink = _a.fromLink;
642
641
  var observer = {
643
642
  next: function (result) {
644
643
  finishWaitingForOwnResult();
@@ -732,11 +731,11 @@ function reobserveCacheFirst(obsQuery) {
732
731
  return obsQuery.reobserve();
733
732
  }
734
733
  function defaultSubscriptionObserverErrorCallback(error) {
735
- globalThis.__DEV__ !== false && globals.invariant.error(21, error.message, error.stack);
734
+ globalThis.__DEV__ !== false && globals.invariant.error(23, error.message, error.stack);
736
735
  }
737
736
  function logMissingFieldErrors(missing) {
738
737
  if (globalThis.__DEV__ !== false && missing) {
739
- globalThis.__DEV__ !== false && globals.invariant.debug(22, missing);
738
+ globalThis.__DEV__ !== false && globals.invariant.debug(24, missing);
740
739
  }
741
740
  }
742
741
  function skipCacheDataFor(fetchPolicy) {
@@ -921,7 +920,7 @@ var LocalState = (function () {
921
920
  }
922
921
  else {
923
922
  fragment = fragmentMap[selection.name.value];
924
- globals.invariant(fragment, 16, selection.name.value);
923
+ globals.invariant(fragment, 18, selection.name.value);
925
924
  }
926
925
  if (fragment && fragment.typeCondition) {
927
926
  typeCondition = fragment.typeCondition.name.value;
@@ -1034,7 +1033,7 @@ var LocalState = (function () {
1034
1033
  },
1035
1034
  FragmentSpread: function (spread, _, __, ___, ancestors) {
1036
1035
  var fragment = fragmentMap[spread.name.value];
1037
- globals.invariant(fragment, 17, spread.name.value);
1036
+ globals.invariant(fragment, 19, spread.name.value);
1038
1037
  var fragmentSelections = collectByDefinition(fragment);
1039
1038
  if (fragmentSelections.size > 0) {
1040
1039
  ancestors.forEach(function (node) {
@@ -1080,7 +1079,6 @@ var QueryInfo = (function () {
1080
1079
  this.listeners = new Set();
1081
1080
  this.document = null;
1082
1081
  this.lastRequestId = 1;
1083
- this.subscriptions = new Set();
1084
1082
  this.stopped = false;
1085
1083
  this.dirty = false;
1086
1084
  this.observableQuery = null;
@@ -1215,7 +1213,6 @@ var QueryInfo = (function () {
1215
1213
  this.reset();
1216
1214
  this.cancel();
1217
1215
  this.cancel = QueryInfo.prototype.cancel;
1218
- this.subscriptions.forEach(function (sub) { return sub.unsubscribe(); });
1219
1216
  var oq = this.observableQuery;
1220
1217
  if (oq)
1221
1218
  oq.stopPolling();
@@ -1334,7 +1331,7 @@ var hasOwnProperty = Object.prototype.hasOwnProperty;
1334
1331
  var QueryManager = (function () {
1335
1332
  function QueryManager(_a) {
1336
1333
  var _this = this;
1337
- 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;
1334
+ 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, defaultContext = _a.defaultContext;
1338
1335
  this.clientAwareness = {};
1339
1336
  this.queries = new Map();
1340
1337
  this.fetchCancelFns = new Map();
@@ -1357,6 +1354,7 @@ var QueryManager = (function () {
1357
1354
  .concat(documentTransform)
1358
1355
  .concat(defaultDocumentTransform)
1359
1356
  : defaultDocumentTransform;
1357
+ this.defaultContext = defaultContext || Object.create(null);
1360
1358
  if ((this.onBroadcast = onBroadcast)) {
1361
1359
  this.mutationStore = Object.create(null);
1362
1360
  }
@@ -1366,7 +1364,7 @@ var QueryManager = (function () {
1366
1364
  this.queries.forEach(function (_info, queryId) {
1367
1365
  _this.stopQueryNoBroadcast(queryId);
1368
1366
  });
1369
- this.cancelPendingFetches(globals.newInvariantError(23));
1367
+ this.cancelPendingFetches(globals.newInvariantError(25));
1370
1368
  };
1371
1369
  QueryManager.prototype.cancelPendingFetches = function (error) {
1372
1370
  this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
@@ -1380,8 +1378,8 @@ var QueryManager = (function () {
1380
1378
  return tslib.__generator(this, function (_h) {
1381
1379
  switch (_h.label) {
1382
1380
  case 0:
1383
- globals.invariant(mutation, 24);
1384
- globals.invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 25);
1381
+ globals.invariant(mutation, 26);
1382
+ globals.invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 27);
1385
1383
  mutationId = this.generateMutationId();
1386
1384
  mutation = this.cache.transformForLink(this.transform(mutation));
1387
1385
  hasClientExports = this.getDocumentInfo(mutation).hasClientExports;
@@ -1702,10 +1700,10 @@ var QueryManager = (function () {
1702
1700
  QueryManager.prototype.query = function (options, queryId) {
1703
1701
  var _this = this;
1704
1702
  if (queryId === void 0) { queryId = this.generateQueryId(); }
1705
- globals.invariant(options.query, 26);
1706
- globals.invariant(options.query.kind === "Document", 27);
1707
- globals.invariant(!options.returnPartialData, 28);
1708
- globals.invariant(!options.pollInterval, 29);
1703
+ globals.invariant(options.query, 28);
1704
+ globals.invariant(options.query.kind === "Document", 29);
1705
+ globals.invariant(!options.returnPartialData, 30);
1706
+ globals.invariant(!options.pollInterval, 31);
1709
1707
  return this.fetchQuery(queryId, tslib.__assign(tslib.__assign({}, options), { query: this.transform(options.query) })).finally(function () { return _this.stopQuery(queryId); });
1710
1708
  };
1711
1709
  QueryManager.prototype.generateQueryId = function () {
@@ -1730,7 +1728,7 @@ var QueryManager = (function () {
1730
1728
  if (options === void 0) { options = {
1731
1729
  discardWatches: true,
1732
1730
  }; }
1733
- this.cancelPendingFetches(globals.newInvariantError(30));
1731
+ this.cancelPendingFetches(globals.newInvariantError(32));
1734
1732
  this.queries.forEach(function (queryInfo) {
1735
1733
  if (queryInfo.observableQuery) {
1736
1734
  queryInfo.networkStatus = exports.NetworkStatus.loading;
@@ -1806,7 +1804,7 @@ var QueryManager = (function () {
1806
1804
  if (globalThis.__DEV__ !== false && queryNamesAndDocs.size) {
1807
1805
  queryNamesAndDocs.forEach(function (included, nameOrDoc) {
1808
1806
  if (!included) {
1809
- globalThis.__DEV__ !== false && globals.invariant.warn(typeof nameOrDoc === "string" ? 31 : 32, nameOrDoc);
1807
+ globalThis.__DEV__ !== false && globals.invariant.warn(typeof nameOrDoc === "string" ? 33 : 34, nameOrDoc);
1810
1808
  }
1811
1809
  });
1812
1810
  }
@@ -1962,7 +1960,7 @@ var QueryManager = (function () {
1962
1960
  QueryManager.prototype.getResultsFromLink = function (queryInfo, cacheWriteBehavior, options) {
1963
1961
  var requestId = (queryInfo.lastRequestId = this.generateRequestId());
1964
1962
  var linkDocument = this.cache.transformForLink(options.query);
1965
- return utilities.asyncMap(this.getObservableFromLink(linkDocument, options.context, options.variables), function (result) {
1963
+ return utilities.asyncMap(this.getObservableFromLink(linkDocument, utilities.compact(this.defaultContext, options.context), options.variables), function (result) {
1966
1964
  var graphQLErrors = utilities.getGraphQLErrorsFromResult(result);
1967
1965
  var hasErrors = graphQLErrors.length > 0;
1968
1966
  if (requestId >= queryInfo.lastRequestId) {
@@ -1994,10 +1992,10 @@ var QueryManager = (function () {
1994
1992
  throw error;
1995
1993
  });
1996
1994
  };
1997
- QueryManager.prototype.fetchConcastWithInfo = function (queryId, options, networkStatus) {
1995
+ QueryManager.prototype.fetchConcastWithInfo = function (queryId, options, networkStatus, query) {
1998
1996
  var _this = this;
1999
1997
  if (networkStatus === void 0) { networkStatus = exports.NetworkStatus.loading; }
2000
- var query = options.query;
1998
+ if (query === void 0) { query = options.query; }
2001
1999
  var variables = this.getVariables(query, options.variables);
2002
2000
  var queryInfo = this.getQuery(queryId);
2003
2001
  var defaults = this.defaultOptions.watchQuery;
@@ -2243,11 +2241,11 @@ var ApolloClient = (function () {
2243
2241
  this.resetStoreCallbacks = [];
2244
2242
  this.clearStoreCallbacks = [];
2245
2243
  if (!options.cache) {
2246
- throw globals.newInvariantError(13);
2244
+ throw globals.newInvariantError(15);
2247
2245
  }
2248
2246
  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" &&
2249
2247
  !window.__APOLLO_CLIENT__ &&
2250
- globalThis.__DEV__ !== false : _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;
2248
+ globalThis.__DEV__ !== false : _c, _d = options.queryDeduplication, queryDeduplication = _d === void 0 ? true : _d, defaultOptions = options.defaultOptions, defaultContext = options.defaultContext, _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;
2251
2249
  var link = options.link;
2252
2250
  if (!link) {
2253
2251
  link = uri
@@ -2279,6 +2277,7 @@ var ApolloClient = (function () {
2279
2277
  cache: this.cache,
2280
2278
  link: this.link,
2281
2279
  defaultOptions: this.defaultOptions,
2280
+ defaultContext: defaultContext,
2282
2281
  documentTransform: documentTransform,
2283
2282
  queryDeduplication: queryDeduplication,
2284
2283
  ssrMode: ssrMode,
@@ -2368,7 +2367,7 @@ var ApolloClient = (function () {
2368
2367
  if (this.defaultOptions.query) {
2369
2368
  options = utilities.mergeOptions(this.defaultOptions.query, options);
2370
2369
  }
2371
- globals.invariant(options.fetchPolicy !== "cache-and-network", 14);
2370
+ globals.invariant(options.fetchPolicy !== "cache-and-network", 16);
2372
2371
  if (this.disableNetworkFetches && options.fetchPolicy === "network-only") {
2373
2372
  options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: "cache-first" });
2374
2373
  }
@@ -2461,7 +2460,7 @@ var ApolloClient = (function () {
2461
2460
  result.queries = queries;
2462
2461
  result.results = results;
2463
2462
  result.catch(function (error) {
2464
- globalThis.__DEV__ !== false && globals.invariant.debug(15, error);
2463
+ globalThis.__DEV__ !== false && globals.invariant.debug(17, error);
2465
2464
  });
2466
2465
  return result;
2467
2466
  };
@@ -2490,6 +2489,13 @@ var ApolloClient = (function () {
2490
2489
  ApolloClient.prototype.setLink = function (newLink) {
2491
2490
  this.link = this.queryManager.link = newLink;
2492
2491
  };
2492
+ Object.defineProperty(ApolloClient.prototype, "defaultContext", {
2493
+ get: function () {
2494
+ return this.queryManager.defaultContext;
2495
+ },
2496
+ enumerable: false,
2497
+ configurable: true
2498
+ });
2493
2499
  return ApolloClient;
2494
2500
  }());
2495
2501