@apollo/client 3.6.0-beta.0 → 3.6.0-beta.4

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 (137) hide show
  1. package/apollo-client.cjs +192 -182
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/cache/cache.cjs +15 -15
  5. package/cache/cache.cjs.map +1 -1
  6. package/cache/inmemory/helpers.js +1 -1
  7. package/cache/inmemory/helpers.js.map +1 -1
  8. package/cache/inmemory/key-extractor.js +2 -2
  9. package/cache/inmemory/key-extractor.js.map +1 -1
  10. package/cache/inmemory/policies.js +3 -3
  11. package/cache/inmemory/policies.js.map +1 -1
  12. package/cache/inmemory/readFromStore.js +3 -3
  13. package/cache/inmemory/readFromStore.js.map +1 -1
  14. package/cache/inmemory/writeToStore.js +6 -6
  15. package/cache/inmemory/writeToStore.js.map +1 -1
  16. package/core/ApolloClient.js +1 -1
  17. package/core/ApolloClient.js.map +1 -1
  18. package/core/LocalState.js +1 -1
  19. package/core/LocalState.js.map +1 -1
  20. package/core/ObservableQuery.d.ts.map +1 -1
  21. package/core/ObservableQuery.js +8 -5
  22. package/core/ObservableQuery.js.map +1 -1
  23. package/core/QueryManager.js +1 -1
  24. package/core/QueryManager.js.map +1 -1
  25. package/core/core.cjs +16 -13
  26. package/core/core.cjs.map +1 -1
  27. package/errors/errors.cjs +2 -2
  28. package/errors/errors.cjs.map +1 -1
  29. package/errors/index.js +2 -2
  30. package/errors/index.js.map +1 -1
  31. package/invariantErrorCodes.js +27 -27
  32. package/link/batch/batch.cjs +48 -38
  33. package/link/batch/batch.cjs.map +1 -1
  34. package/link/batch/batching.d.ts +2 -6
  35. package/link/batch/batching.d.ts.map +1 -1
  36. package/link/batch/batching.js +48 -38
  37. package/link/batch/batching.js.map +1 -1
  38. package/link/batch-http/batch-http.cjs +1 -1
  39. package/link/batch-http/batch-http.cjs.map +1 -1
  40. package/link/batch-http/batchHttpLink.js +2 -2
  41. package/link/batch-http/batchHttpLink.js.map +1 -1
  42. package/link/http/createHttpLink.js +2 -2
  43. package/link/http/createHttpLink.js.map +1 -1
  44. package/link/http/http.cjs +24 -13
  45. package/link/http/http.cjs.map +1 -1
  46. package/link/http/index.d.ts +1 -1
  47. package/link/http/index.d.ts.map +1 -1
  48. package/link/http/index.js +1 -1
  49. package/link/http/index.js.map +1 -1
  50. package/link/http/parseAndCheckHttpResponse.js +3 -3
  51. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  52. package/link/http/rewriteURIForGET.js +1 -1
  53. package/link/http/rewriteURIForGET.js.map +1 -1
  54. package/link/http/selectHttpOptionsAndBody.d.ts +5 -1
  55. package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
  56. package/link/http/selectHttpOptionsAndBody.js +19 -8
  57. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  58. package/link/http/serializeFetchParameter.js +1 -1
  59. package/link/http/serializeFetchParameter.js.map +1 -1
  60. package/link/subscriptions/index.d.ts +9 -0
  61. package/link/subscriptions/index.d.ts.map +1 -0
  62. package/link/subscriptions/index.js +39 -0
  63. package/link/subscriptions/index.js.map +1 -0
  64. package/link/subscriptions/package.json +8 -0
  65. package/link/subscriptions/subscriptions.cjs +45 -0
  66. package/link/subscriptions/subscriptions.cjs.map +1 -0
  67. package/link/utils/utils.cjs +1 -1
  68. package/link/utils/utils.cjs.map +1 -1
  69. package/link/utils/validateOperation.js +1 -1
  70. package/link/utils/validateOperation.js.map +1 -1
  71. package/main.cjs +4 -4
  72. package/package.json +21 -15
  73. package/react/components/components.cjs +3 -3
  74. package/react/context/context.cjs +3 -3
  75. package/react/hoc/hoc.cjs +9 -9
  76. package/react/hoc/hoc.cjs.map +1 -1
  77. package/react/hoc/mutation-hoc.js +2 -2
  78. package/react/hoc/mutation-hoc.js.map +1 -1
  79. package/react/hoc/query-hoc.js +1 -1
  80. package/react/hoc/query-hoc.js.map +1 -1
  81. package/react/hoc/subscription-hoc.js +1 -1
  82. package/react/hoc/subscription-hoc.js.map +1 -1
  83. package/react/hoc/withApollo.js +1 -1
  84. package/react/hoc/withApollo.js.map +1 -1
  85. package/react/hooks/hooks.cjs +113 -117
  86. package/react/hooks/hooks.cjs.map +1 -1
  87. package/react/hooks/useApolloClient.js +2 -2
  88. package/react/hooks/useApolloClient.js.map +1 -1
  89. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  90. package/react/hooks/useLazyQuery.js +20 -27
  91. package/react/hooks/useLazyQuery.js.map +1 -1
  92. package/react/hooks/useMutation.d.ts.map +1 -1
  93. package/react/hooks/useMutation.js +59 -65
  94. package/react/hooks/useMutation.js.map +1 -1
  95. package/react/hooks/useQuery.d.ts.map +1 -1
  96. package/react/hooks/useQuery.js +25 -17
  97. package/react/hooks/useQuery.js.map +1 -1
  98. package/react/hooks/useSubscription.d.ts.map +1 -1
  99. package/react/hooks/useSubscription.js +10 -8
  100. package/react/hooks/useSubscription.js.map +1 -1
  101. package/react/parser/index.js +7 -7
  102. package/react/parser/index.js.map +1 -1
  103. package/react/parser/parser.cjs +7 -7
  104. package/react/parser/parser.cjs.map +1 -1
  105. package/react/react.cjs +2 -2
  106. package/react/ssr/ssr.cjs +3 -3
  107. package/react/types/types.d.ts +1 -1
  108. package/react/types/types.d.ts.map +1 -1
  109. package/react/types/types.js.map +1 -1
  110. package/testing/core/core.cjs +2 -2
  111. package/testing/core/core.cjs.map +1 -1
  112. package/testing/core/mocking/mockFetch.js +1 -1
  113. package/testing/core/mocking/mockFetch.js.map +1 -1
  114. package/testing/core/mocking/mockLink.js +2 -2
  115. package/testing/core/mocking/mockLink.js.map +1 -1
  116. package/testing/core/observableToPromise.js +1 -1
  117. package/testing/core/observableToPromise.js.map +1 -1
  118. package/testing/testing.cjs +5 -5
  119. package/utilities/common/makeUniqueId.js +1 -1
  120. package/utilities/common/makeUniqueId.js.map +1 -1
  121. package/utilities/globals/fix-graphql.js +1 -1
  122. package/utilities/globals/global.d.ts.map +1 -1
  123. package/utilities/globals/global.js +1 -1
  124. package/utilities/globals/global.js.map +1 -1
  125. package/utilities/globals/globals.cjs +1 -1
  126. package/utilities/globals/globals.cjs.map +1 -1
  127. package/utilities/graphql/directives.js +4 -4
  128. package/utilities/graphql/directives.js.map +1 -1
  129. package/utilities/graphql/fragments.js +3 -3
  130. package/utilities/graphql/fragments.js.map +1 -1
  131. package/utilities/graphql/getFromAST.js +2 -2
  132. package/utilities/graphql/getFromAST.js.map +1 -1
  133. package/utilities/graphql/storeUtils.js +5 -5
  134. package/utilities/graphql/storeUtils.js.map +1 -1
  135. package/utilities/utilities.cjs +15 -15
  136. package/utilities/utilities.cjs.map +1 -1
  137. package/version.js +1 -1
package/apollo-client.cjs CHANGED
@@ -18,11 +18,11 @@ function _interopNamespace(e) {
18
18
  if (e && e.__esModule) return e;
19
19
  var n = Object.create(null);
20
20
  if (e) {
21
- Object.keys(e).forEach(function (k) {
21
+ for (var k in e) {
22
22
  n[k] = e[k];
23
- });
23
+ }
24
24
  }
25
- n['default'] = e;
25
+ n["default"] = e;
26
26
  return Object.freeze(n);
27
27
  }
28
28
 
@@ -45,7 +45,7 @@ function shouldInclude(_a, variables) {
45
45
  var evaledValue = false;
46
46
  if (ifArgument.value.kind === 'Variable') {
47
47
  evaledValue = variables && variables[ifArgument.value.name.value];
48
- __DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.") : tsInvariant.invariant(evaledValue !== void 0, 37);
48
+ __DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @".concat(directive.name.value, " directive.")) : tsInvariant.invariant(evaledValue !== void 0, 37);
49
49
  }
50
50
  else {
51
51
  evaledValue = ifArgument.value.value;
@@ -82,12 +82,12 @@ function getInclusionDirectives(directives) {
82
82
  return;
83
83
  var directiveArguments = directive.arguments;
84
84
  var directiveName = directive.name.value;
85
- __DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.") : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, 38);
85
+ __DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @".concat(directiveName, " directive.")) : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, 38);
86
86
  var ifArgument = directiveArguments[0];
87
- __DEV__ ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive.") : tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', 39);
87
+ __DEV__ ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @".concat(directiveName, " directive.")) : tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', 39);
88
88
  var ifValue = ifArgument.value;
89
89
  __DEV__ ? tsInvariant.invariant(ifValue &&
90
- (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @" + directiveName + " directive must be a variable or a boolean value.") : tsInvariant.invariant(ifValue &&
90
+ (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @".concat(directiveName, " directive must be a variable or a boolean value.")) : tsInvariant.invariant(ifValue &&
91
91
  (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 40);
92
92
  result.push({ directive: directive, ifArgument: ifArgument });
93
93
  });
@@ -100,7 +100,7 @@ function getFragmentQueryDocument(document, fragmentName) {
100
100
  var fragments = [];
101
101
  document.definitions.forEach(function (definition) {
102
102
  if (definition.kind === 'OperationDefinition') {
103
- throw __DEV__ ? new tsInvariant.InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " +
103
+ throw __DEV__ ? new tsInvariant.InvariantError("Found a ".concat(definition.operation, " operation").concat(definition.name ? " named '".concat(definition.name.value, "'") : '', ". ") +
104
104
  'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new tsInvariant.InvariantError(41);
105
105
  }
106
106
  if (definition.kind === 'FragmentDefinition') {
@@ -108,7 +108,7 @@ function getFragmentQueryDocument(document, fragmentName) {
108
108
  }
109
109
  });
110
110
  if (typeof actualFragmentName === 'undefined') {
111
- __DEV__ ? tsInvariant.invariant(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.") : tsInvariant.invariant(fragments.length === 1, 42);
111
+ __DEV__ ? tsInvariant.invariant(fragments.length === 1, "Found ".concat(fragments.length, " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.")) : tsInvariant.invariant(fragments.length === 1, 42);
112
112
  actualFragmentName = fragments[0].name.value;
113
113
  }
114
114
  var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
@@ -145,7 +145,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
145
145
  return selection;
146
146
  case 'FragmentSpread': {
147
147
  var fragment = fragmentMap && fragmentMap[selection.name.value];
148
- __DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value + ".") : tsInvariant.invariant(fragment, 43);
148
+ __DEV__ ? tsInvariant.invariant(fragment, "No fragment named ".concat(selection.name.value, ".")) : tsInvariant.invariant(fragment, 43);
149
149
  return fragment;
150
150
  }
151
151
  default:
@@ -227,7 +227,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
227
227
  argObj[name.value] = null;
228
228
  }
229
229
  else {
230
- throw __DEV__ ? new tsInvariant.InvariantError("The inline argument \"" + name.value + "\" of kind \"" + value.kind + "\"" +
230
+ throw __DEV__ ? new tsInvariant.InvariantError("The inline argument \"".concat(name.value, "\" of kind \"").concat(value.kind, "\"") +
231
231
  'is not supported. Use variables instead of inline arguments to ' +
232
232
  'overcome this limitation.') : new tsInvariant.InvariantError(52);
233
233
  }
@@ -279,7 +279,7 @@ var getStoreKeyName = Object.assign(function (fieldName, args, directives) {
279
279
  filterKeys.forEach(function (key) {
280
280
  filteredArgs_1[key] = args[key];
281
281
  });
282
- return directives['connection']['key'] + "(" + stringify(filteredArgs_1) + ")";
282
+ return "".concat(directives['connection']['key'], "(").concat(stringify(filteredArgs_1), ")");
283
283
  }
284
284
  else {
285
285
  return directives['connection']['key'];
@@ -288,17 +288,17 @@ var getStoreKeyName = Object.assign(function (fieldName, args, directives) {
288
288
  var completeFieldName = fieldName;
289
289
  if (args) {
290
290
  var stringifiedArgs = stringify(args);
291
- completeFieldName += "(" + stringifiedArgs + ")";
291
+ completeFieldName += "(".concat(stringifiedArgs, ")");
292
292
  }
293
293
  if (directives) {
294
294
  Object.keys(directives).forEach(function (key) {
295
295
  if (KNOWN_DIRECTIVES.indexOf(key) !== -1)
296
296
  return;
297
297
  if (directives[key] && Object.keys(directives[key]).length) {
298
- completeFieldName += "@" + key + "(" + stringify(directives[key]) + ")";
298
+ completeFieldName += "@".concat(key, "(").concat(stringify(directives[key]), ")");
299
299
  }
300
300
  else {
301
- completeFieldName += "@" + key;
301
+ completeFieldName += "@".concat(key);
302
302
  }
303
303
  });
304
304
  }
@@ -368,11 +368,11 @@ function checkDocument(doc) {
368
368
  .filter(function (d) { return d.kind !== 'FragmentDefinition'; })
369
369
  .map(function (definition) {
370
370
  if (definition.kind !== 'OperationDefinition') {
371
- throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"") : new tsInvariant.InvariantError(45);
371
+ throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"".concat(definition.kind, "\"")) : new tsInvariant.InvariantError(45);
372
372
  }
373
373
  return definition;
374
374
  });
375
- __DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations") : tsInvariant.invariant(operations.length <= 1, 46);
375
+ __DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains ".concat(operations.length, " operations")) : tsInvariant.invariant(operations.length <= 1, 46);
376
376
  return doc;
377
377
  }
378
378
  function getOperationDefinition(doc) {
@@ -1077,7 +1077,7 @@ var prefixCounts = new Map();
1077
1077
  function makeUniqueId(prefix) {
1078
1078
  var count = prefixCounts.get(prefix) || 1;
1079
1079
  prefixCounts.set(prefix, count + 1);
1080
- return prefix + ":" + count + ":" + Math.random().toString(36).slice(2);
1080
+ return "".concat(prefix, ":").concat(count, ":").concat(Math.random().toString(36).slice(2));
1081
1081
  }
1082
1082
 
1083
1083
  function stringifyForDisplay(value) {
@@ -1142,7 +1142,7 @@ function validateOperation(operation) {
1142
1142
  for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
1143
1143
  var key = _a[_i];
1144
1144
  if (OPERATION_FIELDS.indexOf(key) < 0) {
1145
- throw __DEV__ ? new tsInvariant.InvariantError("illegal argument: " + key) : new tsInvariant.InvariantError(24);
1145
+ throw __DEV__ ? new tsInvariant.InvariantError("illegal argument: ".concat(key)) : new tsInvariant.InvariantError(24);
1146
1146
  }
1147
1147
  }
1148
1148
  return operation;
@@ -1291,7 +1291,7 @@ var concat = ApolloLink.concat;
1291
1291
 
1292
1292
  var execute = ApolloLink.execute;
1293
1293
 
1294
- var version = '3.6.0-beta.0';
1294
+ var version = '3.6.0-beta.4';
1295
1295
 
1296
1296
  var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
1297
1297
  function parseAndCheckHttpResponse(operations) {
@@ -1312,14 +1312,14 @@ function parseAndCheckHttpResponse(operations) {
1312
1312
  })
1313
1313
  .then(function (result) {
1314
1314
  if (response.status >= 300) {
1315
- throwServerError(response, result, "Response not successful: Received status code " + response.status);
1315
+ throwServerError(response, result, "Response not successful: Received status code ".concat(response.status));
1316
1316
  }
1317
1317
  if (!Array.isArray(result) &&
1318
1318
  !hasOwnProperty$2.call(result, 'data') &&
1319
1319
  !hasOwnProperty$2.call(result, 'errors')) {
1320
- throwServerError(response, result, "Server response was missing for query '" + (Array.isArray(operations)
1320
+ throwServerError(response, result, "Server response was missing for query '".concat(Array.isArray(operations)
1321
1321
  ? operations.map(function (op) { return op.operationName; })
1322
- : operations.operationName) + "'.");
1322
+ : operations.operationName, "'."));
1323
1323
  }
1324
1324
  return result;
1325
1325
  }); };
@@ -1331,7 +1331,7 @@ var serializeFetchParameter = function (p, label) {
1331
1331
  serialized = JSON.stringify(p);
1332
1332
  }
1333
1333
  catch (e) {
1334
- var parseError = __DEV__ ? new tsInvariant.InvariantError("Network request failed. " + label + " is not serializable: " + e.message) : new tsInvariant.InvariantError(21);
1334
+ var parseError = __DEV__ ? new tsInvariant.InvariantError("Network request failed. ".concat(label, " is not serializable: ").concat(e.message)) : new tsInvariant.InvariantError(21);
1335
1335
  parseError.parseError = e;
1336
1336
  throw parseError;
1337
1337
  }
@@ -1355,17 +1355,27 @@ var fallbackHttpConfig = {
1355
1355
  options: defaultOptions,
1356
1356
  };
1357
1357
  var defaultPrinter = function (ast, printer) { return printer(ast); };
1358
- var selectHttpOptionsAndBody = function (operation, printer, fallbackConfig) {
1358
+ function selectHttpOptionsAndBody(operation, fallbackConfig) {
1359
+ var configs = [];
1360
+ for (var _i = 2; _i < arguments.length; _i++) {
1361
+ configs[_i - 2] = arguments[_i];
1362
+ }
1363
+ configs.unshift(fallbackConfig);
1364
+ return selectHttpOptionsAndBodyInternal.apply(void 0, tslib.__spreadArray([operation,
1365
+ defaultPrinter], configs, false));
1366
+ }
1367
+ function selectHttpOptionsAndBodyInternal(operation, printer) {
1359
1368
  var configs = [];
1360
- for (var _i = 3; _i < arguments.length; _i++) {
1361
- configs[_i - 3] = arguments[_i];
1369
+ for (var _i = 2; _i < arguments.length; _i++) {
1370
+ configs[_i - 2] = arguments[_i];
1362
1371
  }
1363
- var options = tslib.__assign(tslib.__assign({}, fallbackConfig.options), { headers: fallbackConfig.headers, credentials: fallbackConfig.credentials });
1364
- var http = fallbackConfig.http || {};
1372
+ var options = {};
1373
+ var http = {};
1365
1374
  configs.forEach(function (config) {
1366
1375
  options = tslib.__assign(tslib.__assign(tslib.__assign({}, options), config.options), { headers: tslib.__assign(tslib.__assign({}, options.headers), headersToLowerCase(config.headers)) });
1367
- if (config.credentials)
1376
+ if (config.credentials) {
1368
1377
  options.credentials = config.credentials;
1378
+ }
1369
1379
  http = tslib.__assign(tslib.__assign({}, http), config.http);
1370
1380
  });
1371
1381
  var operationName = operation.operationName, extensions = operation.extensions, variables = operation.variables, query = operation.query;
@@ -1378,7 +1388,7 @@ var selectHttpOptionsAndBody = function (operation, printer, fallbackConfig) {
1378
1388
  options: options,
1379
1389
  body: body,
1380
1390
  };
1381
- };
1391
+ }
1382
1392
  function headersToLowerCase(headers) {
1383
1393
  if (headers) {
1384
1394
  var normalized_1 = Object.create(null);
@@ -1421,7 +1431,7 @@ var selectURI = function (operation, fallbackURI) {
1421
1431
  function rewriteURIForGET(chosenURI, body) {
1422
1432
  var queryParams = [];
1423
1433
  var addQueryParam = function (key, value) {
1424
- queryParams.push(key + "=" + encodeURIComponent(value));
1434
+ queryParams.push("".concat(key, "=").concat(encodeURIComponent(value)));
1425
1435
  };
1426
1436
  if ('query' in body) {
1427
1437
  addQueryParam('query', body.query);
@@ -1493,7 +1503,7 @@ var createHttpLink = function (linkOptions) {
1493
1503
  credentials: context.credentials,
1494
1504
  headers: contextHeaders,
1495
1505
  };
1496
- var _b = selectHttpOptionsAndBody(operation, print, fallbackHttpConfig, linkConfig, contextConfig), options = _b.options, body = _b.body;
1506
+ var _b = selectHttpOptionsAndBodyInternal(operation, print, fallbackHttpConfig, linkConfig, contextConfig), options = _b.options, body = _b.body;
1497
1507
  if (body.variables && !includeUnusedVariables) {
1498
1508
  var unusedNames_1 = new Set(Object.keys(body.variables));
1499
1509
  graphql.visit(operation.query, {
@@ -1686,7 +1696,7 @@ function defaultDataIdFromObject(_a, context) {
1686
1696
  if (id === void 0)
1687
1697
  id = _id;
1688
1698
  if (id !== void 0) {
1689
- return __typename + ":" + ((typeof id === "number" ||
1699
+ return "".concat(__typename, ":").concat((typeof id === "number" ||
1690
1700
  typeof id === "string") ? id : JSON.stringify(id));
1691
1701
  }
1692
1702
  }
@@ -2422,7 +2432,7 @@ var StoreReader = (function () {
2422
2432
  !context.store.has(objectOrReference.__ref)) {
2423
2433
  return {
2424
2434
  result: this.canon.empty,
2425
- missing: "Dangling reference to missing " + objectOrReference.__ref + " object",
2435
+ missing: "Dangling reference to missing ".concat(objectOrReference.__ref, " object"),
2426
2436
  };
2427
2437
  }
2428
2438
  var variables = context.variables, policies = context.policies, store = context.store;
@@ -2457,7 +2467,7 @@ var StoreReader = (function () {
2457
2467
  if (fieldValue === void 0) {
2458
2468
  if (!addTypenameToDocument.added(selection)) {
2459
2469
  missing = context.merge(missing, (_a = {},
2460
- _a[resultName] = "Can't find field '" + selection.name.value + "' on " + (isReference(objectOrReference)
2470
+ _a[resultName] = "Can't find field '".concat(selection.name.value, "' on ").concat(isReference(objectOrReference)
2461
2471
  ? objectOrReference.__ref + " object"
2462
2472
  : "object " + JSON.stringify(objectOrReference, null, 2)),
2463
2473
  _a));
@@ -2567,7 +2577,7 @@ function assertSelectionSetForIdValue(store, field, fieldValue) {
2567
2577
  var workSet_1 = new Set([fieldValue]);
2568
2578
  workSet_1.forEach(function (value) {
2569
2579
  if (isNonNullObject(value)) {
2570
- __DEV__ ? tsInvariant.invariant(!isReference(value), "Missing selection set for object of type " + getTypenameFromStoreObject(store, value) + " returned for query field " + field.name.value) : tsInvariant.invariant(!isReference(value), 5);
2580
+ __DEV__ ? tsInvariant.invariant(!isReference(value), "Missing selection set for object of type ".concat(getTypenameFromStoreObject(store, value), " returned for query field ").concat(field.name.value)) : tsInvariant.invariant(!isReference(value), 5);
2571
2581
  Object.values(value).forEach(workSet_1.add, workSet_1);
2572
2582
  }
2573
2583
  });
@@ -2654,10 +2664,10 @@ function keyFieldsFnFromSpecifier(specifier) {
2654
2664
  hasOwn.call(object, schemaKeyPath[0])) {
2655
2665
  extracted = extractKeyPath(object, schemaKeyPath, extractKey);
2656
2666
  }
2657
- __DEV__ ? tsInvariant.invariant(extracted !== void 0, "Missing field '" + schemaKeyPath.join('.') + "' while extracting keyFields from " + JSON.stringify(object)) : tsInvariant.invariant(extracted !== void 0, 2);
2667
+ __DEV__ ? tsInvariant.invariant(extracted !== void 0, "Missing field '".concat(schemaKeyPath.join('.'), "' while extracting keyFields from ").concat(JSON.stringify(object))) : tsInvariant.invariant(extracted !== void 0, 2);
2658
2668
  return extracted;
2659
2669
  });
2660
- return context.typename + ":" + JSON.stringify(keyObject);
2670
+ return "".concat(context.typename, ":").concat(JSON.stringify(keyObject));
2661
2671
  });
2662
2672
  }
2663
2673
  function keyArgsFnFromSpecifier(specifier) {
@@ -2883,7 +2893,7 @@ var Policies = (function () {
2883
2893
  var rootId = "ROOT_" + which.toUpperCase();
2884
2894
  var old = this.rootTypenamesById[rootId];
2885
2895
  if (typename !== old) {
2886
- __DEV__ ? tsInvariant.invariant(!old || old === which, "Cannot change root " + which + " __typename more than once") : tsInvariant.invariant(!old || old === which, 3);
2896
+ __DEV__ ? tsInvariant.invariant(!old || old === which, "Cannot change root ".concat(which, " __typename more than once")) : tsInvariant.invariant(!old || old === which, 3);
2887
2897
  if (old)
2888
2898
  delete this.rootIdsByTypename[old];
2889
2899
  this.rootIdsByTypename[typename] = rootId;
@@ -2967,7 +2977,7 @@ var Policies = (function () {
2967
2977
  if (supertypeSet.has(supertype)) {
2968
2978
  if (!typenameSupertypeSet.has(supertype)) {
2969
2979
  if (checkingFuzzySubtypes) {
2970
- __DEV__ && tsInvariant.invariant.warn("Inferring subtype " + typename + " of supertype " + supertype);
2980
+ __DEV__ && tsInvariant.invariant.warn("Inferring subtype ".concat(typename, " of supertype ").concat(supertype));
2971
2981
  }
2972
2982
  typenameSupertypeSet.add(supertype);
2973
2983
  }
@@ -3121,7 +3131,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
3121
3131
  }
3122
3132
  }
3123
3133
  if (__DEV__ && options.from === void 0) {
3124
- __DEV__ && tsInvariant.invariant.warn("Undefined 'from' passed to readField with arguments " + stringifyForDisplay(Array.from(readFieldArgs)));
3134
+ __DEV__ && tsInvariant.invariant.warn("Undefined 'from' passed to readField with arguments ".concat(stringifyForDisplay(Array.from(readFieldArgs))));
3125
3135
  }
3126
3136
  if (void 0 === options.variables) {
3127
3137
  options.variables = variables;
@@ -3161,7 +3171,7 @@ function makeMergeObjectsFunction(store) {
3161
3171
  }
3162
3172
 
3163
3173
  function getContextFlavor(context, clientOnly, deferred) {
3164
- var key = "" + clientOnly + deferred;
3174
+ var key = "".concat(clientOnly).concat(deferred);
3165
3175
  var flavored = context.flavors.get(key);
3166
3176
  if (!flavored) {
3167
3177
  context.flavors.set(key, flavored = (context.clientOnly === clientOnly &&
@@ -3203,7 +3213,7 @@ var StoreWriter = (function () {
3203
3213
  context: context,
3204
3214
  });
3205
3215
  if (!isReference(ref)) {
3206
- throw __DEV__ ? new tsInvariant.InvariantError("Could not identify object " + JSON.stringify(result)) : new tsInvariant.InvariantError(6);
3216
+ throw __DEV__ ? new tsInvariant.InvariantError("Could not identify object ".concat(JSON.stringify(result))) : new tsInvariant.InvariantError(6);
3207
3217
  }
3208
3218
  context.incomingById.forEach(function (_a, dataId) {
3209
3219
  var storeObject = _a.storeObject, mergeTree = _a.mergeTree, fieldNodeSet = _a.fieldNodeSet;
@@ -3308,7 +3318,7 @@ var StoreWriter = (function () {
3308
3318
  !context.deferred &&
3309
3319
  !addTypenameToDocument.added(field) &&
3310
3320
  !policies.getReadFunction(typename, field.name.value)) {
3311
- __DEV__ && tsInvariant.invariant.error(("Missing field '" + resultKeyNameFromField(field) + "' while writing result " + JSON.stringify(result, null, 2)).substring(0, 1000));
3321
+ __DEV__ && tsInvariant.invariant.error("Missing field '".concat(resultKeyNameFromField(field), "' while writing result ").concat(JSON.stringify(result, null, 2)).substring(0, 1000));
3312
3322
  }
3313
3323
  });
3314
3324
  try {
@@ -3530,7 +3540,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
3530
3540
  var parentType = store.getFieldValue(existingRef, "__typename") ||
3531
3541
  store.getFieldValue(incomingObj, "__typename");
3532
3542
  var fieldName = fieldNameFromStoreName(storeFieldName);
3533
- var typeDotName = parentType + "." + fieldName;
3543
+ var typeDotName = "".concat(parentType, ".").concat(fieldName);
3534
3544
  if (warnings.has(typeDotName))
3535
3545
  return;
3536
3546
  warnings.add(typeDotName);
@@ -3545,10 +3555,10 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
3545
3555
  }
3546
3556
  });
3547
3557
  }
3548
- __DEV__ && tsInvariant.invariant.warn("Cache data may be lost when replacing the " + fieldName + " field of a " + parentType + " object.\n\nTo address this problem (which is not a bug in Apollo Client), " + (childTypenames.length
3558
+ __DEV__ && tsInvariant.invariant.warn("Cache data may be lost when replacing the ".concat(fieldName, " field of a ").concat(parentType, " object.\n\nTo address this problem (which is not a bug in Apollo Client), ").concat(childTypenames.length
3549
3559
  ? "either ensure all objects of type " +
3550
3560
  childTypenames.join(" and ") + " have an ID or a custom merge function, or "
3551
- : "") + "define a custom merge function for the " + typeDotName + " field, so InMemoryCache can safely merge these objects:\n\n existing: " + JSON.stringify(existing).slice(0, 1000) + "\n incoming: " + JSON.stringify(incoming).slice(0, 1000) + "\n\nFor more information about these options, please refer to the documentation:\n\n * Ensuring entity objects have IDs: https://go.apollo.dev/c/generating-unique-identifiers\n * Defining custom merge functions: https://go.apollo.dev/c/merging-non-normalized-objects\n");
3561
+ : "", "define a custom merge function for the ").concat(typeDotName, " field, so InMemoryCache can safely merge these objects:\n\n existing: ").concat(JSON.stringify(existing).slice(0, 1000), "\n incoming: ").concat(JSON.stringify(incoming).slice(0, 1000), "\n\nFor more information about these options, please refer to the documentation:\n\n * Ensuring entity objects have IDs: https://go.apollo.dev/c/generating-unique-identifiers\n * Defining custom merge functions: https://go.apollo.dev/c/merging-non-normalized-objects\n"));
3552
3562
  }
3553
3563
 
3554
3564
  var InMemoryCache = (function (_super) {
@@ -3855,11 +3865,11 @@ var generateErrorMessage = function (err) {
3855
3865
  var errorMessage = error
3856
3866
  ? error.message
3857
3867
  : 'Error message not found.';
3858
- message += errorMessage + "\n";
3868
+ message += "".concat(errorMessage, "\n");
3859
3869
  });
3860
3870
  }
3861
3871
  if (err.networkError) {
3862
- message += err.networkError.message + "\n";
3872
+ message += "".concat(err.networkError.message, "\n");
3863
3873
  }
3864
3874
  message = message.replace(/\n$/, '');
3865
3875
  return message;
@@ -4041,7 +4051,7 @@ var ObservableQuery = (function (_super) {
4041
4051
  pollInterval: 0,
4042
4052
  };
4043
4053
  var fetchPolicy = this.options.fetchPolicy;
4044
- if (fetchPolicy === 'standby' || fetchPolicy === 'cache-and-network') {
4054
+ if (fetchPolicy === 'cache-and-network') {
4045
4055
  reobserveOptions.fetchPolicy = fetchPolicy;
4046
4056
  }
4047
4057
  else if (fetchPolicy === 'no-cache') {
@@ -4054,7 +4064,7 @@ var ObservableQuery = (function (_super) {
4054
4064
  var queryDef = getQueryDefinition(this.options.query);
4055
4065
  var vars = queryDef.variableDefinitions;
4056
4066
  if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
4057
- __DEV__ && tsInvariant.invariant.warn("Called refetch(" + JSON.stringify(variables) + ") for query " + (((_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 })?");
4067
+ __DEV__ && tsInvariant.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 })?"));
4058
4068
  }
4059
4069
  }
4060
4070
  if (variables && !equality.equal(this.options.variables, variables)) {
@@ -4281,8 +4291,11 @@ var ObservableQuery = (function (_super) {
4281
4291
  this.reportResult(this.getCurrentResult(false), this.variables);
4282
4292
  };
4283
4293
  ObservableQuery.prototype.reportResult = function (result, variables) {
4284
- if (this.getLastError() || this.isDifferentFromLastResult(result)) {
4285
- this.updateLastResult(result, variables);
4294
+ var lastError = this.getLastError();
4295
+ if (lastError || this.isDifferentFromLastResult(result)) {
4296
+ if (lastError || !result.partial || this.options.returnPartialData) {
4297
+ this.updateLastResult(result, variables);
4298
+ }
4286
4299
  iterateObserversSafely(this.observers, 'next', result);
4287
4300
  }
4288
4301
  };
@@ -4317,7 +4330,7 @@ function defaultSubscriptionObserverErrorCallback(error) {
4317
4330
  }
4318
4331
  function logMissingFieldErrors(missing) {
4319
4332
  if (__DEV__ && missing) {
4320
- __DEV__ && tsInvariant.invariant.debug("Missing cache result fields: " + JSON.stringify(missing), missing);
4333
+ __DEV__ && tsInvariant.invariant.debug("Missing cache result fields: ".concat(JSON.stringify(missing)), missing);
4321
4334
  }
4322
4335
  }
4323
4336
  function applyNextFetchPolicy(options) {
@@ -4498,7 +4511,7 @@ var LocalState = (function () {
4498
4511
  }
4499
4512
  else {
4500
4513
  fragment = fragmentMap[selection.name.value];
4501
- __DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value) : tsInvariant.invariant(fragment, 9);
4514
+ __DEV__ ? tsInvariant.invariant(fragment, "No fragment named ".concat(selection.name.value)) : tsInvariant.invariant(fragment, 9);
4502
4515
  }
4503
4516
  if (fragment && fragment.typeCondition) {
4504
4517
  typeCondition = fragment.typeCondition.name.value;
@@ -5289,7 +5302,7 @@ var QueryManager = (function () {
5289
5302
  if (__DEV__ && queryNamesAndDocs.size) {
5290
5303
  queryNamesAndDocs.forEach(function (included, nameOrDoc) {
5291
5304
  if (!included) {
5292
- __DEV__ && tsInvariant.invariant.warn("Unknown query " + (typeof nameOrDoc === "string" ? "named " : "") + JSON.stringify(nameOrDoc, null, 2) + " requested in refetchQueries options.include array");
5305
+ __DEV__ && tsInvariant.invariant.warn("Unknown query ".concat(typeof nameOrDoc === "string" ? "named " : "").concat(JSON.stringify(nameOrDoc, null, 2), " requested in refetchQueries options.include array"));
5293
5306
  }
5294
5307
  });
5295
5308
  }
@@ -5880,7 +5893,7 @@ var ApolloClient = (function () {
5880
5893
  result.queries = queries;
5881
5894
  result.results = results;
5882
5895
  result.catch(function (error) {
5883
- __DEV__ && tsInvariant.invariant.debug("In client.refetchQueries, Promise.all promise rejected with error " + error);
5896
+ __DEV__ && tsInvariant.invariant.debug("In client.refetchQueries, Promise.all promise rejected with error ".concat(error));
5884
5897
  });
5885
5898
  return result;
5886
5899
  };
@@ -5956,8 +5969,8 @@ function useApolloClient(override) {
5956
5969
  var context = React.useContext(getApolloContext());
5957
5970
  var client = override || context.client;
5958
5971
  __DEV__ ? tsInvariant.invariant(!!client, 'Could not find "client" in the context or passed in as an option. ' +
5959
- 'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient' +
5960
- 'ApolloClient instance in via options.') : tsInvariant.invariant(!!client, 29);
5972
+ 'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient ' +
5973
+ 'instance in via options.') : tsInvariant.invariant(!!client, 29);
5961
5974
  return client;
5962
5975
  }
5963
5976
 
@@ -5988,7 +6001,7 @@ function parser(document) {
5988
6001
  if (cached)
5989
6002
  return cached;
5990
6003
  var variables, type, name;
5991
- __DEV__ ? tsInvariant.invariant(!!document && !!document.kind, "Argument of " + document + " passed to parser was not a valid GraphQL " +
6004
+ __DEV__ ? tsInvariant.invariant(!!document && !!document.kind, "Argument of ".concat(document, " passed to parser was not a valid GraphQL ") +
5992
6005
  "DocumentNode. You may need to use 'graphql-tag' or another method " +
5993
6006
  "to convert your operation into a document") : tsInvariant.invariant(!!document && !!document.kind, 30);
5994
6007
  var fragments = document.definitions.filter(function (x) { return x.kind === 'FragmentDefinition'; });
@@ -6006,8 +6019,8 @@ function parser(document) {
6006
6019
  "You must include a query, subscription or mutation as well") : tsInvariant.invariant(!fragments.length ||
6007
6020
  (queries.length || mutations.length || subscriptions.length), 31);
6008
6021
  __DEV__ ? tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1, "react-apollo only supports a query, subscription, or a mutation per HOC. " +
6009
- (document + " had " + queries.length + " queries, " + subscriptions.length + " ") +
6010
- ("subscriptions and " + mutations.length + " mutations. ") +
6022
+ "".concat(document, " had ").concat(queries.length, " queries, ").concat(subscriptions.length, " ") +
6023
+ "subscriptions and ".concat(mutations.length, " mutations. ") +
6011
6024
  "You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1, 32);
6012
6025
  type = queries.length ? exports.DocumentType.Query : exports.DocumentType.Mutation;
6013
6026
  if (!queries.length && !mutations.length)
@@ -6017,8 +6030,8 @@ function parser(document) {
6017
6030
  : mutations.length
6018
6031
  ? mutations
6019
6032
  : subscriptions;
6020
- __DEV__ ? tsInvariant.invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. " + document + " had " +
6021
- (definitions.length + " definitions. ") +
6033
+ __DEV__ ? tsInvariant.invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. ".concat(document, " had ") +
6034
+ "".concat(definitions.length, " definitions. ") +
6022
6035
  "You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(definitions.length === 1, 33);
6023
6036
  var definition = definitions[0];
6024
6037
  variables = definition.variableDefinitions || [];
@@ -6036,17 +6049,18 @@ function verifyDocumentType(document, type) {
6036
6049
  var operation = parser(document);
6037
6050
  var requiredOperationName = operationName(type);
6038
6051
  var usedOperationName = operationName(operation.type);
6039
- __DEV__ ? tsInvariant.invariant(operation.type === type, "Running a " + requiredOperationName + " requires a graphql " +
6040
- (requiredOperationName + ", but a " + usedOperationName + " was used instead.")) : tsInvariant.invariant(operation.type === type, 34);
6052
+ __DEV__ ? tsInvariant.invariant(operation.type === type, "Running a ".concat(requiredOperationName, " requires a graphql ") +
6053
+ "".concat(requiredOperationName, ", but a ").concat(usedOperationName, " was used instead.")) : tsInvariant.invariant(operation.type === type, 34);
6041
6054
  }
6042
6055
 
6043
6056
  function useQuery(query, options) {
6044
6057
  var _a;
6045
6058
  var context = React.useContext(getApolloContext());
6046
6059
  var client = useApolloClient(options === null || options === void 0 ? void 0 : options.client);
6060
+ var defaultWatchQueryOptions = client.defaultOptions.watchQuery;
6047
6061
  verifyDocumentType(query, exports.DocumentType.Query);
6048
6062
  var _b = React.useState(function () {
6049
- var watchQueryOptions = createWatchQueryOptions(query, options);
6063
+ var watchQueryOptions = createWatchQueryOptions(query, options, defaultWatchQueryOptions);
6050
6064
  var obsQuery = null;
6051
6065
  if (context.renderPromises) {
6052
6066
  obsQuery = context.renderPromises.getSSRObservable(watchQueryOptions);
@@ -6062,7 +6076,7 @@ function useQuery(query, options) {
6062
6076
  !(options === null || options === void 0 ? void 0 : options.skip) &&
6063
6077
  obsQuery.getCurrentResult().loading) {
6064
6078
  context.renderPromises.addQueryPromise({
6065
- getOptions: function () { return createWatchQueryOptions(query, options); },
6079
+ getOptions: function () { return createWatchQueryOptions(query, options, defaultWatchQueryOptions); },
6066
6080
  fetchData: function () { return new Promise(function (resolve) {
6067
6081
  var sub = obsQuery.subscribe({
6068
6082
  next: function (result) {
@@ -6103,11 +6117,11 @@ function useQuery(query, options) {
6103
6117
  options: options,
6104
6118
  result: result,
6105
6119
  previousData: void 0,
6106
- watchQueryOptions: createWatchQueryOptions(query, options),
6120
+ watchQueryOptions: createWatchQueryOptions(query, options, defaultWatchQueryOptions),
6107
6121
  });
6108
6122
  React.useEffect(function () {
6109
6123
  var _a, _b;
6110
- var watchQueryOptions = createWatchQueryOptions(query, options);
6124
+ var watchQueryOptions = createWatchQueryOptions(query, options, defaultWatchQueryOptions);
6111
6125
  var nextResult;
6112
6126
  if (ref.current.client !== client || !equality.equal(ref.current.query, query)) {
6113
6127
  var obsQuery_1 = client.watchQuery(watchQueryOptions);
@@ -6126,17 +6140,15 @@ function useQuery(query, options) {
6126
6140
  }
6127
6141
  setResult(ref.current.result = nextResult);
6128
6142
  if (!nextResult.loading && options) {
6129
- if (!result.loading) {
6130
- if (result.error) {
6131
- (_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, result.error);
6132
- }
6133
- else if (result.data) {
6134
- (_b = options.onCompleted) === null || _b === void 0 ? void 0 : _b.call(options, result.data);
6135
- }
6143
+ if (nextResult.error) {
6144
+ (_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, nextResult.error);
6145
+ }
6146
+ else if (nextResult.data) {
6147
+ (_b = options.onCompleted) === null || _b === void 0 ? void 0 : _b.call(options, nextResult.data);
6136
6148
  }
6137
6149
  }
6138
6150
  }
6139
- Object.assign(ref.current, { client: client, query: query, options: options });
6151
+ Object.assign(ref.current, { client: client, query: query });
6140
6152
  }, [obsQuery, client, query, options]);
6141
6153
  React.useEffect(function () {
6142
6154
  if (context.renderPromises) {
@@ -6204,8 +6216,9 @@ function useQuery(query, options) {
6204
6216
  (options === null || options === void 0 ? void 0 : options.ssr) !== false &&
6205
6217
  !(options === null || options === void 0 ? void 0 : options.skip) &&
6206
6218
  result.loading) {
6207
- obsQuery.setOptions(createWatchQueryOptions(query, options)).catch(function () { });
6219
+ obsQuery.setOptions(createWatchQueryOptions(query, options, defaultWatchQueryOptions)).catch(function () { });
6208
6220
  }
6221
+ Object.assign(ref.current, { options: options });
6209
6222
  }
6210
6223
  if ((context.renderPromises || client.disableNetworkFetches) &&
6211
6224
  (options === null || options === void 0 ? void 0 : options.ssr) === false) {
@@ -6235,12 +6248,16 @@ function useQuery(query, options) {
6235
6248
  stopPolling: obsQuery.stopPolling.bind(obsQuery),
6236
6249
  subscribeToMore: obsQuery.subscribeToMore.bind(obsQuery),
6237
6250
  }); }, [obsQuery]);
6238
- return tslib.__assign(tslib.__assign(tslib.__assign({}, obsQueryFields), { variables: obsQuery.variables, client: client, called: true, previousData: ref.current.previousData }), result);
6251
+ return tslib.__assign(tslib.__assign(tslib.__assign({}, obsQueryFields), { variables: createWatchQueryOptions(query, options, defaultWatchQueryOptions).variables, client: client, called: true, previousData: ref.current.previousData }), result);
6239
6252
  }
6240
- function createWatchQueryOptions(query, options) {
6253
+ function createWatchQueryOptions(query, options, defaultOptions) {
6241
6254
  var _a;
6242
6255
  if (options === void 0) { options = {}; }
6243
- var skip = options.skip; options.ssr; options.onCompleted; options.onError; options.displayName; var watchQueryOptions = tslib.__rest(options, ["skip", "ssr", "onCompleted", "onError", "displayName"]);
6256
+ var skip = options.skip; options.ssr; options.onCompleted; options.onError; options.displayName; var otherOptions = tslib.__rest(options, ["skip", "ssr", "onCompleted", "onError", "displayName"]);
6257
+ var watchQueryOptions = tslib.__assign({ query: query }, otherOptions);
6258
+ if (defaultOptions) {
6259
+ watchQueryOptions = mergeOptions(defaultOptions, watchQueryOptions);
6260
+ }
6244
6261
  if (skip) {
6245
6262
  watchQueryOptions.fetchPolicy = 'standby';
6246
6263
  }
@@ -6252,7 +6269,10 @@ function createWatchQueryOptions(query, options) {
6252
6269
  else if (!watchQueryOptions.fetchPolicy) {
6253
6270
  watchQueryOptions.fetchPolicy = 'cache-first';
6254
6271
  }
6255
- return tslib.__assign({ query: query }, watchQueryOptions);
6272
+ if (!watchQueryOptions.variables) {
6273
+ watchQueryOptions.variables = {};
6274
+ }
6275
+ return watchQueryOptions;
6256
6276
  }
6257
6277
 
6258
6278
  var EAGER_METHODS = [
@@ -6265,36 +6285,16 @@ var EAGER_METHODS = [
6265
6285
  function useLazyQuery(query, options) {
6266
6286
  var _a = React.useState({
6267
6287
  called: false,
6268
- resolves: [],
6269
6288
  }), execution = _a[0], setExecution = _a[1];
6270
- var execute = React.useCallback(function (executeOptions) {
6271
- var resolve;
6272
- var promise = new Promise(function (resolve1) { return (resolve = resolve1); });
6273
- setExecution(function (execution) {
6274
- if (execution.called) {
6275
- result && result.refetch(executeOptions === null || executeOptions === void 0 ? void 0 : executeOptions.variables);
6276
- }
6277
- return {
6278
- called: true,
6279
- resolves: tslib.__spreadArray(tslib.__spreadArray([], execution.resolves, true), [resolve], false),
6280
- options: executeOptions,
6281
- };
6282
- });
6283
- return promise;
6284
- }, []);
6285
6289
  var result = useQuery(query, tslib.__assign(tslib.__assign(tslib.__assign({}, options), execution.options), { fetchPolicy: execution.called ? options === null || options === void 0 ? void 0 : options.fetchPolicy : 'standby', skip: undefined }));
6286
- React.useEffect(function () {
6287
- var resolves = execution.resolves;
6288
- if (!result.loading && resolves.length) {
6289
- setExecution(function (execution) { return (tslib.__assign(tslib.__assign({}, execution), { resolves: [] })); });
6290
- resolves.forEach(function (resolve) { return resolve(result); });
6291
- }
6292
- }, [result, execution]);
6293
6290
  if (!execution.called) {
6294
6291
  result = tslib.__assign(tslib.__assign({}, result), { loading: false, data: void 0, error: void 0, called: false });
6292
+ }
6293
+ var eagerMethods = React.useMemo(function () {
6294
+ var eagerMethods = {};
6295
6295
  var _loop_1 = function (key) {
6296
6296
  var method = result[key];
6297
- result[key] = function () {
6297
+ eagerMethods[key] = function () {
6298
6298
  var args = [];
6299
6299
  for (var _i = 0; _i < arguments.length; _i++) {
6300
6300
  args[_i] = arguments[_i];
@@ -6307,7 +6307,20 @@ function useLazyQuery(query, options) {
6307
6307
  var key = EAGER_METHODS_1[_i];
6308
6308
  _loop_1(key);
6309
6309
  }
6310
- }
6310
+ return eagerMethods;
6311
+ }, []);
6312
+ result.error = result.error || void 0;
6313
+ Object.assign(result, eagerMethods);
6314
+ var execute = React.useCallback(function (executeOptions) {
6315
+ setExecution({ called: true, options: executeOptions });
6316
+ var promise = result.refetch(executeOptions === null || executeOptions === void 0 ? void 0 : executeOptions.variables).then(function (result1) {
6317
+ var result2 = tslib.__assign(tslib.__assign({}, result), { data: result1.data, error: result1.error, called: true, loading: false });
6318
+ Object.assign(result2, eagerMethods);
6319
+ return result2;
6320
+ });
6321
+ promise.catch(function () { });
6322
+ return promise;
6323
+ }, []);
6311
6324
  return [execute, result];
6312
6325
  }
6313
6326
 
@@ -6323,79 +6336,73 @@ function useMutation(mutation, options) {
6323
6336
  result: result,
6324
6337
  mutationId: 0,
6325
6338
  isMounted: true,
6326
- execute: null,
6327
6339
  client: client,
6328
6340
  mutation: mutation,
6329
6341
  options: options,
6330
6342
  });
6331
- var execute = React.useMemo(function () {
6332
- if (ref.current.execute != null &&
6333
- ref.current.client === client &&
6334
- equality.equal(options, ref.current.options) &&
6335
- equality.equal(mutation, ref.current.mutation)) {
6336
- return ref.current.execute;
6337
- }
6338
- ref.current.client = client;
6339
- ref.current.options = options;
6340
- ref.current.mutation = mutation;
6341
- ref.current.execute = function (executeOptions) {
6342
- if (executeOptions === void 0) { executeOptions = {}; }
6343
- var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
6344
- if (!ref.current.result.loading && !baseOptions.ignoreResults) {
6345
- setResult(ref.current.result = {
6346
- loading: true,
6347
- error: void 0,
6348
- data: void 0,
6343
+ {
6344
+ Object.assign(ref.current, { client: client, options: options, mutation: mutation });
6345
+ }
6346
+ var execute = React.useCallback(function (executeOptions) {
6347
+ if (executeOptions === void 0) { executeOptions = {}; }
6348
+ var _a = ref.current, client = _a.client, options = _a.options, mutation = _a.mutation;
6349
+ var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
6350
+ if (!ref.current.result.loading && !baseOptions.ignoreResults) {
6351
+ setResult(ref.current.result = {
6352
+ loading: true,
6353
+ error: void 0,
6354
+ data: void 0,
6355
+ called: true,
6356
+ client: client,
6357
+ });
6358
+ }
6359
+ var mutationId = ++ref.current.mutationId;
6360
+ var clientOptions = mergeOptions(baseOptions, executeOptions);
6361
+ return client.mutate(clientOptions).then(function (response) {
6362
+ var _a, _b;
6363
+ var data = response.data, errors = response.errors;
6364
+ var error = errors && errors.length > 0
6365
+ ? new ApolloError({ graphQLErrors: errors })
6366
+ : void 0;
6367
+ if (mutationId === ref.current.mutationId &&
6368
+ !clientOptions.ignoreResults) {
6369
+ var result_1 = {
6349
6370
  called: true,
6371
+ loading: false,
6372
+ data: data,
6373
+ error: error,
6350
6374
  client: client,
6351
- });
6352
- }
6353
- var mutationId = ++ref.current.mutationId;
6354
- var clientOptions = mergeOptions(baseOptions, executeOptions);
6355
- return client.mutate(clientOptions).then(function (response) {
6356
- var _a;
6357
- var data = response.data, errors = response.errors;
6358
- var error = errors && errors.length > 0
6359
- ? new ApolloError({ graphQLErrors: errors })
6360
- : void 0;
6361
- if (mutationId === ref.current.mutationId &&
6362
- !baseOptions.ignoreResults) {
6363
- var result_1 = {
6364
- called: true,
6365
- loading: false,
6366
- data: data,
6367
- error: error,
6368
- client: client,
6369
- };
6370
- if (ref.current.isMounted && !equality.equal(ref.current.result, result_1)) {
6371
- setResult(ref.current.result = result_1);
6372
- }
6373
- }
6374
- (_a = baseOptions.onCompleted) === null || _a === void 0 ? void 0 : _a.call(baseOptions, response.data);
6375
- return response;
6376
- }).catch(function (error) {
6377
- if (mutationId === ref.current.mutationId &&
6378
- ref.current.isMounted) {
6379
- var result_2 = {
6380
- loading: false,
6381
- error: error,
6382
- data: void 0,
6383
- called: true,
6384
- client: client,
6385
- };
6386
- if (!equality.equal(ref.current.result, result_2)) {
6387
- setResult(ref.current.result = result_2);
6388
- }
6375
+ };
6376
+ if (ref.current.isMounted && !equality.equal(ref.current.result, result_1)) {
6377
+ setResult(ref.current.result = result_1);
6389
6378
  }
6390
- if (baseOptions.onError) {
6391
- baseOptions.onError(error);
6392
- return { data: void 0, errors: error };
6379
+ }
6380
+ (_a = baseOptions.onCompleted) === null || _a === void 0 ? void 0 : _a.call(baseOptions, response.data);
6381
+ (_b = executeOptions.onCompleted) === null || _b === void 0 ? void 0 : _b.call(executeOptions, response.data);
6382
+ return response;
6383
+ }).catch(function (error) {
6384
+ var _a, _b;
6385
+ if (mutationId === ref.current.mutationId &&
6386
+ ref.current.isMounted) {
6387
+ var result_2 = {
6388
+ loading: false,
6389
+ error: error,
6390
+ data: void 0,
6391
+ called: true,
6392
+ client: client,
6393
+ };
6394
+ if (!equality.equal(ref.current.result, result_2)) {
6395
+ setResult(ref.current.result = result_2);
6393
6396
  }
6394
- throw error;
6395
- });
6396
- };
6397
- return ref.current.execute;
6398
- }, [client, mutation, options]);
6397
+ }
6398
+ if (baseOptions.onError || clientOptions.onError) {
6399
+ (_a = baseOptions.onError) === null || _a === void 0 ? void 0 : _a.call(baseOptions, error);
6400
+ (_b = executeOptions.onError) === null || _b === void 0 ? void 0 : _b.call(executeOptions, error);
6401
+ return { data: void 0, errors: error };
6402
+ }
6403
+ throw error;
6404
+ });
6405
+ }, []);
6399
6406
  var reset = React.useCallback(function () {
6400
6407
  setResult({ called: false, loading: false, client: client });
6401
6408
  }, []);
@@ -6432,14 +6439,16 @@ function useSubscription(subscription, options) {
6432
6439
  if (typeof shouldResubscribe === 'function') {
6433
6440
  shouldResubscribe = !!shouldResubscribe(options);
6434
6441
  }
6435
- if ((options === null || options === void 0 ? void 0 : options.skip) && !(options === null || options === void 0 ? void 0 : options.skip) !== !((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.skip)) {
6436
- setResult({
6437
- loading: false,
6438
- data: void 0,
6439
- error: void 0,
6440
- variables: options === null || options === void 0 ? void 0 : options.variables,
6441
- });
6442
- setObservable(null);
6442
+ if (options === null || options === void 0 ? void 0 : options.skip) {
6443
+ if (!(options === null || options === void 0 ? void 0 : options.skip) !== !((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.skip)) {
6444
+ setResult({
6445
+ loading: false,
6446
+ data: void 0,
6447
+ error: void 0,
6448
+ variables: options === null || options === void 0 ? void 0 : options.variables,
6449
+ });
6450
+ setObservable(null);
6451
+ }
6443
6452
  }
6444
6453
  else if (shouldResubscribe !== false && (client !== ref.current.client ||
6445
6454
  subscription !== ref.current.subscription ||
@@ -6557,6 +6566,7 @@ exports.parser = parser;
6557
6566
  exports.resetApolloContext = getApolloContext;
6558
6567
  exports.rewriteURIForGET = rewriteURIForGET;
6559
6568
  exports.selectHttpOptionsAndBody = selectHttpOptionsAndBody;
6569
+ exports.selectHttpOptionsAndBodyInternal = selectHttpOptionsAndBodyInternal;
6560
6570
  exports.selectURI = selectURI;
6561
6571
  exports.serializeFetchParameter = serializeFetchParameter;
6562
6572
  exports.split = split;