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

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 (221) hide show
  1. package/apollo-client.cjs +648 -464
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/cache/cache.cjs +2 -0
  5. package/cache/cache.cjs.map +1 -1
  6. package/cache/cache.cjs.native.js +2 -0
  7. package/cache/core/cache.d.ts +1 -0
  8. package/cache/core/cache.d.ts.map +1 -1
  9. package/cache/core/cache.js +1 -0
  10. package/cache/core/cache.js.map +1 -1
  11. package/cache/inmemory/inMemoryCache.d.ts +1 -0
  12. package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
  13. package/cache/inmemory/inMemoryCache.js +1 -0
  14. package/cache/inmemory/inMemoryCache.js.map +1 -1
  15. package/core/ApolloClient.d.ts.map +1 -1
  16. package/core/ApolloClient.js +6 -6
  17. package/core/ApolloClient.js.map +1 -1
  18. package/core/ObservableQuery.d.ts.map +1 -1
  19. package/core/ObservableQuery.js +27 -20
  20. package/core/ObservableQuery.js.map +1 -1
  21. package/core/QueryInfo.d.ts.map +1 -1
  22. package/core/QueryInfo.js.map +1 -1
  23. package/core/QueryManager.d.ts +2 -0
  24. package/core/QueryManager.d.ts.map +1 -1
  25. package/core/QueryManager.js +62 -50
  26. package/core/QueryManager.js.map +1 -1
  27. package/core/core.cjs +180 -91
  28. package/core/core.cjs.map +1 -1
  29. package/core/core.cjs.native.js +180 -91
  30. package/core/equalByQuery.d.ts +4 -0
  31. package/core/equalByQuery.d.ts.map +1 -0
  32. package/{react/hooks/compareResults.js → core/equalByQuery.js} +14 -10
  33. package/core/equalByQuery.js.map +1 -0
  34. package/core/index.d.ts +1 -1
  35. package/core/index.d.ts.map +1 -1
  36. package/core/index.js +1 -1
  37. package/core/index.js.map +1 -1
  38. package/core/networkStatus.d.ts +1 -0
  39. package/core/networkStatus.d.ts.map +1 -1
  40. package/core/networkStatus.js +3 -0
  41. package/core/networkStatus.js.map +1 -1
  42. package/core/types.d.ts +3 -0
  43. package/core/types.d.ts.map +1 -1
  44. package/core/types.js.map +1 -1
  45. package/core/watchQueryOptions.d.ts +0 -1
  46. package/core/watchQueryOptions.d.ts.map +1 -1
  47. package/core/watchQueryOptions.js.map +1 -1
  48. package/errors/errors.cjs +17 -17
  49. package/errors/errors.cjs.map +1 -1
  50. package/errors/errors.cjs.native.js +17 -17
  51. package/errors/index.d.ts +24 -8
  52. package/errors/index.d.ts.map +1 -1
  53. package/errors/index.js +17 -19
  54. package/errors/index.js.map +1 -1
  55. package/invariantErrorCodes.js +35 -30
  56. package/link/batch-http/batch-http.cjs +23 -2
  57. package/link/batch-http/batch-http.cjs.map +1 -1
  58. package/link/batch-http/batch-http.cjs.native.js +23 -2
  59. package/link/batch-http/batchHttpLink.d.ts.map +1 -1
  60. package/link/batch-http/batchHttpLink.js +7 -2
  61. package/link/batch-http/batchHttpLink.js.map +1 -1
  62. package/link/core/types.d.ts +4 -0
  63. package/link/core/types.d.ts.map +1 -1
  64. package/link/core/types.js.map +1 -1
  65. package/link/http/createHttpLink.d.ts.map +1 -1
  66. package/link/http/createHttpLink.js +21 -20
  67. package/link/http/createHttpLink.js.map +1 -1
  68. package/link/http/http.cjs +59 -30
  69. package/link/http/http.cjs.map +1 -1
  70. package/link/http/http.cjs.native.js +59 -30
  71. package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
  72. package/link/http/parseAndCheckHttpResponse.js +34 -14
  73. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  74. package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
  75. package/link/http/selectHttpOptionsAndBody.js +2 -1
  76. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  77. package/link/subscriptions/index.d.ts.map +1 -1
  78. package/link/subscriptions/index.js +10 -5
  79. package/link/subscriptions/index.js.map +1 -1
  80. package/link/subscriptions/subscriptions.cjs +9 -4
  81. package/link/subscriptions/subscriptions.cjs.map +1 -1
  82. package/link/subscriptions/subscriptions.cjs.native.js +9 -4
  83. package/link/utils/filterOperationVariables.d.ts +5 -0
  84. package/link/utils/filterOperationVariables.d.ts.map +1 -0
  85. package/link/utils/filterOperationVariables.js +18 -0
  86. package/link/utils/filterOperationVariables.js.map +1 -0
  87. package/link/utils/index.d.ts +1 -0
  88. package/link/utils/index.d.ts.map +1 -1
  89. package/link/utils/index.js +1 -0
  90. package/link/utils/index.js.map +1 -1
  91. package/link/utils/utils.cjs +18 -0
  92. package/link/utils/utils.cjs.map +1 -1
  93. package/link/utils/utils.cjs.native.js +18 -0
  94. package/package.json +18 -18
  95. package/react/cache/QuerySubscription.d.ts +26 -0
  96. package/react/cache/QuerySubscription.d.ts.map +1 -0
  97. package/react/cache/QuerySubscription.js +88 -0
  98. package/react/cache/QuerySubscription.js.map +1 -0
  99. package/react/cache/SuspenseCache.d.ts +10 -13
  100. package/react/cache/SuspenseCache.d.ts.map +1 -1
  101. package/react/cache/SuspenseCache.js +17 -41
  102. package/react/cache/SuspenseCache.js.map +1 -1
  103. package/react/context/ApolloConsumer.js +1 -1
  104. package/react/context/ApolloProvider.js +1 -1
  105. package/react/context/context.cjs +2 -2
  106. package/react/context/context.cjs.map +1 -1
  107. package/react/context/context.cjs.native.js +2 -2
  108. package/react/hoc/hoc-utils.js +1 -1
  109. package/react/hoc/hoc.cjs +2 -2
  110. package/react/hoc/hoc.cjs.map +1 -1
  111. package/react/hoc/hoc.cjs.native.js +2 -2
  112. package/react/hoc/withApollo.js +1 -1
  113. package/react/hooks/hooks.cjs +135 -202
  114. package/react/hooks/hooks.cjs.map +1 -1
  115. package/react/hooks/hooks.cjs.native.js +135 -202
  116. package/react/hooks/internal/__use.d.ts +4 -0
  117. package/react/hooks/internal/__use.d.ts.map +1 -0
  118. package/react/hooks/internal/__use.js +17 -0
  119. package/react/hooks/internal/__use.js.map +1 -0
  120. package/react/hooks/internal/index.d.ts +2 -0
  121. package/react/hooks/internal/index.d.ts.map +1 -1
  122. package/react/hooks/internal/index.js +2 -0
  123. package/react/hooks/internal/index.js.map +1 -1
  124. package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +1 -1
  125. package/react/hooks/internal/useIsomorphicLayoutEffect.js +2 -2
  126. package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
  127. package/react/hooks/internal/useStrictModeSafeCleanupEffect.d.ts +2 -0
  128. package/react/hooks/internal/useStrictModeSafeCleanupEffect.d.ts.map +1 -0
  129. package/react/hooks/internal/useStrictModeSafeCleanupEffect.js +11 -0
  130. package/react/hooks/internal/useStrictModeSafeCleanupEffect.js.map +1 -0
  131. package/react/hooks/useApolloClient.js +1 -1
  132. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  133. package/react/hooks/useLazyQuery.js +13 -22
  134. package/react/hooks/useLazyQuery.js.map +1 -1
  135. package/react/hooks/useQuery.d.ts +3 -3
  136. package/react/hooks/useQuery.d.ts.map +1 -1
  137. package/react/hooks/useQuery.js +26 -25
  138. package/react/hooks/useQuery.js.map +1 -1
  139. package/react/hooks/useSuspenseCache.js +1 -1
  140. package/react/hooks/useSuspenseQuery.d.ts +7 -2
  141. package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
  142. package/react/hooks/useSuspenseQuery.js +70 -153
  143. package/react/hooks/useSuspenseQuery.js.map +1 -1
  144. package/react/index.d.ts +1 -1
  145. package/react/index.d.ts.map +1 -1
  146. package/react/index.js +1 -1
  147. package/react/index.js.map +1 -1
  148. package/react/parser/index.js +5 -5
  149. package/react/parser/parser.cjs +5 -5
  150. package/react/parser/parser.cjs.map +1 -1
  151. package/react/parser/parser.cjs.native.js +5 -5
  152. package/react/react.cjs +98 -39
  153. package/react/react.cjs.map +1 -1
  154. package/react/react.cjs.native.js +98 -39
  155. package/react/types/types.d.ts +1 -2
  156. package/react/types/types.d.ts.map +1 -1
  157. package/react/types/types.js.map +1 -1
  158. package/testing/core/core.cjs +1 -1
  159. package/testing/core/core.cjs.map +1 -1
  160. package/testing/core/core.cjs.native.js +1 -1
  161. package/testing/core/mocking/mockLink.js +1 -1
  162. package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
  163. package/testing/react/MockedProvider.d.ts +1 -1
  164. package/testing/react/MockedProvider.d.ts.map +1 -1
  165. package/testing/react/MockedProvider.js +7 -6
  166. package/testing/react/MockedProvider.js.map +1 -1
  167. package/testing/testing.cjs +7 -51
  168. package/testing/testing.cjs.map +1 -1
  169. package/testing/testing.cjs.native.js +7 -51
  170. package/utilities/common/incrementalResult.d.ts +2 -1
  171. package/utilities/common/incrementalResult.d.ts.map +1 -1
  172. package/utilities/common/incrementalResult.js +4 -0
  173. package/utilities/common/incrementalResult.js.map +1 -1
  174. package/utilities/common/mergeOptions.d.ts +1 -1
  175. package/utilities/common/mergeOptions.d.ts.map +1 -1
  176. package/utilities/common/mergeOptions.js +1 -1
  177. package/utilities/common/mergeOptions.js.map +1 -1
  178. package/utilities/common/objects.d.ts +1 -0
  179. package/utilities/common/objects.d.ts.map +1 -1
  180. package/utilities/common/objects.js +6 -0
  181. package/utilities/common/objects.js.map +1 -1
  182. package/utilities/common/omitDeep.d.ts +3 -0
  183. package/utilities/common/omitDeep.d.ts.map +1 -0
  184. package/utilities/common/omitDeep.js +42 -0
  185. package/utilities/common/omitDeep.js.map +1 -0
  186. package/utilities/common/stripTypename.d.ts +2 -0
  187. package/utilities/common/stripTypename.d.ts.map +1 -0
  188. package/utilities/common/stripTypename.js +5 -0
  189. package/utilities/common/stripTypename.js.map +1 -0
  190. package/utilities/graphql/directives.js +4 -4
  191. package/utilities/graphql/fragments.js +3 -3
  192. package/utilities/graphql/getFromAST.js +8 -8
  193. package/utilities/graphql/storeUtils.d.ts.map +1 -1
  194. package/utilities/graphql/storeUtils.js +2 -1
  195. package/utilities/graphql/storeUtils.js.map +1 -1
  196. package/utilities/graphql/transform.d.ts.map +1 -1
  197. package/utilities/graphql/transform.js +26 -16
  198. package/utilities/graphql/transform.js.map +1 -1
  199. package/utilities/index.d.ts +4 -0
  200. package/utilities/index.d.ts.map +1 -1
  201. package/utilities/index.js +3 -0
  202. package/utilities/index.js.map +1 -1
  203. package/utilities/promises/decoration.d.ts +15 -0
  204. package/utilities/promises/decoration.d.ts.map +1 -0
  205. package/utilities/promises/decoration.js +25 -0
  206. package/utilities/promises/decoration.js.map +1 -0
  207. package/utilities/types/DeepOmit.d.ts +9 -0
  208. package/utilities/types/DeepOmit.d.ts.map +1 -0
  209. package/utilities/types/DeepOmit.js +2 -0
  210. package/utilities/types/DeepOmit.js.map +1 -0
  211. package/utilities/utilities.cjs +128 -32
  212. package/utilities/utilities.cjs.map +1 -1
  213. package/utilities/utilities.cjs.native.js +128 -32
  214. package/version.js +1 -1
  215. package/cache/inmemory/__mocks__/optimism.d.ts +0 -2
  216. package/cache/inmemory/__mocks__/optimism.d.ts.map +0 -1
  217. package/cache/inmemory/__mocks__/optimism.js +0 -14
  218. package/cache/inmemory/__mocks__/optimism.js.map +0 -1
  219. package/react/hooks/compareResults.d.ts +0 -3
  220. package/react/hooks/compareResults.d.ts.map +0 -1
  221. package/react/hooks/compareResults.js.map +0 -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, 41);
21
+ globals.__DEV__ ? globals.invariant(evaledValue !== void 0, "Invalid variable referenced in @".concat(directive.name.value, " directive.")) : globals.invariant(evaledValue !== void 0, 42);
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, 42);
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);
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', 43);
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);
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'), 44);
74
+ (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 45);
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(45);
87
+ 'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new globals.InvariantError(46);
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, 46);
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);
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, 47);
135
+ globals.__DEV__ ? globals.invariant(fragment, "No fragment named ".concat(fragmentName)) : globals.invariant(fragment, 48);
136
136
  return fragment || null;
137
137
  }
138
138
  default:
@@ -143,6 +143,12 @@ function getFragmentFromSelection(selection, fragmentMap) {
143
143
  function isNonNullObject(obj) {
144
144
  return obj !== null && typeof obj === 'object';
145
145
  }
146
+ function isPlainObject(obj) {
147
+ return (obj !== null &&
148
+ typeof obj === 'object' &&
149
+ (Object.getPrototypeOf(obj) === Object.prototype ||
150
+ Object.getPrototypeOf(obj) === null));
151
+ }
146
152
 
147
153
  function makeReference(id) {
148
154
  return { __ref: String(id) };
@@ -216,7 +222,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
216
222
  else {
217
223
  throw globals.__DEV__ ? new globals.InvariantError("The inline argument \"".concat(name.value, "\" of kind \"").concat(value.kind, "\"") +
218
224
  'is not supported. Use variables instead of inline arguments to ' +
219
- 'overcome this limitation.') : new globals.InvariantError(56);
225
+ 'overcome this limitation.') : new globals.InvariantError(57);
220
226
  }
221
227
  }
222
228
  function storeKeyNameFromField(field, variables) {
@@ -250,6 +256,7 @@ var KNOWN_DIRECTIVES = [
250
256
  'client',
251
257
  'rest',
252
258
  'export',
259
+ 'nonreactive',
253
260
  ];
254
261
  var getStoreKeyName = Object.assign(function (fieldName, args, directives) {
255
262
  if (args &&
@@ -350,16 +357,16 @@ function isInlineFragment(selection) {
350
357
  }
351
358
 
352
359
  function checkDocument(doc) {
353
- 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);
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);
354
361
  var operations = doc.definitions
355
362
  .filter(function (d) { return d.kind !== 'FragmentDefinition'; })
356
363
  .map(function (definition) {
357
364
  if (definition.kind !== 'OperationDefinition') {
358
- throw globals.__DEV__ ? new globals.InvariantError("Schema type definitions not allowed in queries. Found: \"".concat(definition.kind, "\"")) : new globals.InvariantError(49);
365
+ throw globals.__DEV__ ? new globals.InvariantError("Schema type definitions not allowed in queries. Found: \"".concat(definition.kind, "\"")) : new globals.InvariantError(50);
359
366
  }
360
367
  return definition;
361
368
  });
362
- globals.__DEV__ ? globals.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains ".concat(operations.length, " operations")) : globals.invariant(operations.length <= 1, 50);
369
+ globals.__DEV__ ? globals.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains ".concat(operations.length, " operations")) : globals.invariant(operations.length <= 1, 51);
363
370
  return doc;
364
371
  }
365
372
  function getOperationDefinition(doc) {
@@ -382,14 +389,14 @@ function getFragmentDefinitions(doc) {
382
389
  }
383
390
  function getQueryDefinition(doc) {
384
391
  var queryDef = getOperationDefinition(doc);
385
- globals.__DEV__ ? globals.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : globals.invariant(queryDef && queryDef.operation === 'query', 51);
392
+ globals.__DEV__ ? globals.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : globals.invariant(queryDef && queryDef.operation === 'query', 52);
386
393
  return queryDef;
387
394
  }
388
395
  function getFragmentDefinition(doc) {
389
- 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);
390
- globals.__DEV__ ? globals.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : globals.invariant(doc.definitions.length <= 1, 53);
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);
391
398
  var fragmentDef = doc.definitions[0];
392
- globals.__DEV__ ? globals.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : globals.invariant(fragmentDef.kind === 'FragmentDefinition', 54);
399
+ globals.__DEV__ ? globals.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : globals.invariant(fragmentDef.kind === 'FragmentDefinition', 55);
393
400
  return fragmentDef;
394
401
  }
395
402
  function getMainDefinition(queryDoc) {
@@ -412,7 +419,7 @@ function getMainDefinition(queryDoc) {
412
419
  if (fragmentDefinition) {
413
420
  return fragmentDefinition;
414
421
  }
415
- throw globals.__DEV__ ? new globals.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new globals.InvariantError(55);
422
+ throw globals.__DEV__ ? new globals.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new globals.InvariantError(56);
416
423
  }
417
424
  function getDefaultValues(definition) {
418
425
  var defaultValues = Object.create(null);
@@ -448,19 +455,30 @@ function nullIfDocIsEmpty(doc) {
448
455
  ? null
449
456
  : doc;
450
457
  }
451
- function getDirectiveMatcher(directives) {
452
- var nameSet = new Set();
453
- var tests = [];
454
- directives.forEach(function (directive) {
455
- if (directive.name) {
456
- nameSet.add(directive.name);
457
- }
458
- else if (directive.test) {
459
- tests.push(directive.test);
458
+ function getDirectiveMatcher(configs) {
459
+ var names = new Map();
460
+ var tests = new Map();
461
+ configs.forEach(function (directive) {
462
+ if (directive) {
463
+ if (directive.name) {
464
+ names.set(directive.name, directive);
465
+ }
466
+ else if (directive.test) {
467
+ tests.set(directive.test, directive);
468
+ }
460
469
  }
461
470
  });
462
- return function (directive) { return (nameSet.has(directive.name.value) ||
463
- tests.some(function (test) { return test(directive); })); };
471
+ return function (directive) {
472
+ var config = names.get(directive.name.value);
473
+ if (!config && tests.size) {
474
+ tests.forEach(function (testConfig, test) {
475
+ if (test(directive)) {
476
+ config = testConfig;
477
+ }
478
+ });
479
+ }
480
+ return config;
481
+ };
464
482
  }
465
483
  function makeInUseGetterFunction(defaultKey) {
466
484
  var map = new Map();
@@ -477,6 +495,7 @@ function makeInUseGetterFunction(defaultKey) {
477
495
  };
478
496
  }
479
497
  function removeDirectivesFromDocument(directives, doc) {
498
+ checkDocument(doc);
480
499
  var getInUseByOperationName = makeInUseGetterFunction("");
481
500
  var getInUseByFragmentName = makeInUseGetterFunction("");
482
501
  var getInUse = function (ancestors) {
@@ -500,10 +519,8 @@ function removeDirectivesFromDocument(directives, doc) {
500
519
  }
501
520
  }
502
521
  var directiveMatcher = getDirectiveMatcher(directives);
503
- var hasRemoveDirective = directives.some(function (directive) { return directive.remove; });
504
- var shouldRemoveField = function (nodeDirectives) { return (hasRemoveDirective &&
505
- nodeDirectives &&
506
- nodeDirectives.some(directiveMatcher)); };
522
+ var shouldRemoveField = function (nodeDirectives) { return (isNonEmptyArray(nodeDirectives) &&
523
+ nodeDirectives.map(directiveMatcher).some(function (config) { return config && config.remove; })); };
507
524
  var originalFragmentDefsByPath = new Map();
508
525
  var firstVisitMadeChanges = false;
509
526
  var fieldOrInlineFragmentVisitor = {
@@ -984,6 +1001,31 @@ function makeEmptyData() {
984
1001
  };
985
1002
  }
986
1003
 
1004
+ function isStatefulPromise(promise) {
1005
+ return 'status' in promise;
1006
+ }
1007
+ function wrapPromiseWithState(promise) {
1008
+ if (isStatefulPromise(promise)) {
1009
+ return promise;
1010
+ }
1011
+ var pendingPromise = promise;
1012
+ pendingPromise.status = 'pending';
1013
+ pendingPromise.then(function (value) {
1014
+ if (pendingPromise.status === 'pending') {
1015
+ var fulfilledPromise = pendingPromise;
1016
+ fulfilledPromise.status = 'fulfilled';
1017
+ fulfilledPromise.value = value;
1018
+ }
1019
+ }, function (reason) {
1020
+ if (pendingPromise.status === 'pending') {
1021
+ var rejectedPromise = pendingPromise;
1022
+ rejectedPromise.status = 'rejected';
1023
+ rejectedPromise.reason = reason;
1024
+ }
1025
+ });
1026
+ return promise;
1027
+ }
1028
+
987
1029
  var toString = Object.prototype.toString;
988
1030
  function cloneDeep(value) {
989
1031
  return cloneDeepHelper(value);
@@ -1266,6 +1308,9 @@ function isExecutionPatchResult(value) {
1266
1308
  return (isExecutionPatchIncrementalResult(value) ||
1267
1309
  isExecutionPatchInitialResult(value));
1268
1310
  }
1311
+ function isApolloPayloadResult(value) {
1312
+ return isNonNullObject(value) && "payload" in value;
1313
+ }
1269
1314
  function mergeIncrementalData(prevResult, result) {
1270
1315
  var mergedData = prevResult;
1271
1316
  var merger = new DeepMerger();
@@ -1340,7 +1385,7 @@ function stringifyForDisplay(value) {
1340
1385
 
1341
1386
  function mergeOptions(defaults, options) {
1342
1387
  return compact(defaults, options, options.variables && {
1343
- variables: tslib.__assign(tslib.__assign({}, (defaults && defaults.variables)), options.variables),
1388
+ variables: compact(tslib.__assign(tslib.__assign({}, (defaults && defaults.variables)), options.variables)),
1344
1389
  });
1345
1390
  }
1346
1391
 
@@ -1364,6 +1409,51 @@ function isNodeReadableStream(value) {
1364
1409
  return !!value.pipe;
1365
1410
  }
1366
1411
 
1412
+ function omitDeep(value, key) {
1413
+ return __omitDeep(value, key);
1414
+ }
1415
+ function __omitDeep(value, key, known) {
1416
+ if (known === void 0) { known = new Map(); }
1417
+ if (known.has(value)) {
1418
+ return known.get(value);
1419
+ }
1420
+ var modified = false;
1421
+ if (Array.isArray(value)) {
1422
+ var array_1 = [];
1423
+ known.set(value, array_1);
1424
+ value.forEach(function (value, index) {
1425
+ var result = __omitDeep(value, key, known);
1426
+ modified || (modified = result !== value);
1427
+ array_1[index] = result;
1428
+ });
1429
+ if (modified) {
1430
+ return array_1;
1431
+ }
1432
+ }
1433
+ else if (isPlainObject(value)) {
1434
+ var obj_1 = Object.create(Object.getPrototypeOf(value));
1435
+ known.set(value, obj_1);
1436
+ Object.keys(value).forEach(function (k) {
1437
+ if (k === key) {
1438
+ modified = true;
1439
+ }
1440
+ else {
1441
+ var result = __omitDeep(value[k], key, known);
1442
+ modified || (modified = result !== value[k]);
1443
+ obj_1[k] = result;
1444
+ }
1445
+ });
1446
+ if (modified) {
1447
+ return obj_1;
1448
+ }
1449
+ }
1450
+ return value;
1451
+ }
1452
+
1453
+ function stripTypename(value) {
1454
+ return omitDeep(value, '__typename');
1455
+ }
1456
+
1367
1457
  exports.DEV = globals.DEV;
1368
1458
  exports.maybe = globals.maybe;
1369
1459
  exports.Observable = zenObservableTs.Observable;
@@ -1404,6 +1494,7 @@ exports.hasAllDirectives = hasAllDirectives;
1404
1494
  exports.hasAnyDirectives = hasAnyDirectives;
1405
1495
  exports.hasClientExports = hasClientExports;
1406
1496
  exports.hasDirectives = hasDirectives;
1497
+ exports.isApolloPayloadResult = isApolloPayloadResult;
1407
1498
  exports.isArray = isArray;
1408
1499
  exports.isAsyncIterableIterator = isAsyncIterableIterator;
1409
1500
  exports.isBlob = isBlob;
@@ -1417,8 +1508,10 @@ exports.isNodeReadableStream = isNodeReadableStream;
1417
1508
  exports.isNodeResponse = isNodeResponse;
1418
1509
  exports.isNonEmptyArray = isNonEmptyArray;
1419
1510
  exports.isNonNullObject = isNonNullObject;
1511
+ exports.isPlainObject = isPlainObject;
1420
1512
  exports.isReadableStream = isReadableStream;
1421
1513
  exports.isReference = isReference;
1514
+ exports.isStatefulPromise = isStatefulPromise;
1422
1515
  exports.isStreamableBlob = isStreamableBlob;
1423
1516
  exports.iterateObserversSafely = iterateObserversSafely;
1424
1517
  exports.makeReference = makeReference;
@@ -1429,6 +1522,7 @@ exports.mergeDeepArray = mergeDeepArray;
1429
1522
  exports.mergeIncrementalData = mergeIncrementalData;
1430
1523
  exports.mergeOptions = mergeOptions;
1431
1524
  exports.offsetLimitPagination = offsetLimitPagination;
1525
+ exports.omitDeep = omitDeep;
1432
1526
  exports.relayStylePagination = relayStylePagination;
1433
1527
  exports.removeArgumentsFromDocument = removeArgumentsFromDocument;
1434
1528
  exports.removeClientSetsFromDocument = removeClientSetsFromDocument;
@@ -1439,5 +1533,7 @@ exports.resultKeyNameFromField = resultKeyNameFromField;
1439
1533
  exports.shouldInclude = shouldInclude;
1440
1534
  exports.storeKeyNameFromField = storeKeyNameFromField;
1441
1535
  exports.stringifyForDisplay = stringifyForDisplay;
1536
+ exports.stripTypename = stripTypename;
1442
1537
  exports.valueToObjectRepresentation = valueToObjectRepresentation;
1538
+ exports.wrapPromiseWithState = wrapPromiseWithState;
1443
1539
  //# sourceMappingURL=utilities.cjs.map
package/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export var version = '3.8.0-alpha.10';
1
+ export var version = '3.8.0-alpha.12';
2
2
  //# sourceMappingURL=version.js.map
@@ -1,2 +0,0 @@
1
- declare const optimism: any;
2
- //# sourceMappingURL=optimism.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"optimism.d.ts","sourceRoot":"","sources":["../../../../src/cache/inmemory/__mocks__/optimism.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,QAAQ,KAAiC,CAAC"}
@@ -1,14 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var optimism = jest.requireActual('optimism');
13
- module.exports = __assign(__assign({}, optimism), { wrap: jest.fn(optimism.wrap) });
14
- //# sourceMappingURL=optimism.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"optimism.js","sourceRoot":"","sources":["../../../../src/cache/inmemory/__mocks__/optimism.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,IAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AAChD,MAAM,CAAC,OAAO,yBACT,QAAQ,KACX,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,GAC7B,CAAC","sourcesContent":["const optimism = jest.requireActual('optimism');\nmodule.exports = {\n ...optimism,\n wrap: jest.fn(optimism.wrap),\n};\n"]}
@@ -1,3 +0,0 @@
1
- import { DocumentNode } from "graphql";
2
- export declare function compareResultsUsingQuery(query: DocumentNode, aResult: any, bResult: any, variables?: Record<string, any> | undefined): boolean;
3
- //# sourceMappingURL=compareResults.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compareResults.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/compareResults.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,YAAY,EAOb,MAAM,SAAS,CAAC;AAejB,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,GAAG,EACZ,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,GAC1C,OAAO,CAWT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"compareResults.js","sourceRoot":"","sources":["../../../src/react/hooks/compareResults.ts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U,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;AACrF,CAAC;AAED,SAAS,sBAAsB,CAAC,GAAkB;IAChD,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,aAAa,CAAC;AAC1C,CAAC","sourcesContent":["import equal from \"@wry/equality\";\n\nimport {\n DirectiveNode,\n DocumentNode,\n FieldNode,\n FragmentDefinitionNode,\n FragmentSpreadNode,\n InlineFragmentNode,\n SelectionNode,\n SelectionSetNode,\n} from \"graphql\";\n\nimport {\n createFragmentMap,\n FragmentMap,\n getFragmentDefinitions,\n getFragmentFromSelection,\n getMainDefinition,\n isField,\n resultKeyNameFromField,\n shouldInclude,\n} from \"../../utilities\";\n\n// Returns true if aResult and bResult are deeply equal according to the fields\n// selected by the given query, ignoring any fields marked as @nonreactive.\nexport function compareResultsUsingQuery(\n query: DocumentNode,\n aResult: any,\n bResult: any,\n variables?: Record<string, any> | undefined,\n): boolean {\n if (aResult === bResult) return true;\n return compareResultsUsingSelectionSet(\n getMainDefinition(query).selectionSet,\n aResult,\n bResult,\n {\n fragmentMap: createFragmentMap(getFragmentDefinitions(query)),\n variables,\n },\n );\n}\n\n// Encapsulates the information used by compareResultsUsingSelectionSet that\n// does not change during the recursion.\ninterface CompareContext {\n fragmentMap: FragmentMap;\n variables: Record<string, any> | undefined;\n}\n\nfunction compareResultsUsingSelectionSet(\n selectionSet: SelectionSetNode,\n aResult: any,\n bResult: any,\n context: CompareContext,\n): boolean {\n const seenSelections = new Set<SelectionNode>();\n\n // Returning true from this Array.prototype.every callback function skips the\n // current field/subtree. Returning false aborts the entire traversal\n // immediately, causing compareResultsUsingSelectionSet to return false.\n return selectionSet.selections.every(selection => {\n // Avoid re-processing the same selection at the same level of recursion, in\n // case the same field gets included via multiple indirect fragment spreads.\n if (seenSelections.has(selection)) return true;\n seenSelections.add(selection);\n\n // Ignore @skip(if: true) and @include(if: false) fields.\n if (!shouldInclude(selection, context.variables)) return true;\n\n // If the field or (named) fragment spread has a @nonreactive directive on\n // it, we don't care if it's different, so we pretend it's the same.\n if (selectionHasNonreactiveDirective(selection)) return true;\n\n if (isField(selection)) {\n const resultKey = resultKeyNameFromField(selection);\n const aResultChild = aResult && aResult[resultKey];\n const bResultChild = bResult && bResult[resultKey];\n const childSelectionSet = selection.selectionSet;\n\n if (!childSelectionSet) {\n // These are scalar values, so we can compare them with deep equal\n // without redoing the main recursive work.\n return equal(aResultChild, bResultChild);\n }\n\n const aChildIsArray = Array.isArray(aResultChild);\n const bChildIsArray = Array.isArray(bResultChild);\n if (aChildIsArray !== bChildIsArray) return false;\n if (aChildIsArray && bChildIsArray) {\n const length = aResultChild.length;\n if (bResultChild.length !== length) {\n return false;\n }\n for (let i = 0; i < length; ++i) {\n if (!compareResultsUsingSelectionSet(\n childSelectionSet,\n aResultChild[i],\n bResultChild[i],\n context,\n )) {\n return false;\n }\n }\n return true;\n }\n\n return compareResultsUsingSelectionSet(\n childSelectionSet,\n aResultChild,\n bResultChild,\n context,\n );\n\n } else {\n const fragment = getFragmentFromSelection(selection, context.fragmentMap);\n if (fragment) {\n // The fragment might === selection if it's an inline fragment, but\n // could be !== if it's a named fragment ...spread.\n if (selectionHasNonreactiveDirective(fragment)) return true;\n\n return compareResultsUsingSelectionSet(\n fragment.selectionSet,\n // Notice that we reuse the same aResult and bResult values here,\n // since the fragment ...spread does not specify a field name, but\n // consists of multiple fields (within the fragment's selection set)\n // that should be applied to the current result value(s).\n aResult,\n bResult,\n context,\n );\n }\n }\n });\n}\n\nfunction selectionHasNonreactiveDirective(selection:\n | FieldNode\n | InlineFragmentNode\n | FragmentSpreadNode\n | FragmentDefinitionNode,\n): boolean {\n return !!selection.directives && selection.directives.some(directiveIsNonreactive);\n}\n\nfunction directiveIsNonreactive(dir: DirectiveNode): boolean {\n return dir.name.value === \"nonreactive\";\n}\n"]}