@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterOperationVariables.js","sourceRoot":"","sources":["../../../src/link/utils/filterOperationVariables.ts"],"names":[],"mappings":";AAAA,OAAO,EAA0B,KAAK,EAAE,MAAM,SAAS,CAAC;AAIxD,MAAM,UAAU,wBAAwB,CAAC,SAA8B,EAAE,SAAoB;IAC3F,IAAM,MAAM,gBAAQ,SAAS,CAAE,CAAC;IAChC,IAAM,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACpD,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE;QACrB,QAAQ,YAAC,IAAI,EAAE,IAAI,EAAE,MAAM;YAKzB,IAAI,MAAM,IAAK,MAAiC,CAAC,IAAI,KAAK,oBAAoB,EAAE;gBAC9E,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACrC;QACH,CAAC;KACF,CAAC,CAAC;IACH,WAAW,CAAC,OAAO,CAAC,UAAA,IAAI;QACtB,OAAO,MAAO,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { VariableDefinitionNode, visit } from \"graphql\";\n\nimport { Operation } from \"../core\";\n\nexport function filterOperationVariables(variables: Record<string, any>, operation: Operation) {\n const result = { ...variables };\n const unusedNames = new Set(Object.keys(variables));\n visit(operation.query, {\n Variable(node, _key, parent) {\n // A variable type definition at the top level of a query is not\n // enough to silence server-side errors about the variable being\n // unused, so variable definitions do not count as usage.\n // https://spec.graphql.org/draft/#sec-All-Variables-Used\n if (parent && (parent as VariableDefinitionNode).kind !== 'VariableDefinition') {\n unusedNames.delete(node.name.value);\n }\n },\n });\n unusedNames.forEach(name => {\n delete result![name];\n });\n return result;\n}\n"]}
@@ -6,4 +6,5 @@ export { ServerError, throwServerError } from './throwServerError';
6
6
  export { validateOperation } from './validateOperation';
7
7
  export { createOperation } from './createOperation';
8
8
  export { transformOperation } from './transformOperation';
9
+ export { filterOperationVariables } from './filterOperationVariables';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/link/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/link/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -6,4 +6,5 @@ export { throwServerError } from "./throwServerError.js";
6
6
  export { validateOperation } from "./validateOperation.js";
7
7
  export { createOperation } from "./createOperation.js";
8
8
  export { transformOperation } from "./transformOperation.js";
9
+ export { filterOperationVariables } from "./filterOperationVariables.js";
9
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAe,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["import '../../utilities/globals';\n\nexport { fromError } from './fromError';\nexport { toPromise } from './toPromise';\nexport { fromPromise } from './fromPromise';\nexport { ServerError, throwServerError } from './throwServerError';\nexport { validateOperation } from './validateOperation';\nexport { createOperation } from './createOperation';\nexport { transformOperation } from './transformOperation';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAe,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC","sourcesContent":["import '../../utilities/globals';\n\nexport { fromError } from './fromError';\nexport { toPromise } from './toPromise';\nexport { fromPromise } from './fromPromise';\nexport { ServerError, throwServerError } from './throwServerError';\nexport { validateOperation } from './validateOperation';\nexport { createOperation } from './createOperation';\nexport { transformOperation } from './transformOperation';\nexport { filterOperationVariables } from './filterOperationVariables';\n"]}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var globals = require('../../utilities/globals');
6
6
  var utilities = require('../../utilities');
7
7
  var tslib = require('tslib');
8
+ var graphql = require('graphql');
8
9
 
9
10
  function fromError(errorValue) {
10
11
  return new utilities.Observable(function (observer) {
@@ -105,7 +106,24 @@ function transformOperation(operation) {
105
106
  return transformedOperation;
106
107
  }
107
108
 
109
+ function filterOperationVariables(variables, operation) {
110
+ var result = tslib.__assign({}, variables);
111
+ var unusedNames = new Set(Object.keys(variables));
112
+ graphql.visit(operation.query, {
113
+ Variable: function (node, _key, parent) {
114
+ if (parent && parent.kind !== 'VariableDefinition') {
115
+ unusedNames.delete(node.name.value);
116
+ }
117
+ },
118
+ });
119
+ unusedNames.forEach(function (name) {
120
+ delete result[name];
121
+ });
122
+ return result;
123
+ }
124
+
108
125
  exports.createOperation = createOperation;
126
+ exports.filterOperationVariables = filterOperationVariables;
109
127
  exports.fromError = fromError;
110
128
  exports.fromPromise = fromPromise;
111
129
  exports.throwServerError = throwServerError;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","sources":["fromError.js","toPromise.js","fromPromise.js","throwServerError.js","validateOperation.js","createOperation.js","transformOperation.js"],"sourcesContent":["import { Observable } from '../../utilities';\nexport function fromError(errorValue) {\n return new Observable(function (observer) {\n observer.error(errorValue);\n });\n}\n//# sourceMappingURL=fromError.js.map","import { invariant, __DEV__ } from '../../utilities/globals';\nexport function toPromise(observable) {\n var completed = false;\n return new Promise(function (resolve, reject) {\n observable.subscribe({\n next: function (data) {\n if (completed) {\n __DEV__ && invariant.warn(\"Promise Wrapper does not support multiple results from Observable\");\n }\n else {\n completed = true;\n resolve(data);\n }\n },\n error: reject,\n });\n });\n}\n//# sourceMappingURL=toPromise.js.map","import { Observable } from '../../utilities';\nexport function fromPromise(promise) {\n return new Observable(function (observer) {\n promise\n .then(function (value) {\n observer.next(value);\n observer.complete();\n })\n .catch(observer.error.bind(observer));\n });\n}\n//# sourceMappingURL=fromPromise.js.map","export var throwServerError = function (response, result, message) {\n var error = new Error(message);\n error.name = 'ServerError';\n error.response = response;\n error.statusCode = response.status;\n error.result = result;\n throw error;\n};\n//# sourceMappingURL=throwServerError.js.map","import { InvariantError, __DEV__ } from '../../utilities/globals';\nexport function validateOperation(operation) {\n var OPERATION_FIELDS = [\n 'query',\n 'operationName',\n 'variables',\n 'extensions',\n 'context',\n ];\n for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {\n var key = _a[_i];\n if (OPERATION_FIELDS.indexOf(key) < 0) {\n throw __DEV__ ? new InvariantError(\"illegal argument: \".concat(key)) : new InvariantError(27);\n }\n }\n return operation;\n}\n//# sourceMappingURL=validateOperation.js.map","import { __assign } from \"tslib\";\nexport function createOperation(starting, operation) {\n var context = __assign({}, starting);\n var setContext = function (next) {\n if (typeof next === 'function') {\n context = __assign(__assign({}, context), next(context));\n }\n else {\n context = __assign(__assign({}, context), next);\n }\n };\n var getContext = function () { return (__assign({}, context)); };\n Object.defineProperty(operation, 'setContext', {\n enumerable: false,\n value: setContext,\n });\n Object.defineProperty(operation, 'getContext', {\n enumerable: false,\n value: getContext,\n });\n return operation;\n}\n//# sourceMappingURL=createOperation.js.map","import { getOperationName } from '../../utilities';\nexport function transformOperation(operation) {\n var transformedOperation = {\n variables: operation.variables || {},\n extensions: operation.extensions || {},\n operationName: operation.operationName,\n query: operation.query,\n };\n if (!transformedOperation.operationName) {\n transformedOperation.operationName =\n typeof transformedOperation.query !== 'string'\n ? getOperationName(transformedOperation.query) || undefined\n : '';\n }\n return transformedOperation;\n}\n//# sourceMappingURL=transformOperation.js.map"],"names":["Observable","__DEV__","invariant","InvariantError","__assign","getOperationName"],"mappings":";;;;;;;;AACO,SAAS,SAAS,CAAC,UAAU,EAAE;AACtC,IAAI,OAAO,IAAIA,oBAAU,CAAC,UAAU,QAAQ,EAAE;AAC9C,QAAQ,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AACnC,KAAK,CAAC,CAAC;AACP;;ACJO,SAAS,SAAS,CAAC,UAAU,EAAE;AACtC,IAAI,IAAI,SAAS,GAAG,KAAK,CAAC;AAC1B,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,OAAO,EAAE,MAAM,EAAE;AAClD,QAAQ,UAAU,CAAC,SAAS,CAAC;AAC7B,YAAY,IAAI,EAAE,UAAU,IAAI,EAAE;AAClC,gBAAgB,IAAI,SAAS,EAAE;AAC/B,oBAA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AAK,CAAC,CAAC;AACP,IAAI,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,YAAY,EAAE;AACnD,QAAQ,UAAU,EAAE,KAAK;AACzB,QAAQ,KAAK,EAAE,UAAU;AACzB,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,SAAS,CAAC;AACrB;;ACpBO,SAAS,kBAAkB,CAAC,SAAS,EAAE;AAC9C,IAAI,IAAI,oBAAoB,GAAG;AAC/B,QAAQ,SAAS,EAAE,SAAS,CAAC,SAAS,IAAI,EAAE;AAC5C,QAAQ,UAAU,EAAE,SAAS,CAAC,UAAU,IAAI,EAAE;AAC9C,QAAQ,aAAa,EAAE,SAAS,CAAC,aAAa;AAC9C,QAAQ,KAAK,EAAE,SAAS,CAAC,KAAK;AAC9B,KAAK,CAAC;AACN,IAAI,IAAI,CAAC,oBAAoB,CAAC,aAAa,EAAE;AAC7C,QAAQ,oBAAoB,CAAC,aAAa;AAC1C,YAAY,OAAO,oBAAoB,CAAC,KAAK,KAAK,QAAQ;AAC1D,kBAAkBC,0BAAgB,CAAC,oBAAoB,CAAC,KAAK,CAAC,IAAI,SAAS;AAC3E,kBAAkB,EAAE,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,oBAAoB,CAAC;AAChC;;;;;;;;;;"}
1
+ {"version":3,"file":"utils.cjs","sources":["fromError.js","toPromise.js","fromPromise.js","throwServerError.js","validateOperation.js","createOperation.js","transformOperation.js","filterOperationVariables.js"],"sourcesContent":["import { Observable } from '../../utilities';\nexport function fromError(errorValue) {\n return new Observable(function (observer) {\n observer.error(errorValue);\n });\n}\n//# sourceMappingURL=fromError.js.map","import { invariant, __DEV__ } from '../../utilities/globals';\nexport function toPromise(observable) {\n var completed = false;\n return new Promise(function (resolve, reject) {\n observable.subscribe({\n next: function (data) {\n if (completed) {\n __DEV__ && invariant.warn(\"Promise Wrapper does not support multiple results from Observable\");\n }\n else {\n completed = true;\n resolve(data);\n }\n },\n error: reject,\n });\n });\n}\n//# sourceMappingURL=toPromise.js.map","import { Observable } from '../../utilities';\nexport function fromPromise(promise) {\n return new Observable(function (observer) {\n promise\n .then(function (value) {\n observer.next(value);\n observer.complete();\n })\n .catch(observer.error.bind(observer));\n });\n}\n//# sourceMappingURL=fromPromise.js.map","export var throwServerError = function (response, result, message) {\n var error = new Error(message);\n error.name = 'ServerError';\n error.response = response;\n error.statusCode = response.status;\n error.result = result;\n throw error;\n};\n//# sourceMappingURL=throwServerError.js.map","import { InvariantError, __DEV__ } from '../../utilities/globals';\nexport function validateOperation(operation) {\n var OPERATION_FIELDS = [\n 'query',\n 'operationName',\n 'variables',\n 'extensions',\n 'context',\n ];\n for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {\n var key = _a[_i];\n if (OPERATION_FIELDS.indexOf(key) < 0) {\n throw __DEV__ ? new InvariantError(\"illegal argument: \".concat(key)) : new InvariantError(27);\n }\n }\n return operation;\n}\n//# sourceMappingURL=validateOperation.js.map","import { __assign } from \"tslib\";\nexport function createOperation(starting, operation) {\n var context = __assign({}, starting);\n var setContext = function (next) {\n if (typeof next === 'function') {\n context = __assign(__assign({}, context), next(context));\n }\n else {\n context = __assign(__assign({}, context), next);\n }\n };\n var getContext = function () { return (__assign({}, context)); };\n Object.defineProperty(operation, 'setContext', {\n enumerable: false,\n value: setContext,\n });\n Object.defineProperty(operation, 'getContext', {\n enumerable: false,\n value: getContext,\n });\n return operation;\n}\n//# sourceMappingURL=createOperation.js.map","import { getOperationName } from '../../utilities';\nexport function transformOperation(operation) {\n var transformedOperation = {\n variables: operation.variables || {},\n extensions: operation.extensions || {},\n operationName: operation.operationName,\n query: operation.query,\n };\n if (!transformedOperation.operationName) {\n transformedOperation.operationName =\n typeof transformedOperation.query !== 'string'\n ? getOperationName(transformedOperation.query) || undefined\n : '';\n }\n return transformedOperation;\n}\n//# sourceMappingURL=transformOperation.js.map","import { __assign } from \"tslib\";\nimport { visit } from \"graphql\";\nexport function filterOperationVariables(variables, operation) {\n var result = __assign({}, variables);\n var unusedNames = new Set(Object.keys(variables));\n visit(operation.query, {\n Variable: function (node, _key, parent) {\n if (parent && parent.kind !== 'VariableDefinition') {\n unusedNames.delete(node.name.value);\n }\n },\n });\n unusedNames.forEach(function (name) {\n delete result[name];\n });\n return result;\n}\n//# sourceMappingURL=filterOperationVariables.js.map"],"names":["Observable","__DEV__","invariant","InvariantError","__assign","getOperationName","visit"],"mappings":";;;;;;;;;AACO,SAAS,SAAS,CAAC,UAAU,EAAE;AACtC,IAAI,OAAO,IAAIA,oBAAU,CAAC,UAAU,QAAQ,EAAE;AAC9C,QAAQ,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AACnC,KAAK,CAAC,CAAC;AACP;;ACJO,SAAS,SAAS,CAAC,UAAU,EAAE;AACtC,IAAI,IAAI,SAAS,GAAG,KAAK,CAAC;AAC1B,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,OAAO,EAAE,MAAM,EAAE;AAClD,QAAQ,UAAU,CAAC,SAAS,CAAC;AAC7B,YAAY,IAAI,EAAE,UAAU,IAAI,EAAE;AAClC,gBAAgB,IAAI,SAAS,EAAE;AAC/B,oBAAoBC,eAAO,IAAIC,iBAAS,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC;AACnH,iBAAiB;AACjB,qBAAqB;AACrB,oBAAoB,SAAS,GAAG,IAAI,CAAC;AACrC,oBAAoB,OAAO,CAAC,IAAI,CAAC,CAAC;AAClC,iBAAiB;AACjB,aAAa;AACb,YAAY,KAAK,EAAE,MAAM;AACzB,SAAS,CAAC,CAAC;AACX,KAAK,CAAC,CAAC;AACP;;AChBO,SAAS,WAAW,CAAC,OAAO,EAAE;AACrC,IAAI,OAAO,IAAIF,oBAAU,CAAC,UAAU,QAAQ,EAAE;AAC9C,QAAQ,OAAO;AACf,aAAa,IAAI,CAAC,UAAU,KAAK,EAAE;AACnC,YAAY,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACjC,YAAY,QAAQ,CAAC,QAA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,CAAC,aAAa,EAAE;AAC7C,QAAQ,oBAAoB,CAAC,aAAa;AAC1C,YAAY,OAAO,oBAAoB,CAAC,KAAK,KAAK,QAAQ;AAC1D,kBAAkBC,0BAAgB,CAAC,oBAAoB,CAAC,KAAK,CAAC,IAAI,SAAS;AAC3E,kBAAkB,EAAE,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,oBAAoB,CAAC;AAChC;;ACbO,SAAS,wBAAwB,CAAC,SAAS,EAAE,SAAS,EAAE;AAC/D,IAAI,IAAI,MAAM,GAAGD,cAAQ,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;AACzC,IAAI,IAAI,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;AACtD,IAAIE,aAAK,CAAC,SAAS,CAAC,KAAK,EAAE;AAC3B,QAAQ,QAAQ,EAAE,UAAU,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE;AAChD,YAAY,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,oBAAoB,EAAE;AAChE,gBAAgB,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACpD,aAAa;AACb,SAAS;AACT,KAAK,CAAC,CAAC;AACP,IAAI,WAAW,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE;AACxC,QAAQ,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;AAC5B,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,MAAM,CAAC;AAClB;;;;;;;;;;;"}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var globals = require('../../utilities/globals');
6
6
  var utilities = require('../../utilities');
7
7
  var tslib = require('tslib');
8
+ var graphql = require('graphql');
8
9
 
9
10
  function fromError(errorValue) {
10
11
  return new utilities.Observable(function (observer) {
@@ -105,7 +106,24 @@ function transformOperation(operation) {
105
106
  return transformedOperation;
106
107
  }
107
108
 
109
+ function filterOperationVariables(variables, operation) {
110
+ var result = tslib.__assign({}, variables);
111
+ var unusedNames = new Set(Object.keys(variables));
112
+ graphql.visit(operation.query, {
113
+ Variable: function (node, _key, parent) {
114
+ if (parent && parent.kind !== 'VariableDefinition') {
115
+ unusedNames.delete(node.name.value);
116
+ }
117
+ },
118
+ });
119
+ unusedNames.forEach(function (name) {
120
+ delete result[name];
121
+ });
122
+ return result;
123
+ }
124
+
108
125
  exports.createOperation = createOperation;
126
+ exports.filterOperationVariables = filterOperationVariables;
109
127
  exports.fromError = fromError;
110
128
  exports.fromPromise = fromPromise;
111
129
  exports.throwServerError = throwServerError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollo/client",
3
- "version": "3.8.0-alpha.10",
3
+ "version": "3.8.0-alpha.12",
4
4
  "description": "A fully-featured caching GraphQL client.",
5
5
  "private": false,
6
6
  "keywords": [
@@ -57,7 +57,7 @@
57
57
  "@wry/trie": "^0.3.0",
58
58
  "graphql-tag": "^2.12.6",
59
59
  "hoist-non-react-statics": "^3.3.2",
60
- "optimism": "^0.16.1",
60
+ "optimism": "^0.17.0",
61
61
  "prop-types": "^15.7.2",
62
62
  "response-iterator": "^0.2.6",
63
63
  "symbol-observable": "^4.0.0",
@@ -66,9 +66,9 @@
66
66
  "zen-observable-ts": "^1.2.5"
67
67
  },
68
68
  "devDependencies": {
69
- "@babel/parser": "7.21.2",
69
+ "@babel/parser": "7.21.4",
70
70
  "@changesets/changelog-github": "0.4.8",
71
- "@changesets/cli": "2.26.0",
71
+ "@changesets/cli": "2.26.1",
72
72
  "@graphql-tools/schema": "9.0.17",
73
73
  "@rollup/plugin-node-resolve": "11.2.1",
74
74
  "@testing-library/jest-dom": "5.16.5",
@@ -79,25 +79,25 @@
79
79
  "@types/fetch-mock": "7.3.5",
80
80
  "@types/glob": "8.1.0",
81
81
  "@types/hoist-non-react-statics": "3.3.1",
82
- "@types/jest": "29.4.0",
83
- "@types/lodash": "4.14.191",
84
- "@types/node": "18.15.1",
85
- "@types/node-fetch": "2.6.2",
86
- "@types/react": "18.0.28",
82
+ "@types/jest": "29.5.0",
83
+ "@types/lodash": "4.14.192",
84
+ "@types/node": "18.15.11",
85
+ "@types/node-fetch": "2.6.3",
86
+ "@types/react": "18.0.33",
87
87
  "@types/react-dom": "18.0.11",
88
88
  "@types/use-sync-external-store": "0.0.3",
89
- "@typescript-eslint/eslint-plugin": "5.55.0",
90
- "@typescript-eslint/parser": "5.55.0",
89
+ "@typescript-eslint/eslint-plugin": "5.57.1",
90
+ "@typescript-eslint/parser": "5.58.0",
91
91
  "acorn": "8.8.2",
92
92
  "blob-polyfill": "7.0.20220408",
93
93
  "bytes": "3.1.2",
94
94
  "cross-fetch": "3.1.5",
95
- "eslint": "8.36.0",
95
+ "eslint": "8.38.0",
96
96
  "eslint-plugin-testing-library": "5.10.2",
97
97
  "fetch-mock": "9.11.0",
98
98
  "glob": "8.1.0",
99
99
  "graphql": "16.6.0",
100
- "graphql-ws": "5.12.0",
100
+ "graphql-ws": "5.12.1",
101
101
  "jest": "29.5.0",
102
102
  "jest-environment-jsdom": "29.5.0",
103
103
  "jest-junit": "15.0.0",
@@ -110,17 +110,17 @@
110
110
  "react-dom-17": "npm:react-dom@^17",
111
111
  "react-error-boundary": "3.1.4",
112
112
  "recast": "0.22.0",
113
- "resolve": "1.22.1",
114
- "rimraf": "4.4.0",
113
+ "resolve": "1.22.2",
114
+ "rimraf": "5.0.0",
115
115
  "rollup": "2.79.1",
116
116
  "rollup-plugin-terser": "7.0.2",
117
117
  "rxjs": "7.8.0",
118
118
  "subscriptions-transport-ws": "0.11.0",
119
- "terser": "5.16.6",
120
- "ts-jest": "29.0.5",
119
+ "terser": "5.16.8",
120
+ "ts-jest": "29.1.0",
121
121
  "ts-node": "10.9.1",
122
122
  "typedoc": "0.22.18",
123
- "typescript": "4.9.5",
123
+ "typescript": "5.0.4",
124
124
  "wait-for-observables": "1.0.3",
125
125
  "web-streams-polyfill": "3.2.1",
126
126
  "whatwg-fetch": "3.6.2"
@@ -0,0 +1,26 @@
1
+ import { ApolloQueryResult, ObservableQuery, OperationVariables } from '../../core';
2
+ type Listener<TData> = (result: ApolloQueryResult<TData>) => void;
3
+ type FetchMoreOptions<TData> = Parameters<ObservableQuery<TData>['fetchMore']>[0];
4
+ interface QuerySubscriptionOptions {
5
+ onDispose?: () => void;
6
+ autoDisposeTimeoutMs?: number;
7
+ }
8
+ export declare class QuerySubscription<TData = any> {
9
+ result: ApolloQueryResult<TData>;
10
+ promise: Promise<ApolloQueryResult<TData>>;
11
+ readonly observable: ObservableQuery<TData>;
12
+ private subscription;
13
+ private listeners;
14
+ private autoDisposeTimeoutId;
15
+ constructor(observable: ObservableQuery<TData>, options?: QuerySubscriptionOptions);
16
+ listen(listener: Listener<TData>): () => void;
17
+ refetch(variables: OperationVariables | undefined): Promise<ApolloQueryResult<TData>>;
18
+ fetchMore(options: FetchMoreOptions<TData>): Promise<ApolloQueryResult<TData>>;
19
+ dispose(): void;
20
+ private onDispose;
21
+ private handleNext;
22
+ private handleError;
23
+ private deliver;
24
+ }
25
+ export {};
26
+ //# sourceMappingURL=QuerySubscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QuerySubscription.d.ts","sourceRoot":"","sources":["../../../src/react/cache/QuerySubscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAGjB,eAAe,EACf,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAUpB,KAAK,QAAQ,CAAC,KAAK,IAAI,CAAC,MAAM,EAAE,iBAAiB,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;AAElE,KAAK,gBAAgB,CAAC,KAAK,IAAI,UAAU,CACvC,eAAe,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CACpC,CAAC,CAAC,CAAC,CAAC;AAwBL,UAAU,wBAAwB;IAChC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,qBAAa,iBAAiB,CAAC,KAAK,GAAG,GAAG;IACjC,MAAM,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACjC,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;IAClD,SAAgB,UAAU,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;IAEnD,OAAO,CAAC,YAAY,CAAyB;IAC7C,OAAO,CAAC,SAAS,CAA8B;IAC/C,OAAO,CAAC,oBAAoB,CAAiB;gBAG3C,UAAU,EAAE,eAAe,CAAC,KAAK,CAAC,EAClC,OAAO,GAAE,wBAA8C;IA4CzD,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC;IAahC,OAAO,CAAC,SAAS,EAAE,kBAAkB,GAAG,SAAS;IAMjD,SAAS,CAAC,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC;IAM1C,OAAO;IAKP,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,UAAU;IAgBlB,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,OAAO;CAGhB"}
@@ -0,0 +1,88 @@
1
+ import { __assign } from "tslib";
2
+ import { NetworkStatus, } from "../../core/index.js";
3
+ import { isNetworkRequestSettled } from "../../core/index.js";
4
+ import { hasAnyDirectives, } from "../../utilities/index.js";
5
+ import { invariant, __DEV__ } from "../../utilities/globals/index.js";
6
+ import { wrap } from 'optimism';
7
+ function wrapWithCustomPromise(concast) {
8
+ return new Promise(function (resolve, reject) {
9
+ var subscription = concast.subscribe({
10
+ next: function (value) {
11
+ resolve(value);
12
+ subscription.unsubscribe();
13
+ },
14
+ error: reject,
15
+ });
16
+ });
17
+ }
18
+ var isMultipartQuery = wrap(function (query) {
19
+ return hasAnyDirectives(['defer', 'stream'], query);
20
+ });
21
+ var QuerySubscription = (function () {
22
+ function QuerySubscription(observable, options) {
23
+ if (options === void 0) { options = Object.create(null); }
24
+ var _a;
25
+ this.listeners = new Set();
26
+ this.listen = this.listen.bind(this);
27
+ this.handleNext = this.handleNext.bind(this);
28
+ this.handleError = this.handleError.bind(this);
29
+ this.dispose = this.dispose.bind(this);
30
+ this.observable = observable;
31
+ this.result = observable.getCurrentResult();
32
+ if (options.onDispose) {
33
+ this.onDispose = options.onDispose;
34
+ }
35
+ this.subscription = observable.subscribe({
36
+ next: this.handleNext,
37
+ error: this.handleError,
38
+ });
39
+ __DEV__ ? invariant(observable['concast'], 'Unexpected error: A concast was not found on the observable.') : invariant(observable['concast'], 28);
40
+ var concast = observable['concast'];
41
+ this.promise = isMultipartQuery(observable.query)
42
+ ? wrapWithCustomPromise(concast)
43
+ : concast.promise;
44
+ this.autoDisposeTimeoutId = setTimeout(this.dispose, (_a = options.autoDisposeTimeoutMs) !== null && _a !== void 0 ? _a : 30000);
45
+ }
46
+ QuerySubscription.prototype.listen = function (listener) {
47
+ var _this = this;
48
+ clearTimeout(this.autoDisposeTimeoutId);
49
+ this.listeners.add(listener);
50
+ return function () {
51
+ _this.listeners.delete(listener);
52
+ };
53
+ };
54
+ QuerySubscription.prototype.refetch = function (variables) {
55
+ this.promise = this.observable.refetch(variables);
56
+ return this.promise;
57
+ };
58
+ QuerySubscription.prototype.fetchMore = function (options) {
59
+ this.promise = this.observable.fetchMore(options);
60
+ return this.promise;
61
+ };
62
+ QuerySubscription.prototype.dispose = function () {
63
+ this.subscription.unsubscribe();
64
+ this.onDispose();
65
+ };
66
+ QuerySubscription.prototype.onDispose = function () {
67
+ };
68
+ QuerySubscription.prototype.handleNext = function (result) {
69
+ if (isNetworkRequestSettled(result.networkStatus) &&
70
+ this.result.data &&
71
+ result.data === void 0) {
72
+ result.data = this.result.data;
73
+ }
74
+ this.result = result;
75
+ this.deliver(result);
76
+ };
77
+ QuerySubscription.prototype.handleError = function (error) {
78
+ var result = __assign(__assign({}, this.result), { error: error, networkStatus: NetworkStatus.error });
79
+ this.result = result;
80
+ this.deliver(result);
81
+ };
82
+ QuerySubscription.prototype.deliver = function (result) {
83
+ this.listeners.forEach(function (listener) { return listener(result); });
84
+ };
85
+ return QuerySubscription;
86
+ }());
87
+ export { QuerySubscription };
88
+ //# sourceMappingURL=QuerySubscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QuerySubscription.js","sourceRoot":"","sources":["../../../src/react/cache/QuerySubscription.ts"],"names":[],"mappings":";AAAA,OAAO,EAIL,aAAa,GAGd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAGL,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAQhC,SAAS,qBAAqB,CAC5B,OAA0C;IAE1C,OAAO,IAAI,OAAO,CAA2B,UAAC,OAAO,EAAE,MAAM;QAK3D,IAAM,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC;YACrC,IAAI,EAAE,UAAC,KAAK;gBACV,OAAO,CAAC,KAAK,CAAC,CAAC;gBACf,YAAY,CAAC,WAAW,EAAE,CAAC;YAC7B,CAAC;YACD,KAAK,EAAE,MAAM;SACd,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,IAAM,gBAAgB,GAAG,IAAI,CAAC,UAAC,KAAmB;IAChD,OAAO,gBAAgB,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;AACtD,CAAC,CAAC,CAAC;AAOH;IASE,2BACE,UAAkC,EAClC,OAAuD;QAAvD,wBAAA,EAAA,UAAoC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;;QALjD,cAAS,GAAG,IAAI,GAAG,EAAmB,CAAC;QAO7C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,U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ACH,wBAAC;AAAD,CAAC,AAvHD,IAuHC","sourcesContent":["import {\n ApolloError,\n ApolloQueryResult,\n DocumentNode,\n NetworkStatus,\n ObservableQuery,\n OperationVariables,\n} from '../../core';\nimport { isNetworkRequestSettled } from '../../core';\nimport {\n Concast,\n ObservableSubscription,\n hasAnyDirectives,\n} from '../../utilities';\nimport { invariant } from '../../utilities/globals';\nimport { wrap } from 'optimism';\n\ntype Listener<TData> = (result: ApolloQueryResult<TData>) => void;\n\ntype FetchMoreOptions<TData> = Parameters<\n ObservableQuery<TData>['fetchMore']\n>[0];\n\nfunction wrapWithCustomPromise<TData>(\n concast: Concast<ApolloQueryResult<TData>>\n) {\n return new Promise<ApolloQueryResult<TData>>((resolve, reject) => {\n // Unlike `concast.promise`, we want to resolve the promise on the initial\n // chunk of the deferred query. This allows the component to unsuspend\n // when we get the initial set of data, rather than waiting until all\n // chunks have been loaded.\n const subscription = concast.subscribe({\n next: (value) => {\n resolve(value);\n subscription.unsubscribe();\n },\n error: reject,\n });\n });\n}\n\nconst isMultipartQuery = wrap((query: DocumentNode) => {\n return hasAnyDirectives(['defer', 'stream'], query);\n});\n\ninterface QuerySubscriptionOptions {\n onDispose?: () => void;\n autoDisposeTimeoutMs?: number;\n}\n\nexport class QuerySubscription<TData = any> {\n public result: ApolloQueryResult<TData>;\n public promise: Promise<ApolloQueryResult<TData>>;\n public readonly observable: ObservableQuery<TData>;\n\n private subscription: ObservableSubscription;\n private listeners = new Set<Listener<TData>>();\n private autoDisposeTimeoutId: NodeJS.Timeout;\n\n constructor(\n observable: ObservableQuery<TData>,\n options: QuerySubscriptionOptions = Object.create(null)\n ) {\n this.listen = this.listen.bind(this);\n this.handleNext = this.handleNext.bind(this);\n this.handleError = this.handleError.bind(this);\n this.dispose = this.dispose.bind(this);\n this.observable = observable;\n this.result = observable.getCurrentResult();\n\n if (options.onDispose) {\n this.onDispose = options.onDispose;\n }\n\n this.subscription = observable.subscribe({\n next: this.handleNext,\n error: this.handleError,\n });\n\n // This error should never happen since the `.subscribe` call above\n // will ensure a concast is set on the observable via the `reobserve`\n // call. Unless something is going horribly wrong and completely messing\n // around with the internals of the observable, there should always be a\n // concast after subscribing.\n invariant(\n observable['concast'],\n 'Unexpected error: A concast was not found on the observable.'\n );\n\n const concast = observable['concast'];\n\n this.promise = isMultipartQuery(observable.query)\n ? wrapWithCustomPromise(concast)\n : concast.promise;\n\n // Start a timer that will automatically dispose of the query if the\n // suspended resource does not use this subscription in the given time. This\n // helps prevent memory leaks when a component has unmounted before the\n // query has finished loading.\n this.autoDisposeTimeoutId = setTimeout(\n this.dispose,\n options.autoDisposeTimeoutMs ?? 30_000\n );\n }\n\n listen(listener: Listener<TData>) {\n // As soon as the component listens for updates, we know it has finished\n // suspending and is ready to receive updates, so we can remove the auto\n // dispose timer.\n clearTimeout(this.autoDisposeTimeoutId);\n\n this.listeners.add(listener);\n\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n refetch(variables: OperationVariables | undefined) {\n this.promise = this.observable.refetch(variables);\n\n return this.promise;\n }\n\n fetchMore(options: FetchMoreOptions<TData>) {\n this.promise = this.observable.fetchMore<TData>(options);\n\n return this.promise;\n }\n\n dispose() {\n this.subscription.unsubscribe();\n this.onDispose();\n }\n\n private onDispose() {\n // noop. overridable by options\n }\n\n private handleNext(result: ApolloQueryResult<TData>) {\n // If we encounter an error with the new result after we have successfully\n // fetched a previous result, we should set the new result data to the last\n // successful result.\n if (\n isNetworkRequestSettled(result.networkStatus) &&\n this.result.data &&\n result.data === void 0\n ) {\n result.data = this.result.data;\n }\n\n this.result = result;\n this.deliver(result);\n }\n\n private handleError(error: ApolloError) {\n const result = {\n ...this.result,\n error,\n networkStatus: NetworkStatus.error,\n };\n\n this.result = result;\n this.deliver(result);\n }\n\n private deliver(result: ApolloQueryResult<TData>) {\n this.listeners.forEach((listener) => listener(result));\n }\n}\n"]}
@@ -1,18 +1,15 @@
1
- import { ApolloQueryResult, DocumentNode, ObservableQuery, OperationVariables, TypedDocumentNode } from '../../core';
2
- interface CacheEntry<TData, TVariables extends OperationVariables> {
3
- observable: ObservableQuery<TData, TVariables>;
4
- fulfilled: boolean;
5
- promise: Promise<ApolloQueryResult<TData>>;
1
+ import { ObservableQuery } from '../../core';
2
+ import { QuerySubscription } from './QuerySubscription';
3
+ type CacheKey = any[];
4
+ interface SuspenseCacheOptions {
5
+ autoDisposeTimeoutMs?: number;
6
6
  }
7
7
  export declare class SuspenseCache {
8
- private queries;
9
- add<TData = any, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, variables: TVariables | undefined, { promise, observable, }: {
10
- promise: Promise<any>;
11
- observable: ObservableQuery<TData, TVariables>;
12
- }): CacheEntry<TData, TVariables>;
13
- lookup<TData = any, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, variables: TVariables | undefined): CacheEntry<TData, TVariables> | undefined;
14
- remove(query: DocumentNode, variables: OperationVariables | undefined): void;
15
- private getVariablesKey;
8
+ private cacheKeys;
9
+ private subscriptions;
10
+ private options;
11
+ constructor(options?: SuspenseCacheOptions);
12
+ getSubscription<TData = any>(cacheKey: CacheKey, createObservable: () => ObservableQuery<TData>): QuerySubscription<TData>;
16
13
  }
17
14
  export {};
18
15
  //# sourceMappingURL=SuspenseCache.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SuspenseCache.d.ts","sourceRoot":"","sources":["../../../src/react/cache/SuspenseCache.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAGpB,UAAU,UAAU,CAAC,KAAK,EAAE,UAAU,SAAS,kBAAkB;IAC/D,UAAU,EAAE,eAAe,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAC/C,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,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G,EACzB,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,MAAM,eAAe,CAAC,KAAK,CAAC;CAgBjD"}
@@ -1,47 +1,23 @@
1
- import { canonicalStringify } from "../../cache/index.js";
1
+ import { Trie } from '@wry/trie';
2
+ import { canUseWeakMap } from "../../utilities/index.js";
3
+ import { QuerySubscription } from "./QuerySubscription.js";
2
4
  var SuspenseCache = (function () {
3
- function SuspenseCache() {
4
- this.queries = new Map();
5
+ function SuspenseCache(options) {
6
+ if (options === void 0) { options = Object.create(null); }
7
+ this.cacheKeys = new Trie(canUseWeakMap, function (cacheKey) { return cacheKey; });
8
+ this.subscriptions = new Map();
9
+ this.options = options;
5
10
  }
6
- SuspenseCache.prototype.add = function (query, variables, _a) {
7
- var promise = _a.promise, observable = _a.observable;
8
- var variablesKey = this.getVariablesKey(variables);
9
- var map = this.queries.get(query) || new Map();
10
- var entry = {
11
- observable: observable,
12
- fulfilled: false,
13
- promise: promise
14
- .catch(function () {
15
- })
16
- .finally(function () {
17
- entry.fulfilled = true;
18
- }),
19
- };
20
- map.set(variablesKey, entry);
21
- this.queries.set(query, map);
22
- return entry;
23
- };
24
- SuspenseCache.prototype.lookup = function (query, variables) {
25
- var _a;
26
- return (_a = this.queries
27
- .get(query)) === null || _a === void 0 ? void 0 : _a.get(this.getVariablesKey(variables));
28
- };
29
- SuspenseCache.prototype.remove = function (query, variables) {
30
- var map = this.queries.get(query);
31
- if (!map) {
32
- return;
33
- }
34
- var key = this.getVariablesKey(variables);
35
- var entry = map.get(key);
36
- if (entry && !entry.observable.hasObservers()) {
37
- map.delete(key);
11
+ SuspenseCache.prototype.getSubscription = function (cacheKey, createObservable) {
12
+ var _this = this;
13
+ var stableCacheKey = this.cacheKeys.lookupArray(cacheKey);
14
+ if (!this.subscriptions.has(stableCacheKey)) {
15
+ this.subscriptions.set(stableCacheKey, new QuerySubscription(createObservable(), {
16
+ autoDisposeTimeoutMs: this.options.autoDisposeTimeoutMs,
17
+ onDispose: function () { return _this.subscriptions.delete(stableCacheKey); },
18
+ }));
38
19
  }
39
- if (map.size === 0) {
40
- this.queries.delete(query);
41
- }
42
- };
43
- SuspenseCache.prototype.getVariablesKey = function (variables) {
44
- return canonicalStringify(variables || Object.create(null));
20
+ return this.subscriptions.get(stableCacheKey);
45
21
  };
46
22
  return SuspenseCache;
47
23
  }());
@@ -1 +1 @@
1
- {"version":3,"file":"SuspenseCache.js","sourceRoot":"","sources":["../../../src/react/cache/SuspenseCache.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAQjD;IAAA;QACU,YAAO,GAAG,IAAI,GAAG,EAGtB,CAAC;IAmEN,CAAC;IAjEC,2BAAG,GAAH,UACE,KAA0D,EAC1D,SAAiC,EACjC,EAG4E;YAF1E,OAAO,aAAA,EACP,UAAU,gBAAA;QAGZ,IAAM,YAAY,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QACrD,IAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,EAAE,CAAC;QAEjD,IAAM,KAAK,GAAkC;YAC3C,UAAU,YAAA;YACV,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,OAAO;iBACb,KAAK,CAAC;YAGP,CAAC,CAAC;iBACD,OAAO,CAAC;gBACP,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;YACzB,CAAC,CAAC;SACL,CAAC;QAEF,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;QAE7B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAE7B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,8BAAM,GAAN,UAIE,KAA0D,EAC1D,SAAiC;;QAEjC,OAAO,MAAA,IAAI,CAAC,OAAO;aAChB,GAAG,CAAC,KAAK,CAAC,0CACT,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAkC,CAAC;IAC5E,CAAC;IAED,8BAAM,GAAN,UAAO,KAAmB,EAAE,SAAyC;QACnE,IAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAEpC,IAAI,CAAC,GAAG,EAAE;YACR,OAAO;SACR;QAED,IAAM,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QAC5C,IAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAE3B,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,YAAY,EAAE,EAAE;YAC7C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SACjB;QAED,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE;YAClB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SAC5B;IACH,CAAC;IAEO,uCAAe,GAAvB,UAAwB,SAAyC;QAC/D,OAAO,kBAAkB,CAAC,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9D,CAAC;IACH,oBAAC;AAAD,CAAC,AAvED,IAuEC","sourcesContent":["import {\n ApolloQueryResult,\n DocumentNode,\n ObservableQuery,\n OperationVariables,\n TypedDocumentNode,\n} from '../../core';\nimport { canonicalStringify } from '../../cache';\n\ninterface CacheEntry<TData, TVariables extends OperationVariables> {\n observable: ObservableQuery<TData, TVariables>;\n fulfilled: boolean;\n promise: Promise<ApolloQueryResult<TData>>;\n}\n\nexport class SuspenseCache {\n private queries = new Map<\n DocumentNode,\n Map<string, CacheEntry<unknown, any>>\n >();\n\n add<TData = any, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n variables: TVariables | undefined,\n {\n promise,\n observable,\n }: { promise: Promise<any>; observable: ObservableQuery<TData, TVariables> }\n ) {\n const variablesKey = this.getVariablesKey(variables);\n const map = this.queries.get(query) || new Map();\n\n const entry: CacheEntry<TData, TVariables> = {\n observable,\n fulfilled: false,\n promise: promise\n .catch(() => {\n // Throw away the error as we only care to track when the promise has\n // been fulfilled\n })\n .finally(() => {\n entry.fulfilled = true;\n }),\n };\n\n map.set(variablesKey, entry);\n\n this.queries.set(query, map);\n\n return entry;\n }\n\n lookup<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n variables: TVariables | undefined\n ): CacheEntry<TData, TVariables> | undefined {\n return this.queries\n .get(query)\n ?.get(this.getVariablesKey(variables)) as CacheEntry<TData, TVariables>;\n }\n\n remove(query: DocumentNode, variables: OperationVariables | undefined) {\n const map = this.queries.get(query);\n\n if (!map) {\n return;\n }\n\n const key = this.getVariablesKey(variables);\n const entry = map.get(key);\n\n if (entry && !entry.observable.hasObservers()) {\n map.delete(key);\n }\n\n if (map.size === 0) {\n this.queries.delete(query);\n }\n }\n\n private getVariablesKey(variables: OperationVariables | undefined) {\n return canonicalStringify(variables || Object.create(null));\n }\n}\n"]}
1
+ {"version":3,"file":"SuspenseCache.js","sourceRoot":"","sources":["../../../src/react/cache/SuspenseCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAkBxD;IASE,uBAAY,OAAmD;QAAnD,wBAAA,EAAA,UAAgC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;QARvD,cAAS,GAAG,IAAI,IAAI,CAC1B,aAAa,EACb,UAAC,QAAkB,IAAK,OAAA,QAAQ,EAAR,CAAQ,CACjC,CAAC;QAEM,kBAAa,GAAG,IAAI,GAAG,EAA+B,CAAC;QAI7D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,uCAAe,GAAf,UACE,QAAkB,EAClB,gBAA8C;QAFhD,iBAiBC;QAbC,IAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAE5D,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE;YAC3C,IAAI,CAAC,aAAa,CAAC,GAAG,CACpB,cAAc,EACd,IAAI,iBAAiB,CAAC,gBAAgB,EAAE,EAAE;gBACxC,oBAAoB,EAAE,IAAI,CAAC,OAAO,CAAC,oBAAoB;gBACvD,SAAS,EAAE,cAAM,OAAA,KAAI,CAAC,aAAa,CAAC,MAAM,CAAC,cAAc,CAAC,EAAzC,CAAyC;aAC3D,CAAC,CACH,CAAC;SACH;QAED,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,cAAc,CAA8B,CAAC;IAC7E,CAAC;IACH,oBAAC;AAAD,CAAC,AA/BD,IA+BC","sourcesContent":["import { Trie } from '@wry/trie';\nimport { ObservableQuery } from '../../core';\nimport { canUseWeakMap } from '../../utilities';\nimport { QuerySubscription } from './QuerySubscription';\n\ntype CacheKey = any[];\n\ninterface SuspenseCacheOptions {\n /**\n * Specifies the amount of time, in milliseconds, the suspense cache will wait\n * for a suspended component to read from the suspense cache before it\n * automatically disposes of the query. This prevents memory leaks when a\n * component unmounts before a suspended resource finishes loading. Increase\n * the timeout if your queries take longer than than the specified time to\n * prevent your queries from suspending over and over.\n *\n * Defaults to 30 seconds.\n */\n autoDisposeTimeoutMs?: number;\n}\n\nexport class SuspenseCache {\n private cacheKeys = new Trie<CacheKey>(\n canUseWeakMap,\n (cacheKey: CacheKey) => cacheKey\n );\n\n private subscriptions = new Map<CacheKey, QuerySubscription>();\n private options: SuspenseCacheOptions;\n\n constructor(options: SuspenseCacheOptions = Object.create(null)) {\n this.options = options;\n }\n\n getSubscription<TData = any>(\n cacheKey: CacheKey,\n createObservable: () => ObservableQuery<TData>\n ) {\n const stableCacheKey = this.cacheKeys.lookupArray(cacheKey);\n\n if (!this.subscriptions.has(stableCacheKey)) {\n this.subscriptions.set(\n stableCacheKey,\n new QuerySubscription(createObservable(), {\n autoDisposeTimeoutMs: this.options.autoDisposeTimeoutMs,\n onDispose: () => this.subscriptions.delete(stableCacheKey),\n })\n );\n }\n\n return this.subscriptions.get(stableCacheKey)! as QuerySubscription<TData>;\n }\n}\n"]}
@@ -5,7 +5,7 @@ export var ApolloConsumer = function (props) {
5
5
  var ApolloContext = getApolloContext();
6
6
  return (React.createElement(ApolloContext.Consumer, null, function (context) {
7
7
  __DEV__ ? invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
8
- 'Wrap the root component in an <ApolloProvider>.') : invariant(context && context.client, 28);
8
+ 'Wrap the root component in an <ApolloProvider>.') : invariant(context && context.client, 29);
9
9
  return props.children(context.client);
10
10
  }));
11
11
  };
@@ -13,7 +13,7 @@ export var ApolloProvider = function (_a) {
13
13
  context = Object.assign({}, context, { suspenseCache: suspenseCache });
14
14
  }
15
15
  __DEV__ ? invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
16
- 'sure you pass in your client via the "client" prop.') : invariant(context.client, 29);
16
+ 'sure you pass in your client via the "client" prop.') : invariant(context.client, 30);
17
17
  return (React.createElement(ApolloContext.Provider, { value: context }, children));
18
18
  }));
19
19
  };
@@ -41,7 +41,7 @@ var ApolloConsumer = function (props) {
41
41
  var ApolloContext = getApolloContext();
42
42
  return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
43
43
  globals.__DEV__ ? globals.invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
44
- 'Wrap the root component in an <ApolloProvider>.') : globals.invariant(context && context.client, 28);
44
+ 'Wrap the root component in an <ApolloProvider>.') : globals.invariant(context && context.client, 29);
45
45
  return props.children(context.client);
46
46
  }));
47
47
  };
@@ -58,7 +58,7 @@ var ApolloProvider = function (_a) {
58
58
  context = Object.assign({}, context, { suspenseCache: suspenseCache });
59
59
  }
60
60
  globals.__DEV__ ? globals.invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
61
- 'sure you pass in your client via the "client" prop.') : globals.invariant(context.client, 29);
61
+ 'sure you pass in your client via the "client" prop.') : globals.invariant(context.client, 30);
62
62
  return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
63
63
  }));
64
64
  };
@@ -1 +1 @@
1
- {"version":3,"file":"context.cjs","sources":["ApolloContext.js","ApolloConsumer.js","ApolloProvider.js"],"sourcesContent":["import * as React from 'react';\nimport { canUseSymbol } from '../../utilities';\nvar contextKey = canUseSymbol\n ? Symbol.for('__APOLLO_CONTEXT__')\n : '__APOLLO_CONTEXT__';\nexport function getApolloContext() {\n var context = React.createContext[contextKey];\n if (!context) {\n Object.defineProperty(React.createContext, contextKey, {\n value: context = React.createContext({}),\n enumerable: false,\n writable: false,\n configurable: true,\n });\n context.displayName = 'ApolloContext';\n }\n return context;\n}\nexport { getApolloContext as resetApolloContext };\n//# sourceMappingURL=ApolloContext.js.map","import { invariant, __DEV__ } from '../../utilities/globals';\nimport * as React from 'react';\nimport { getApolloContext } from './ApolloContext';\nexport var ApolloConsumer = function (props) {\n var ApolloContext = getApolloContext();\n return (React.createElement(ApolloContext.Consumer, null, function (context) {\n __DEV__ ? invariant(context && context.client, 'Could not find \"client\" in the context of ApolloConsumer. ' +\n 'Wrap the root component in an <ApolloProvider>.') : invariant(context && context.client, 28);\n return props.children(context.client);\n }));\n};\n//# sourceMappingURL=ApolloConsumer.js.map","import { invariant, __DEV__ } from '../../utilities/globals';\nimport * as React from 'react';\nimport { getApolloContext } from './ApolloContext';\nexport var ApolloProvider = function (_a) {\n var client = _a.client, suspenseCache = _a.suspenseCache, children = _a.children;\n var ApolloContext = getApolloContext();\n return (React.createElement(ApolloContext.Consumer, null, function (context) {\n if (context === void 0) { context = {}; }\n if (client && context.client !== client) {\n context = Object.assign({}, context, { client: client });\n }\n if (suspenseCache) {\n context = Object.assign({}, context, { suspenseCache: suspenseCache });\n }\n __DEV__ ? invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +\n 'sure you pass in your client via the \"client\" prop.') : invariant(context.client, 29);\n return (React.createElement(ApolloContext.Provider, { value: context }, children));\n }));\n};\n//# sourceMappingURL=ApolloProvider.js.map"],"names":["canUseSymbol","React","__DEV__","invariant"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,IAAI,UAAU,GAAGA,sBAAY;AAC7B,MAAM,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;AACtC,MAAM,oBAAoB,CAAC;AACpB,SAAS,gBAAgB,GAAG;AACnC,IAAI,IAAI,OAAO,GAAGC,gBAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AAClD,IAAI,IAAI,CAAC,OAAO,EAAE;AAClB,QAAQ,MAAM,CAAC,cAAc,CAACA,gBAAK,CAAC,aAAa,EAAE,UAAU,EAAE;AAC/D,YAAY,KAAK,EAAE,OAAO,GAAGA,gBAAK,CAAC,aAAa,CAAC,EAAE,CAAC;AACpD,YAAY,UAAU,EAAE,KAAK;AAC7B,YAAY,QAAQ,EAAE,KAAK;AAC3B,YAAY,YAAY,EAAE,IAAI;AAC9B,SAAS,CAAC,CAAC;AACX,QAAQ,OAAO,CAAC,WAAW,GAAG,eAAe,CAAC;AAC9C,KAAK;AACL,IAAI,OAAO,OAAO,CAAC;AACnB;;ACdU,IAAC,cAAc,GAAG,UAAU,KAAK,EAAE;AAC7C,IAAI,IAAI,aAAa,GAAG,gBAAgB,EAAE,CAAC;AAC3C,IAAI,QAAQA,gBAAK,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,OAAO,EAAE;AACjF,QAAQC,eAAO,GAAGC,iBAAS,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,4DAA4D;AACnH,YAAY,iDAAiD,CAAC,GAAGA,iBAAS,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,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olloContext.js","ApolloConsumer.js","ApolloProvider.js"],"sourcesContent":["import * as React from 'react';\nimport { canUseSymbol } from '../../utilities';\nvar contextKey = canUseSymbol\n ? Symbol.for('__APOLLO_CONTEXT__')\n : '__APOLLO_CONTEXT__';\nexport function getApolloContext() {\n var context = React.createContext[contextKey];\n if (!context) {\n Object.defineProperty(React.createContext, contextKey, {\n value: context = React.createContext({}),\n enumerable: false,\n writable: false,\n configurable: true,\n });\n context.displayName = 'ApolloContext';\n }\n return context;\n}\nexport { getApolloContext as resetApolloContext };\n//# sourceMappingURL=ApolloContext.js.map","import { invariant, __DEV__ } from '../../utilities/globals';\nimport * as React from 'react';\nimport { getApolloContext } from './ApolloContext';\nexport var ApolloConsumer = function (props) {\n var ApolloContext = getApolloContext();\n return (React.createElement(ApolloContext.Consumer, null, function (context) {\n __DEV__ ? invariant(context && context.client, 'Could not find \"client\" in the context of ApolloConsumer. ' +\n 'Wrap the root component in an <ApolloProvider>.') : invariant(context && context.client, 29);\n return props.children(context.client);\n }));\n};\n//# sourceMappingURL=ApolloConsumer.js.map","import { invariant, __DEV__ } from '../../utilities/globals';\nimport * as React from 'react';\nimport { getApolloContext } from './ApolloContext';\nexport var ApolloProvider = function (_a) {\n var client = _a.client, suspenseCache = _a.suspenseCache, children = _a.children;\n var ApolloContext = getApolloContext();\n return (React.createElement(ApolloContext.Consumer, null, function (context) {\n if (context === void 0) { context = {}; }\n if (client && context.client !== client) {\n context = Object.assign({}, context, { client: client });\n }\n if (suspenseCache) {\n context = Object.assign({}, context, { suspenseCache: suspenseCache });\n }\n __DEV__ ? invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +\n 'sure you pass in your client via the \"client\" prop.') : invariant(context.client, 30);\n return (React.createElement(ApolloContext.Provider, { value: context }, children));\n }));\n};\n//# sourceMappingURL=ApolloProvider.js.map"],"names":["canUseSymbol","React","__DEV__","invariant"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,IAAI,UAAU,GAAGA,sBAAY;A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,CAAC;AACrF,IAAI,IAAI,aAAa,GAAG,gBAAgB,EAAE,CAAC;AAC3C,IAAI,QAAQF,gBAAK,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,OAAO,EAAE;AACjF,QAAQ,IAAI,OAAO,KAAK,KAAK,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,CAAC,EAAE;AACjD,QAAQ,IAAI,MAAM,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE;AACjD,YAAY,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AACrE,SAAS;AACT,QAAQ,IAAI,aAAa,EAAE;AAC3B,YAAY,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC,CAAC;AACnF,SAAS;AACT,QAAQC,eAAO,GAAGC,iBAAS,CAAC,OAAO,CAAC,MAAM,EAAE,wDAAwD;AACpG,YAAY,qDAAqD,CAAC,GAAGA,iBAAS,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACnG,QAAQ,QAAQF,gBAAK,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,CAAC,EAAE;AAC3F,KAAK,CAAC,EAAE;AACR;;;;;;;"}
@@ -41,7 +41,7 @@ var ApolloConsumer = function (props) {
41
41
  var ApolloContext = getApolloContext();
42
42
  return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
43
43
  globals.__DEV__ ? globals.invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
44
- 'Wrap the root component in an <ApolloProvider>.') : globals.invariant(context && context.client, 28);
44
+ 'Wrap the root component in an <ApolloProvider>.') : globals.invariant(context && context.client, 29);
45
45
  return props.children(context.client);
46
46
  }));
47
47
  };
@@ -58,7 +58,7 @@ var ApolloProvider = function (_a) {
58
58
  context = Object.assign({}, context, { suspenseCache: suspenseCache });
59
59
  }
60
60
  globals.__DEV__ ? globals.invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
61
- 'sure you pass in your client via the "client" prop.') : globals.invariant(context.client, 29);
61
+ 'sure you pass in your client via the "client" prop.') : globals.invariant(context.client, 30);
62
62
  return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
63
63
  }));
64
64
  };
@@ -35,7 +35,7 @@ var GraphQLBase = (function (_super) {
35
35
  }
36
36
  GraphQLBase.prototype.getWrappedInstance = function () {
37
37
  __DEV__ ? invariant(this.withRef, "To access the wrapped instance, you need to specify " +
38
- "{ withRef: true } in the options") : invariant(this.withRef, 30);
38
+ "{ withRef: true } in the options") : invariant(this.withRef, 31);
39
39
  return this.wrappedInstance;
40
40
  };
41
41
  GraphQLBase.prototype.setWrappedInstance = function (ref) {
package/react/hoc/hoc.cjs CHANGED
@@ -60,7 +60,7 @@ var GraphQLBase = (function (_super) {
60
60
  }
61
61
  GraphQLBase.prototype.getWrappedInstance = function () {
62
62
  globals.__DEV__ ? globals.invariant(this.withRef, "To access the wrapped instance, you need to specify " +
63
- "{ withRef: true } in the options") : globals.invariant(this.withRef, 30);
63
+ "{ withRef: true } in the options") : globals.invariant(this.withRef, 31);
64
64
  return this.wrappedInstance;
65
65
  };
66
66
  GraphQLBase.prototype.setWrappedInstance = function (ref) {
@@ -292,7 +292,7 @@ function withApollo(WrappedComponent, operationOptions) {
292
292
  }
293
293
  WithApollo.prototype.getWrappedInstance = function () {
294
294
  globals.__DEV__ ? globals.invariant(operationOptions.withRef, "To access the wrapped instance, you need to specify " +
295
- "{ withRef: true } in the options") : globals.invariant(operationOptions.withRef, 31);
295
+ "{ withRef: true } in the options") : globals.invariant(operationOptions.withRef, 32);
296
296
  return this.wrappedInstance;
297
297
  };
298
298
  WithApollo.prototype.setWrappedInstance = function (ref) {