@apollo/client 3.8.0-alpha.12 → 3.8.0-alpha.13

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 (90) hide show
  1. package/apollo-client.cjs +145 -119
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/core/ObservableQuery.d.ts.map +1 -1
  5. package/core/ObservableQuery.js.map +1 -1
  6. package/core/core.cjs +1 -1
  7. package/core/core.cjs.map +1 -1
  8. package/core/core.cjs.native.js +1 -1
  9. package/invariantErrorCodes.js +29 -34
  10. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  11. package/link/persisted-queries/index.d.ts.map +1 -1
  12. package/link/persisted-queries/index.js +12 -13
  13. package/link/persisted-queries/index.js.map +1 -1
  14. package/link/persisted-queries/persisted-queries.cjs +12 -13
  15. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  16. package/link/persisted-queries/persisted-queries.cjs.native.js +12 -13
  17. package/link/utils/throwServerError.d.ts +1 -1
  18. package/link/utils/throwServerError.d.ts.map +1 -1
  19. package/link/utils/throwServerError.js.map +1 -1
  20. package/package.json +18 -17
  21. package/react/cache/QuerySubscription.d.ts +11 -4
  22. package/react/cache/QuerySubscription.d.ts.map +1 -1
  23. package/react/cache/QuerySubscription.js +52 -34
  24. package/react/cache/QuerySubscription.js.map +1 -1
  25. package/react/context/ApolloConsumer.js +1 -1
  26. package/react/context/ApolloProvider.js +1 -1
  27. package/react/context/context.cjs +2 -2
  28. package/react/context/context.cjs.map +1 -1
  29. package/react/context/context.cjs.native.js +2 -2
  30. package/react/hoc/hoc-utils.js +1 -1
  31. package/react/hoc/hoc.cjs +2 -2
  32. package/react/hoc/hoc.cjs.map +1 -1
  33. package/react/hoc/hoc.cjs.native.js +2 -2
  34. package/react/hoc/withApollo.js +1 -1
  35. package/react/hooks/hooks.cjs +58 -63
  36. package/react/hooks/hooks.cjs.map +1 -1
  37. package/react/hooks/hooks.cjs.native.js +58 -63
  38. package/react/hooks/useApolloClient.js +1 -1
  39. package/react/hooks/useFragment.d.ts +2 -1
  40. package/react/hooks/useFragment.d.ts.map +1 -1
  41. package/react/hooks/useFragment.js.map +1 -1
  42. package/react/hooks/useSubscription.d.ts.map +1 -1
  43. package/react/hooks/useSubscription.js +25 -13
  44. package/react/hooks/useSubscription.js.map +1 -1
  45. package/react/hooks/useSuspenseCache.js +1 -1
  46. package/react/hooks/useSuspenseQuery.d.ts +15 -3
  47. package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
  48. package/react/hooks/useSuspenseQuery.js +34 -52
  49. package/react/hooks/useSuspenseQuery.js.map +1 -1
  50. package/react/parser/index.js +5 -5
  51. package/react/parser/parser.cjs +5 -5
  52. package/react/parser/parser.cjs.map +1 -1
  53. package/react/parser/parser.cjs.native.js +5 -5
  54. package/react/react.cjs +52 -33
  55. package/react/react.cjs.map +1 -1
  56. package/react/react.cjs.native.js +52 -33
  57. package/react/types/types.d.ts +1 -3
  58. package/react/types/types.d.ts.map +1 -1
  59. package/react/types/types.js.map +1 -1
  60. package/testing/core/core.cjs +1 -1
  61. package/testing/core/core.cjs.map +1 -1
  62. package/testing/core/core.cjs.native.js +1 -1
  63. package/testing/core/mocking/mockLink.js +1 -1
  64. package/utilities/graphql/directives.js +4 -4
  65. package/utilities/graphql/fragments.js +3 -3
  66. package/utilities/graphql/getFromAST.js +8 -8
  67. package/utilities/graphql/storeUtils.js +1 -1
  68. package/utilities/index.d.ts +2 -1
  69. package/utilities/index.d.ts.map +1 -1
  70. package/utilities/index.js +1 -1
  71. package/utilities/index.js.map +1 -1
  72. package/utilities/promises/decoration.d.ts +2 -0
  73. package/utilities/promises/decoration.d.ts.map +1 -1
  74. package/utilities/promises/decoration.js +12 -0
  75. package/utilities/promises/decoration.js.map +1 -1
  76. package/utilities/types/DeepOmit.d.ts +4 -3
  77. package/utilities/types/DeepOmit.d.ts.map +1 -1
  78. package/utilities/types/DeepOmit.js.map +1 -1
  79. package/utilities/types/DeepPartial.d.ts +12 -0
  80. package/utilities/types/DeepPartial.d.ts.map +1 -0
  81. package/utilities/types/DeepPartial.js +2 -0
  82. package/utilities/types/DeepPartial.js.map +1 -0
  83. package/utilities/types/Primitive.d.ts +2 -0
  84. package/utilities/types/Primitive.d.ts.map +1 -0
  85. package/utilities/types/Primitive.js +2 -0
  86. package/utilities/types/Primitive.js.map +1 -0
  87. package/utilities/utilities.cjs +30 -16
  88. package/utilities/utilities.cjs.map +1 -1
  89. package/utilities/utilities.cjs.native.js +30 -16
  90. package/version.js +1 -1
@@ -18,7 +18,7 @@ function shouldInclude(_a, variables) {
18
18
  var evaledValue = false;
19
19
  if (ifArgument.value.kind === 'Variable') {
20
20
  evaledValue = variables && variables[ifArgument.value.name.value];
21
- globals.__DEV__ ? globals.invariant(evaledValue !== void 0, "Invalid variable referenced in @".concat(directive.name.value, " directive.")) : globals.invariant(evaledValue !== void 0, 42);
21
+ globals.__DEV__ ? globals.invariant(evaledValue !== void 0, "Invalid variable referenced in @".concat(directive.name.value, " directive.")) : globals.invariant(evaledValue !== void 0, 41);
22
22
  }
23
23
  else {
24
24
  evaledValue = ifArgument.value.value;
@@ -65,13 +65,13 @@ function getInclusionDirectives(directives) {
65
65
  return;
66
66
  var directiveArguments = directive.arguments;
67
67
  var directiveName = directive.name.value;
68
- globals.__DEV__ ? globals.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @".concat(directiveName, " directive.")) : globals.invariant(directiveArguments && directiveArguments.length === 1, 43);
68
+ globals.__DEV__ ? globals.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @".concat(directiveName, " directive.")) : globals.invariant(directiveArguments && directiveArguments.length === 1, 42);
69
69
  var ifArgument = directiveArguments[0];
70
- globals.__DEV__ ? globals.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @".concat(directiveName, " directive.")) : globals.invariant(ifArgument.name && ifArgument.name.value === 'if', 44);
70
+ globals.__DEV__ ? globals.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @".concat(directiveName, " directive.")) : globals.invariant(ifArgument.name && ifArgument.name.value === 'if', 43);
71
71
  var ifValue = ifArgument.value;
72
72
  globals.__DEV__ ? globals.invariant(ifValue &&
73
73
  (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @".concat(directiveName, " directive must be a variable or a boolean value.")) : globals.invariant(ifValue &&
74
- (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 45);
74
+ (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 44);
75
75
  result.push({ directive: directive, ifArgument: ifArgument });
76
76
  });
77
77
  }
@@ -84,14 +84,14 @@ function getFragmentQueryDocument(document, fragmentName) {
84
84
  document.definitions.forEach(function (definition) {
85
85
  if (definition.kind === 'OperationDefinition') {
86
86
  throw globals.__DEV__ ? new globals.InvariantError("Found a ".concat(definition.operation, " operation").concat(definition.name ? " named '".concat(definition.name.value, "'") : '', ". ") +
87
- 'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new globals.InvariantError(46);
87
+ 'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new globals.InvariantError(45);
88
88
  }
89
89
  if (definition.kind === 'FragmentDefinition') {
90
90
  fragments.push(definition);
91
91
  }
92
92
  });
93
93
  if (typeof actualFragmentName === 'undefined') {
94
- globals.__DEV__ ? globals.invariant(fragments.length === 1, "Found ".concat(fragments.length, " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.")) : globals.invariant(fragments.length === 1, 47);
94
+ globals.__DEV__ ? globals.invariant(fragments.length === 1, "Found ".concat(fragments.length, " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.")) : globals.invariant(fragments.length === 1, 46);
95
95
  actualFragmentName = fragments[0].name.value;
96
96
  }
97
97
  var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
@@ -132,7 +132,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
132
132
  return fragmentMap(fragmentName);
133
133
  }
134
134
  var fragment = fragmentMap && fragmentMap[fragmentName];
135
- globals.__DEV__ ? globals.invariant(fragment, "No fragment named ".concat(fragmentName)) : globals.invariant(fragment, 48);
135
+ globals.__DEV__ ? globals.invariant(fragment, "No fragment named ".concat(fragmentName)) : globals.invariant(fragment, 47);
136
136
  return fragment || null;
137
137
  }
138
138
  default:
@@ -222,7 +222,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
222
222
  else {
223
223
  throw globals.__DEV__ ? new globals.InvariantError("The inline argument \"".concat(name.value, "\" of kind \"").concat(value.kind, "\"") +
224
224
  'is not supported. Use variables instead of inline arguments to ' +
225
- 'overcome this limitation.') : new globals.InvariantError(57);
225
+ 'overcome this limitation.') : new globals.InvariantError(56);
226
226
  }
227
227
  }
228
228
  function storeKeyNameFromField(field, variables) {
@@ -357,16 +357,16 @@ function isInlineFragment(selection) {
357
357
  }
358
358
 
359
359
  function checkDocument(doc) {
360
- globals.__DEV__ ? globals.invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : globals.invariant(doc && doc.kind === 'Document', 49);
360
+ globals.__DEV__ ? globals.invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : globals.invariant(doc && doc.kind === 'Document', 48);
361
361
  var operations = doc.definitions
362
362
  .filter(function (d) { return d.kind !== 'FragmentDefinition'; })
363
363
  .map(function (definition) {
364
364
  if (definition.kind !== 'OperationDefinition') {
365
- throw globals.__DEV__ ? new globals.InvariantError("Schema type definitions not allowed in queries. Found: \"".concat(definition.kind, "\"")) : new globals.InvariantError(50);
365
+ throw globals.__DEV__ ? new globals.InvariantError("Schema type definitions not allowed in queries. Found: \"".concat(definition.kind, "\"")) : new globals.InvariantError(49);
366
366
  }
367
367
  return definition;
368
368
  });
369
- globals.__DEV__ ? globals.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains ".concat(operations.length, " operations")) : globals.invariant(operations.length <= 1, 51);
369
+ globals.__DEV__ ? globals.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains ".concat(operations.length, " operations")) : globals.invariant(operations.length <= 1, 50);
370
370
  return doc;
371
371
  }
372
372
  function getOperationDefinition(doc) {
@@ -389,14 +389,14 @@ function getFragmentDefinitions(doc) {
389
389
  }
390
390
  function getQueryDefinition(doc) {
391
391
  var queryDef = getOperationDefinition(doc);
392
- globals.__DEV__ ? globals.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : globals.invariant(queryDef && queryDef.operation === 'query', 52);
392
+ globals.__DEV__ ? globals.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : globals.invariant(queryDef && queryDef.operation === 'query', 51);
393
393
  return queryDef;
394
394
  }
395
395
  function getFragmentDefinition(doc) {
396
- globals.__DEV__ ? globals.invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : globals.invariant(doc.kind === 'Document', 53);
397
- globals.__DEV__ ? globals.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : globals.invariant(doc.definitions.length <= 1, 54);
396
+ globals.__DEV__ ? globals.invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : globals.invariant(doc.kind === 'Document', 52);
397
+ globals.__DEV__ ? globals.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : globals.invariant(doc.definitions.length <= 1, 53);
398
398
  var fragmentDef = doc.definitions[0];
399
- globals.__DEV__ ? globals.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : globals.invariant(fragmentDef.kind === 'FragmentDefinition', 55);
399
+ globals.__DEV__ ? globals.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : globals.invariant(fragmentDef.kind === 'FragmentDefinition', 54);
400
400
  return fragmentDef;
401
401
  }
402
402
  function getMainDefinition(queryDoc) {
@@ -419,7 +419,7 @@ function getMainDefinition(queryDoc) {
419
419
  if (fragmentDefinition) {
420
420
  return fragmentDefinition;
421
421
  }
422
- throw globals.__DEV__ ? new globals.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new globals.InvariantError(56);
422
+ throw globals.__DEV__ ? new globals.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new globals.InvariantError(55);
423
423
  }
424
424
  function getDefaultValues(definition) {
425
425
  var defaultValues = Object.create(null);
@@ -1001,6 +1001,18 @@ function makeEmptyData() {
1001
1001
  };
1002
1002
  }
1003
1003
 
1004
+ function createFulfilledPromise(value) {
1005
+ var promise = Promise.resolve(value);
1006
+ promise.status = 'fulfilled';
1007
+ promise.value = value;
1008
+ return promise;
1009
+ }
1010
+ function createRejectedPromise(reason) {
1011
+ var promise = Promise.reject(reason);
1012
+ promise.status = 'rejected';
1013
+ promise.reason = reason;
1014
+ return promise;
1015
+ }
1004
1016
  function isStatefulPromise(promise) {
1005
1017
  return 'status' in promise;
1006
1018
  }
@@ -1474,6 +1486,8 @@ exports.cloneDeep = cloneDeep;
1474
1486
  exports.compact = compact;
1475
1487
  exports.concatPagination = concatPagination;
1476
1488
  exports.createFragmentMap = createFragmentMap;
1489
+ exports.createFulfilledPromise = createFulfilledPromise;
1490
+ exports.createRejectedPromise = createRejectedPromise;
1477
1491
  exports.fixObservableSubclass = fixObservableSubclass;
1478
1492
  exports.getDefaultValues = getDefaultValues;
1479
1493
  exports.getDirectiveNames = getDirectiveNames;