@apollo/client 3.14.0-alpha.0 → 3.14.0-alpha.1

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 (198) hide show
  1. package/.changeset/breezy-lions-rule.md +5 -0
  2. package/.changeset/great-jobs-fetch.md +5 -0
  3. package/.changeset/pre.json +4 -1
  4. package/.changeset/tidy-bulldogs-exercise.md +5 -0
  5. package/CHANGELOG.md +10 -0
  6. package/apollo-client.cjs +187 -119
  7. package/apollo-client.cjs.map +1 -1
  8. package/apollo-client.min.cjs +1 -1
  9. package/cache/cache.cjs +7 -2
  10. package/cache/cache.cjs.map +1 -1
  11. package/cache/cache.cjs.native.js +7 -2
  12. package/cache/inmemory/inMemoryCache.d.ts +8 -0
  13. package/cache/inmemory/inMemoryCache.js +3 -0
  14. package/cache/inmemory/inMemoryCache.js.map +1 -1
  15. package/core/ApolloClient.d.ts +9 -9
  16. package/core/ApolloClient.js +6 -1
  17. package/core/ApolloClient.js.map +1 -1
  18. package/core/LocalState.js +2 -2
  19. package/core/ObservableQuery.d.ts +51 -6
  20. package/core/ObservableQuery.js +89 -13
  21. package/core/ObservableQuery.js.map +1 -1
  22. package/core/QueryInfo.js +6 -3
  23. package/core/QueryInfo.js.map +1 -1
  24. package/core/QueryManager.js +14 -12
  25. package/core/QueryManager.js.map +1 -1
  26. package/core/core.cjs +85 -33
  27. package/core/core.cjs.map +1 -1
  28. package/core/core.cjs.native.js +85 -33
  29. package/core/types.d.ts +177 -3
  30. package/core/types.js.map +1 -1
  31. package/core/watchQueryOptions.d.ts +10 -2
  32. package/core/watchQueryOptions.js.map +1 -1
  33. package/dev/dev.cjs +149 -97
  34. package/dev/dev.cjs.map +1 -1
  35. package/dev/dev.cjs.native.js +149 -97
  36. package/errors/errors.cjs.map +1 -1
  37. package/errors/index.d.ts +19 -0
  38. package/errors/index.js +19 -0
  39. package/errors/index.js.map +1 -1
  40. package/invariantErrorCodes.js +161 -96
  41. package/link/batch-http/batch-http.cjs +9 -0
  42. package/link/batch-http/batch-http.cjs.map +1 -1
  43. package/link/batch-http/batch-http.cjs.native.js +9 -0
  44. package/link/batch-http/batchHttpLink.js +9 -0
  45. package/link/batch-http/batchHttpLink.js.map +1 -1
  46. package/link/core/ApolloLink.d.ts +8 -0
  47. package/link/core/ApolloLink.js +19 -2
  48. package/link/core/ApolloLink.js.map +1 -1
  49. package/link/core/core.cjs +24 -2
  50. package/link/core/core.cjs.map +1 -1
  51. package/link/core/core.cjs.native.js +24 -2
  52. package/link/core/types.d.ts +20 -0
  53. package/link/core/types.js.map +1 -1
  54. package/link/error/index.d.ts +48 -0
  55. package/link/error/index.js.map +1 -1
  56. package/link/http/checkFetcher.js +1 -1
  57. package/link/http/createHttpLink.js +4 -1
  58. package/link/http/createHttpLink.js.map +1 -1
  59. package/link/http/http.cjs +6 -3
  60. package/link/http/http.cjs.map +1 -1
  61. package/link/http/http.cjs.native.js +6 -3
  62. package/link/http/serializeFetchParameter.js +1 -1
  63. package/link/persisted-queries/index.d.ts +38 -0
  64. package/link/persisted-queries/index.js +2 -2
  65. package/link/persisted-queries/index.js.map +1 -1
  66. package/link/persisted-queries/persisted-queries.cjs +2 -2
  67. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  68. package/link/persisted-queries/persisted-queries.cjs.native.js +2 -2
  69. package/link/utils/fromError.d.ts +16 -0
  70. package/link/utils/fromError.js +16 -0
  71. package/link/utils/fromError.js.map +1 -1
  72. package/link/utils/fromPromise.d.ts +16 -0
  73. package/link/utils/fromPromise.js +16 -0
  74. package/link/utils/fromPromise.js.map +1 -1
  75. package/link/utils/throwServerError.d.ts +30 -0
  76. package/link/utils/throwServerError.js +17 -0
  77. package/link/utils/throwServerError.js.map +1 -1
  78. package/link/utils/toPromise.d.ts +16 -0
  79. package/link/utils/toPromise.js +17 -1
  80. package/link/utils/toPromise.js.map +1 -1
  81. package/link/utils/utils.cjs +2 -2
  82. package/link/utils/utils.cjs.map +1 -1
  83. package/link/utils/utils.cjs.native.js +2 -2
  84. package/link/utils/validateOperation.js +1 -1
  85. package/masking/maskDefinition.js +2 -2
  86. package/masking/maskFragment.js +2 -2
  87. package/masking/maskOperation.js +1 -1
  88. package/masking/masking.cjs +6 -6
  89. package/masking/masking.cjs.map +1 -1
  90. package/masking/masking.cjs.native.js +6 -6
  91. package/masking/utils.js +1 -1
  92. package/masking/utils.js.map +1 -1
  93. package/package.json +1 -1
  94. package/react/components/Mutation.js +1 -1
  95. package/react/components/Query.js +1 -1
  96. package/react/components/Subscription.js +1 -1
  97. package/react/components/components.cjs +6 -4
  98. package/react/components/components.cjs.map +1 -1
  99. package/react/components/components.cjs.native.js +6 -4
  100. package/react/context/ApolloConsumer.js +1 -1
  101. package/react/context/ApolloContext.js +2 -2
  102. package/react/context/ApolloProvider.js +1 -1
  103. package/react/context/context.cjs +4 -4
  104. package/react/context/context.cjs.map +1 -1
  105. package/react/context/context.cjs.native.js +4 -4
  106. package/react/hoc/graphql.js +1 -1
  107. package/react/hoc/hoc-utils.js +1 -1
  108. package/react/hoc/hoc.cjs +9 -7
  109. package/react/hoc/hoc.cjs.map +1 -1
  110. package/react/hoc/hoc.cjs.native.js +9 -7
  111. package/react/hoc/mutation-hoc.js +1 -1
  112. package/react/hoc/query-hoc.js +1 -1
  113. package/react/hoc/subscription-hoc.js +1 -1
  114. package/react/hoc/withApollo.js +1 -1
  115. package/react/hooks/hooks.cjs +18 -16
  116. package/react/hooks/hooks.cjs.map +1 -1
  117. package/react/hooks/hooks.cjs.native.js +18 -16
  118. package/react/hooks/internal/useWarnRemoved.d.ts +2 -1
  119. package/react/hooks/internal/useWarnRemoved.js.map +1 -1
  120. package/react/hooks/internal/useWarnRemovedOption.js +1 -1
  121. package/react/hooks/useApolloClient.js +1 -1
  122. package/react/hooks/useLazyQuery.js +2 -2
  123. package/react/hooks/useLoadableQuery.js +2 -2
  124. package/react/hooks/useQuery.js +1 -1
  125. package/react/hooks/useSubscription.js +3 -3
  126. package/react/hooks/useSuspenseQuery.js +2 -2
  127. package/react/hooks/useSyncExternalStore.js +1 -1
  128. package/react/internal/cache/QueryReference.d.ts +1 -0
  129. package/react/internal/cache/QueryReference.js +5 -2
  130. package/react/internal/cache/QueryReference.js.map +1 -1
  131. package/react/internal/internal.cjs +16 -3
  132. package/react/internal/internal.cjs.map +1 -1
  133. package/react/internal/internal.cjs.native.js +16 -3
  134. package/react/parser/index.js +6 -6
  135. package/react/parser/parser.cjs +9 -7
  136. package/react/parser/parser.cjs.map +1 -1
  137. package/react/parser/parser.cjs.native.js +9 -7
  138. package/react/react.cjs +4 -2
  139. package/react/react.cjs.map +1 -1
  140. package/react/react.cjs.native.js +4 -2
  141. package/react/types/types.d.ts +40 -0
  142. package/react/types/types.documentation.d.ts +1 -1
  143. package/react/types/types.documentation.js.map +1 -1
  144. package/react/types/types.js.map +1 -1
  145. package/testing/core/core.cjs +17 -3
  146. package/testing/core/core.cjs.map +1 -1
  147. package/testing/core/core.cjs.native.js +17 -3
  148. package/testing/core/itAsync.d.ts +5 -0
  149. package/testing/core/itAsync.js +5 -0
  150. package/testing/core/itAsync.js.map +1 -1
  151. package/testing/core/mocking/mockClient.d.ts +4 -0
  152. package/testing/core/mocking/mockClient.js +4 -0
  153. package/testing/core/mocking/mockClient.js.map +1 -1
  154. package/testing/core/mocking/mockLink.d.ts +10 -0
  155. package/testing/core/mocking/mockLink.js +23 -4
  156. package/testing/core/mocking/mockLink.js.map +1 -1
  157. package/testing/core/mocking/mockSubscriptionLink.d.ts +4 -0
  158. package/testing/core/mocking/mockSubscriptionLink.js +4 -0
  159. package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
  160. package/testing/core/subscribeAndCount.d.ts +4 -0
  161. package/testing/core/subscribeAndCount.js +4 -0
  162. package/testing/core/subscribeAndCount.js.map +1 -1
  163. package/testing/experimental/createSchemaFetch.d.ts +1 -1
  164. package/testing/experimental/createSchemaFetch.js +1 -1
  165. package/testing/experimental/createSchemaFetch.js.map +1 -1
  166. package/testing/experimental/createTestSchema.d.ts +1 -1
  167. package/testing/experimental/createTestSchema.js +1 -1
  168. package/testing/experimental/createTestSchema.js.map +1 -1
  169. package/testing/experimental/experimental.cjs.map +1 -1
  170. package/testing/testing.cjs +4 -2
  171. package/testing/testing.cjs.map +1 -1
  172. package/testing/testing.cjs.native.js +4 -2
  173. package/utilities/deprecation/index.d.ts +83 -3
  174. package/utilities/deprecation/index.js +15 -3
  175. package/utilities/deprecation/index.js.map +1 -1
  176. package/utilities/globals/globals.cjs +1 -1
  177. package/utilities/globals/globals.cjs.map +1 -1
  178. package/utilities/globals/globals.cjs.native.js +1 -1
  179. package/utilities/graphql/DocumentTransform.js +1 -1
  180. package/utilities/graphql/directives.js +7 -7
  181. package/utilities/graphql/fragments.js +3 -3
  182. package/utilities/graphql/getFromAST.js +8 -8
  183. package/utilities/graphql/storeUtils.js +1 -1
  184. package/utilities/graphql/transform.js +2 -2
  185. package/utilities/observables/asyncMap.d.ts +13 -0
  186. package/utilities/observables/asyncMap.js +13 -0
  187. package/utilities/observables/asyncMap.js.map +1 -1
  188. package/utilities/observables/iteration.d.ts +4 -0
  189. package/utilities/observables/iteration.js +4 -0
  190. package/utilities/observables/iteration.js.map +1 -1
  191. package/utilities/subscriptions/urql/index.d.ts +5 -0
  192. package/utilities/subscriptions/urql/index.js +5 -0
  193. package/utilities/subscriptions/urql/index.js.map +1 -1
  194. package/utilities/subscriptions/urql/urql.cjs.map +1 -1
  195. package/utilities/utilities.cjs +22 -22
  196. package/utilities/utilities.cjs.map +1 -1
  197. package/utilities/utilities.cjs.native.js +22 -22
  198. package/version.js +1 -1
@@ -9,6 +9,7 @@ var utils = require('../utils');
9
9
  var http = require('../http');
10
10
  var batch = require('../batch');
11
11
  var graphql = require('graphql');
12
+ var globals = require('../../utilities/globals');
12
13
 
13
14
  function filterOperationVariables(variables, query) {
14
15
  var result = tslib.__assign({}, variables);
@@ -65,6 +66,14 @@ var BatchHttpLink = (function (_super) {
65
66
  credentials: context.credentials,
66
67
  headers: tslib.__assign(tslib.__assign({}, clientAwarenessHeaders), context.headers),
67
68
  };
69
+ if (globalThis.__DEV__ !== false) {
70
+ if (operations.some(function (_a) {
71
+ var query = _a.query;
72
+ return utilities.hasDirectives(["client"], query);
73
+ })) {
74
+ globalThis.__DEV__ !== false && globals.invariant.warn(46);
75
+ }
76
+ }
68
77
  var queries = operations.map(function (_a) {
69
78
  var query = _a.query;
70
79
  if (utilities.hasDirectives(["client"], query)) {
@@ -1 +1 @@
1
- {"version":3,"file":"batch-http.cjs","sources":["../utils/filterOperationVariables.js","batchHttpLink.js"],"sourcesContent":["import { __assign } from \"tslib\";\nimport { visit } from \"graphql\";\nexport function filterOperationVariables(variables, query) {\n var result = __assign({}, variables);\n var unusedNames = new Set(Object.keys(variables));\n visit(query, {\n Variable: function (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 &&\n 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","import { __assign, __extends, __rest } from \"tslib\";\nimport { ApolloLink } from \"../core/index.js\";\nimport { Observable, hasDirectives, maybe, removeClientSetsFromDocument, } from \"../../utilities/index.js\";\nimport { fromError } from \"../utils/index.js\";\nimport { serializeFetchParameter, selectURI, parseAndCheckHttpResponse, checkFetcher, selectHttpOptionsAndBodyInternal, defaultPrinter, fallbackHttpConfig, } from \"../http/index.js\";\nimport { BatchLink } from \"../batch/index.js\";\nimport { filterOperationVariables } from \"../utils/filterOperationVariables.js\";\nvar backupFetch = maybe(function () { return fetch; });\n/**\n * Transforms Operation for into HTTP results.\n * context can include the headers property, which will be passed to the fetch function\n */\nvar BatchHttpLink = /** @class */ (function (_super) {\n __extends(BatchHttpLink, _super);\n function BatchHttpLink(fetchParams) {\n var _this = _super.call(this) || this;\n var _a = fetchParams || {}, _b = _a.uri, uri = _b === void 0 ? \"/graphql\" : _b, \n // use default global fetch if nothing is passed in\n preferredFetch = _a.fetch, _c = _a.print, print = _c === void 0 ? defaultPrinter : _c, includeExtensions = _a.includeExtensions, preserveHeaderCase = _a.preserveHeaderCase, batchInterval = _a.batchInterval, batchDebounce = _a.batchDebounce, batchMax = _a.batchMax, batchKey = _a.batchKey, _d = _a.includeUnusedVariables, includeUnusedVariables = _d === void 0 ? false : _d, requestOptions = __rest(_a, [\"uri\", \"fetch\", \"print\", \"includeExtensions\", \"preserveHeaderCase\", \"batchInterval\", \"batchDebounce\", \"batchMax\", \"batchKey\", \"includeUnusedVariables\"]);\n if (globalThis.__DEV__ !== false) {\n // Make sure at least one of preferredFetch, window.fetch, or backupFetch\n // is defined, so requests won't fail at runtime.\n checkFetcher(preferredFetch || backupFetch);\n }\n var linkConfig = {\n http: { includeExtensions: includeExtensions, preserveHeaderCase: preserveHeaderCase },\n options: requestOptions.fetchOptions,\n credentials: requestOptions.credentials,\n headers: requestOptions.headers,\n };\n _this.batchDebounce = batchDebounce;\n _this.batchInterval = batchInterval || 10;\n _this.batchMax = batchMax || 10;\n var batchHandler = function (operations) {\n var chosenURI = selectURI(operations[0], uri);\n var context = operations[0].getContext();\n var clientAwarenessHeaders = {};\n if (context.clientAwareness) {\n var _a = context.clientAwareness, name_1 = _a.name, version = _a.version;\n if (name_1) {\n clientAwarenessHeaders[\"apollographql-client-name\"] = name_1;\n }\n if (version) {\n clientAwarenessHeaders[\"apollographql-client-version\"] = version;\n }\n }\n var contextConfig = {\n http: context.http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: __assign(__assign({}, clientAwarenessHeaders), context.headers),\n };\n var queries = operations.map(function (_a) {\n var query = _a.query;\n if (hasDirectives([\"client\"], query)) {\n return removeClientSetsFromDocument(query);\n }\n return query;\n });\n // If we have a query that returned `null` after removing client-only\n // fields, it indicates a query that is using all client-only fields.\n if (queries.some(function (query) { return !query; })) {\n return fromError(new Error(\"BatchHttpLink: Trying to send a client-only query to the server. To send to the server, ensure a non-client field is added to the query or enable the `transformOptions.removeClientFields` option.\"));\n }\n //uses fallback, link, and then context to build options\n var optsAndBody = operations.map(function (operation, index) {\n var result = selectHttpOptionsAndBodyInternal(__assign(__assign({}, operation), { query: queries[index] }), print, fallbackHttpConfig, linkConfig, contextConfig);\n if (result.body.variables && !includeUnusedVariables) {\n result.body.variables = filterOperationVariables(result.body.variables, operation.query);\n }\n return result;\n });\n var loadedBody = optsAndBody.map(function (_a) {\n var body = _a.body;\n return body;\n });\n var options = optsAndBody[0].options;\n // There's no spec for using GET with batches.\n if (options.method === \"GET\") {\n return fromError(new Error(\"apollo-link-batch-http does not support GET requests\"));\n }\n try {\n options.body = serializeFetchParameter(loadedBody, \"Payload\");\n }\n catch (parseError) {\n return fromError(parseError);\n }\n var controller;\n if (!options.signal && typeof AbortController !== \"undefined\") {\n controller = new AbortController();\n options.signal = controller.signal;\n }\n return new Observable(function (observer) {\n // Prefer BatchHttpLink.Options.fetch (preferredFetch) if provided, and\n // otherwise fall back to the *current* global window.fetch function\n // (see issue #7832), or (if all else fails) the backupFetch function we\n // saved when this module was first evaluated. This last option protects\n // against the removal of window.fetch, which is unlikely but not\n // impossible.\n var currentFetch = preferredFetch || maybe(function () { return fetch; }) || backupFetch;\n currentFetch(chosenURI, options)\n .then(function (response) {\n // Make the raw response available in the context.\n operations.forEach(function (operation) {\n return operation.setContext({ response: response });\n });\n return response;\n })\n .then(parseAndCheckHttpResponse(operations))\n .then(function (result) {\n controller = undefined;\n // we have data and can send it to back up the link chain\n observer.next(result);\n observer.complete();\n return result;\n })\n .catch(function (err) {\n controller = undefined;\n // if it is a network error, BUT there is graphql result info\n // fire the next observer before calling error\n // this gives apollo-client (and react-apollo) the `graphqlErrors` and `networkErrors`\n // to pass to UI\n // this should only happen if we *also* have data as part of the response key per\n // the spec\n if (err.result && err.result.errors && err.result.data) {\n // if we dont' call next, the UI can only show networkError because AC didn't\n // get andy graphqlErrors\n // this is graphql execution result info (i.e errors and possibly data)\n // this is because there is no formal spec how errors should translate to\n // http status codes. So an auth error (401) could have both data\n // from a public field, errors from a private field, and a status of 401\n // {\n // user { // this will have errors\n // firstName\n // }\n // products { // this is public so will have data\n // cost\n // }\n // }\n //\n // the result of above *could* look like this:\n // {\n // data: { products: [{ cost: \"$10\" }] },\n // errors: [{\n // message: 'your session has timed out',\n // path: []\n // }]\n // }\n // status code of above would be a 401\n // in the UI you want to show data where you can, errors as data where you can\n // and use correct http status codes\n observer.next(err.result);\n }\n observer.error(err);\n });\n return function () {\n // XXX support canceling this request\n // https://developers.google.com/web/updates/2017/09/abortable-fetch\n if (controller)\n controller.abort();\n };\n });\n };\n batchKey =\n batchKey ||\n (function (operation) {\n var context = operation.getContext();\n var contextConfig = {\n http: context.http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: context.headers,\n };\n //may throw error if config not serializable\n return selectURI(operation, uri) + JSON.stringify(contextConfig);\n });\n _this.batcher = new BatchLink({\n batchDebounce: _this.batchDebounce,\n batchInterval: _this.batchInterval,\n batchMax: _this.batchMax,\n batchKey: batchKey,\n batchHandler: batchHandler,\n });\n return _this;\n }\n BatchHttpLink.prototype.request = function (operation) {\n return this.batcher.request(operation);\n };\n return BatchHttpLink;\n}(ApolloLink));\nexport { BatchHttpLink };\n//# sourceMappingURL=batchHttpLink.js.map"],"names":["__assign","visit","maybe","__extends","defaultPrinter","__rest","checkFetcher","selectURI","hasDirectives","removeClientSetsFromDocument","fromError","selectHttpOptionsAndBodyInternal","fallbackHttpConfig","serializeFetchParameter","Observable","parseAndCheckHttpResponse","BatchLink","ApolloLink"],"mappings":";;;;;;;;;;;;AAEO,SAAS,wBAAwB,CAAC,SAAS,EAAE,KAAK,EAAE;AAC3D,IAAI,IAAI,MAAM,GAAGA,cAAQ,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;AACzC,IAAI,IAAI,WAAW,GAAG,IAAI,G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C3D,QAAQ,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAC/C,KAAK,CAAC;AACN,IAAI,OAAO,aAAa,CAAC;AACzB,CAAC,CAACC,eAAU,CAAC;;;;"}
1
+ {"version":3,"file":"batch-http.cjs","sources":["../utils/filterOperationVariables.js","batchHttpLink.js"],"sourcesContent":["import { __assign } from \"tslib\";\nimport { visit } from \"graphql\";\nexport function filterOperationVariables(variables, query) {\n var result = __assign({}, variables);\n var unusedNames = new Set(Object.keys(variables));\n visit(query, {\n Variable: function (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 &&\n 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","import { __assign, __extends, __rest } from \"tslib\";\nimport { ApolloLink } from \"../core/index.js\";\nimport { Observable, hasDirectives, maybe, removeClientSetsFromDocument, } from \"../../utilities/index.js\";\nimport { fromError } from \"../utils/index.js\";\nimport { serializeFetchParameter, selectURI, parseAndCheckHttpResponse, checkFetcher, selectHttpOptionsAndBodyInternal, defaultPrinter, fallbackHttpConfig, } from \"../http/index.js\";\nimport { BatchLink } from \"../batch/index.js\";\nimport { filterOperationVariables } from \"../utils/filterOperationVariables.js\";\nimport { invariant } from \"../../utilities/globals/index.js\";\nvar backupFetch = maybe(function () { return fetch; });\n/**\n * Transforms Operation for into HTTP results.\n * context can include the headers property, which will be passed to the fetch function\n */\nvar BatchHttpLink = /** @class */ (function (_super) {\n __extends(BatchHttpLink, _super);\n function BatchHttpLink(fetchParams) {\n var _this = _super.call(this) || this;\n var _a = fetchParams || {}, _b = _a.uri, uri = _b === void 0 ? \"/graphql\" : _b, \n // use default global fetch if nothing is passed in\n preferredFetch = _a.fetch, _c = _a.print, print = _c === void 0 ? defaultPrinter : _c, includeExtensions = _a.includeExtensions, preserveHeaderCase = _a.preserveHeaderCase, batchInterval = _a.batchInterval, batchDebounce = _a.batchDebounce, batchMax = _a.batchMax, batchKey = _a.batchKey, _d = _a.includeUnusedVariables, includeUnusedVariables = _d === void 0 ? false : _d, requestOptions = __rest(_a, [\"uri\", \"fetch\", \"print\", \"includeExtensions\", \"preserveHeaderCase\", \"batchInterval\", \"batchDebounce\", \"batchMax\", \"batchKey\", \"includeUnusedVariables\"]);\n if (globalThis.__DEV__ !== false) {\n // Make sure at least one of preferredFetch, window.fetch, or backupFetch\n // is defined, so requests won't fail at runtime.\n checkFetcher(preferredFetch || backupFetch);\n }\n var linkConfig = {\n http: { includeExtensions: includeExtensions, preserveHeaderCase: preserveHeaderCase },\n options: requestOptions.fetchOptions,\n credentials: requestOptions.credentials,\n headers: requestOptions.headers,\n };\n _this.batchDebounce = batchDebounce;\n _this.batchInterval = batchInterval || 10;\n _this.batchMax = batchMax || 10;\n var batchHandler = function (operations) {\n var chosenURI = selectURI(operations[0], uri);\n var context = operations[0].getContext();\n var clientAwarenessHeaders = {};\n if (context.clientAwareness) {\n var _a = context.clientAwareness, name_1 = _a.name, version = _a.version;\n if (name_1) {\n clientAwarenessHeaders[\"apollographql-client-name\"] = name_1;\n }\n if (version) {\n clientAwarenessHeaders[\"apollographql-client-version\"] = version;\n }\n }\n var contextConfig = {\n http: context.http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: __assign(__assign({}, clientAwarenessHeaders), context.headers),\n };\n if (globalThis.__DEV__ !== false) {\n if (operations.some(function (_a) {\n var query = _a.query;\n return hasDirectives([\"client\"], query);\n })) {\n globalThis.__DEV__ !== false && invariant.warn(46);\n }\n }\n var queries = operations.map(function (_a) {\n var query = _a.query;\n if (hasDirectives([\"client\"], query)) {\n return removeClientSetsFromDocument(query);\n }\n return query;\n });\n // If we have a query that returned `null` after removing client-only\n // fields, it indicates a query that is using all client-only fields.\n if (queries.some(function (query) { return !query; })) {\n return fromError(new Error(\"BatchHttpLink: Trying to send a client-only query to the server. To send to the server, ensure a non-client field is added to the query or enable the `transformOptions.removeClientFields` option.\"));\n }\n //uses fallback, link, and then context to build options\n var optsAndBody = operations.map(function (operation, index) {\n var result = selectHttpOptionsAndBodyInternal(__assign(__assign({}, operation), { query: queries[index] }), print, fallbackHttpConfig, linkConfig, contextConfig);\n if (result.body.variables && !includeUnusedVariables) {\n result.body.variables = filterOperationVariables(result.body.variables, operation.query);\n }\n return result;\n });\n var loadedBody = optsAndBody.map(function (_a) {\n var body = _a.body;\n return body;\n });\n var options = optsAndBody[0].options;\n // There's no spec for using GET with batches.\n if (options.method === \"GET\") {\n return fromError(new Error(\"apollo-link-batch-http does not support GET requests\"));\n }\n try {\n options.body = serializeFetchParameter(loadedBody, \"Payload\");\n }\n catch (parseError) {\n return fromError(parseError);\n }\n var controller;\n if (!options.signal && typeof AbortController !== \"undefined\") {\n controller = new AbortController();\n options.signal = controller.signal;\n }\n return new Observable(function (observer) {\n // Prefer BatchHttpLink.Options.fetch (preferredFetch) if provided, and\n // otherwise fall back to the *current* global window.fetch function\n // (see issue #7832), or (if all else fails) the backupFetch function we\n // saved when this module was first evaluated. This last option protects\n // against the removal of window.fetch, which is unlikely but not\n // impossible.\n var currentFetch = preferredFetch || maybe(function () { return fetch; }) || backupFetch;\n currentFetch(chosenURI, options)\n .then(function (response) {\n // Make the raw response available in the context.\n operations.forEach(function (operation) {\n return operation.setContext({ response: response });\n });\n return response;\n })\n .then(parseAndCheckHttpResponse(operations))\n .then(function (result) {\n controller = undefined;\n // we have data and can send it to back up the link chain\n observer.next(result);\n observer.complete();\n return result;\n })\n .catch(function (err) {\n controller = undefined;\n // if it is a network error, BUT there is graphql result info\n // fire the next observer before calling error\n // this gives apollo-client (and react-apollo) the `graphqlErrors` and `networkErrors`\n // to pass to UI\n // this should only happen if we *also* have data as part of the response key per\n // the spec\n if (err.result && err.result.errors && err.result.data) {\n // if we dont' call next, the UI can only show networkError because AC didn't\n // get andy graphqlErrors\n // this is graphql execution result info (i.e errors and possibly data)\n // this is because there is no formal spec how errors should translate to\n // http status codes. So an auth error (401) could have both data\n // from a public field, errors from a private field, and a status of 401\n // {\n // user { // this will have errors\n // firstName\n // }\n // products { // this is public so will have data\n // cost\n // }\n // }\n //\n // the result of above *could* look like this:\n // {\n // data: { products: [{ cost: \"$10\" }] },\n // errors: [{\n // message: 'your session has timed out',\n // path: []\n // }]\n // }\n // status code of above would be a 401\n // in the UI you want to show data where you can, errors as data where you can\n // and use correct http status codes\n observer.next(err.result);\n }\n observer.error(err);\n });\n return function () {\n // XXX support canceling this request\n // https://developers.google.com/web/updates/2017/09/abortable-fetch\n if (controller)\n controller.abort();\n };\n });\n };\n batchKey =\n batchKey ||\n (function (operation) {\n var context = operation.getContext();\n var contextConfig = {\n http: context.http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: context.headers,\n };\n //may throw error if config not serializable\n return selectURI(operation, uri) + JSON.stringify(contextConfig);\n });\n _this.batcher = new BatchLink({\n batchDebounce: _this.batchDebounce,\n batchInterval: _this.batchInterval,\n batchMax: _this.batchMax,\n batchKey: batchKey,\n batchHandler: batchHandler,\n });\n return _this;\n }\n BatchHttpLink.prototype.request = function (operation) {\n return this.batcher.request(operation);\n };\n return BatchHttpLink;\n}(ApolloLink));\nexport { BatchHttpLink };\n//# sourceMappingURL=batchHttpLink.js.map"],"names":["__assign","visit","maybe","__extends","defaultPrinter","__rest","checkFetcher","selectURI","hasDirectives","invariant","removeClientSetsFromDocument","fromError","selectHttpOptionsAndBodyInternal","fallbackHttpConfig","serializeFetchParameter","Observable","parseAndCheckHttpResponse","BatchLink","ApolloLink"],"mappings":";;;;;;;;;;;;;AAEO,SAAS,wBAAwB,CAAC,SAAS,EAAE,KAAK,EAAE;AAC3D,IAAI,IAAI,MAAM,GAAGA,cAAQ,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;AACzC,IAAI,IAAI,WAAW,GAAG,I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iBAAiB,CAAC,CAAC;AACnB,QAAQ,KAAK,CAAC,OAAO,GAAG,IAAIU,eAAS,CAAC;AACtC,YAAY,aAAa,EAAE,KAAK,CAAC,aAAa;AAC9C,YAAY,aAAa,EAAE,KAAK,CAAC,aAAa;AAC9C,YAAY,QAAQ,EAAE,KAAK,CAAC,QAAQ;AACpC,YAAY,QAAQ,EAAE,QAAQ;AAC9B,YAAY,YAAY,EAAE,YAAY;AACtC,SAAS,CAAC,CAAC;AACX,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,aAAa,CAAC,SAAS,CAAC,OAAO,GAAG,UAAU,SAAS,EAAE;AAC3D,QAAQ,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAC/C,KAAK,CAAC;AACN,IAAI,OAAO,aAAa,CAAC;AACzB,CAAC,CAACC,eAAU,CAAC;;;;"}
@@ -9,6 +9,7 @@ var utils = require('../utils');
9
9
  var http = require('../http');
10
10
  var batch = require('../batch');
11
11
  var graphql = require('graphql');
12
+ var globals = require('../../utilities/globals');
12
13
 
13
14
  function filterOperationVariables(variables, query) {
14
15
  var result = tslib.__assign({}, variables);
@@ -65,6 +66,14 @@ var BatchHttpLink = (function (_super) {
65
66
  credentials: context.credentials,
66
67
  headers: tslib.__assign(tslib.__assign({}, clientAwarenessHeaders), context.headers),
67
68
  };
69
+ if (globalThis.__DEV__ !== false) {
70
+ if (operations.some(function (_a) {
71
+ var query = _a.query;
72
+ return utilities.hasDirectives(["client"], query);
73
+ })) {
74
+ globalThis.__DEV__ !== false && globals.invariant.warn(46);
75
+ }
76
+ }
68
77
  var queries = operations.map(function (_a) {
69
78
  var query = _a.query;
70
79
  if (utilities.hasDirectives(["client"], query)) {
@@ -5,6 +5,7 @@ import { fromError } from "../utils/index.js";
5
5
  import { serializeFetchParameter, selectURI, parseAndCheckHttpResponse, checkFetcher, selectHttpOptionsAndBodyInternal, defaultPrinter, fallbackHttpConfig, } from "../http/index.js";
6
6
  import { BatchLink } from "../batch/index.js";
7
7
  import { filterOperationVariables } from "../utils/filterOperationVariables.js";
8
+ import { invariant } from "../../utilities/globals/index.js";
8
9
  var backupFetch = maybe(function () { return fetch; });
9
10
  /**
10
11
  * Transforms Operation for into HTTP results.
@@ -50,6 +51,14 @@ var BatchHttpLink = /** @class */ (function (_super) {
50
51
  credentials: context.credentials,
51
52
  headers: __assign(__assign({}, clientAwarenessHeaders), context.headers),
52
53
  };
54
+ if (globalThis.__DEV__ !== false) {
55
+ if (operations.some(function (_a) {
56
+ var query = _a.query;
57
+ return hasDirectives(["client"], query);
58
+ })) {
59
+ globalThis.__DEV__ !== false && invariant.warn(46);
60
+ }
61
+ }
53
62
  var queries = operations.map(function (_a) {
54
63
  var query = _a.query;
55
64
  if (hasDirectives(["client"], query)) {
@@ -1 +1 @@
1
- {"version":3,"file":"batchHttpLink.js","sourceRoot":"","sources":["../../../src/link/batch-http/batchHttpLink.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,UAAU,EACV,aAAa,EACb,KAAK,EACL,4BAA4B,GAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,yBAAyB,EACzB,YAAY,EACZ,gCAAgC,EAChC,cAAc,EACd,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAUhF,IAAM,WAAW,GAAG,KAAK,CAAC,cAAM,OAAA,KAAK,EAAL,CAAK,CAAC,CAAC;AAEvC;;;GAGG;AACH;IAAmC,iCAAU;IAM3C,uBAAY,WAAmC;QAC7C,YAAA,MAAK,WAAE,SAAC;QAER,IAAI,KAaA,WAAW,IAAK,EAA4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EAAoE;oBACpE,IAAI,UAAU;wBAAE,UAAU,CAAC,KAAK,EAAE,CAAC;gBACrC,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,QAAQ;YACN,QAAQ;gBACR,CAAC,UAAC,SAAoB;oBACpB,IAAM,OAAO,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;oBAEvC,IAAM,aAAa,GAAG;wBACpB,IAAI,EAAE,OAAO,CAAC,IAAI;wBAClB,OAAO,EAAE,OAAO,CAAC,YAAY;wBAC7B,WAAW,EAAE,OAAO,CAAC,WAAW;wBAChC,OAAO,EAAE,OAAO,CAAC,OAAO;qBACzB,CAAC;oBAEF,4CAA4C;oBAC5C,OAAO,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;gBACnE,CAAC,CAAC,CAAC;QAEL,KAAI,CAAC,OAAO,GAAG,IAAI,SAAS,CAAC;YAC3B,aAAa,EAAE,KAAI,CAAC,aAAa;YACjC,aAAa,EAAE,KAAI,CAAC,aAAa;YACjC,QAAQ,EAAE,KAAI,CAAC,QAAQ;YACvB,QAAQ,UAAA;YACR,YAAY,cAAA;SACb,CAAC,CAAC;;IACL,CAAC;IAEM,+BAAO,GAAd,UAAe,SAAoB;QACjC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC;IACH,oBAAC;AAAD,CAAC,AAtOD,CAAmC,UAAU,GAsO5C","sourcesContent":["import type { Operation, FetchResult } from \"../core/index.js\";\nimport { ApolloLink } from \"../core/index.js\";\nimport {\n Observable,\n hasDirectives,\n maybe,\n removeClientSetsFromDocument,\n} from \"../../utilities/index.js\";\nimport { fromError } from \"../utils/index.js\";\nimport type { HttpOptions } from \"../http/index.js\";\nimport {\n serializeFetchParameter,\n selectURI,\n parseAndCheckHttpResponse,\n checkFetcher,\n selectHttpOptionsAndBodyInternal,\n defaultPrinter,\n fallbackHttpConfig,\n} from \"../http/index.js\";\nimport { BatchLink } from \"../batch/index.js\";\nimport { filterOperationVariables } from \"../utils/filterOperationVariables.js\";\n\nexport namespace BatchHttpLink {\n export type Options = Pick<\n BatchLink.Options,\n \"batchMax\" | \"batchDebounce\" | \"batchInterval\" | \"batchKey\"\n > &\n Omit<HttpOptions, \"useGETForQueries\">;\n}\n\nconst backupFetch = maybe(() => fetch);\n\n/**\n * Transforms Operation for into HTTP results.\n * context can include the headers property, which will be passed to the fetch function\n */\nexport class BatchHttpLink extends ApolloLink {\n private batchDebounce?: boolean;\n private batchInterval: number;\n private batchMax: number;\n private batcher: ApolloLink;\n\n constructor(fetchParams?: BatchHttpLink.Options) {\n super();\n\n let {\n uri = \"/graphql\",\n // use default global fetch if nothing is passed in\n fetch: preferredFetch,\n print = defaultPrinter,\n includeExtensions,\n preserveHeaderCase,\n batchInterval,\n batchDebounce,\n batchMax,\n batchKey,\n includeUnusedVariables = false,\n ...requestOptions\n } = fetchParams || ({} as BatchHttpLink.Options);\n\n if (__DEV__) {\n // Make sure at least one of preferredFetch, window.fetch, or backupFetch\n // is defined, so requests won't fail at runtime.\n checkFetcher(preferredFetch || backupFetch);\n }\n\n const linkConfig = {\n http: { includeExtensions, preserveHeaderCase },\n options: requestOptions.fetchOptions,\n credentials: requestOptions.credentials,\n headers: requestOptions.headers,\n };\n\n this.batchDebounce = batchDebounce;\n this.batchInterval = batchInterval || 10;\n this.batchMax = batchMax || 10;\n\n const batchHandler = (operations: Operation[]) => {\n const chosenURI = selectURI(operations[0], uri);\n\n const context = operations[0].getContext();\n\n const clientAwarenessHeaders: {\n \"apollographql-client-name\"?: string;\n \"apollographql-client-version\"?: string;\n } = {};\n if (context.clientAwareness) {\n const { name, version } = context.clientAwareness;\n if (name) {\n clientAwarenessHeaders[\"apollographql-client-name\"] = name;\n }\n if (version) {\n clientAwarenessHeaders[\"apollographql-client-version\"] = version;\n }\n }\n\n const contextConfig = {\n http: context.http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: { ...clientAwarenessHeaders, ...context.headers },\n };\n\n const queries = operations.map(({ query }) => {\n if (hasDirectives([\"client\"], query)) {\n return removeClientSetsFromDocument(query);\n }\n\n return query;\n });\n\n // If we have a query that returned `null` after removing client-only\n // fields, it indicates a query that is using all client-only fields.\n if (queries.some((query) => !query)) {\n return fromError<FetchResult[]>(\n new Error(\n \"BatchHttpLink: Trying to send a client-only query to the server. To send to the server, ensure a non-client field is added to the query or enable the `transformOptions.removeClientFields` option.\"\n )\n );\n }\n\n //uses fallback, link, and then context to build options\n const optsAndBody = operations.map((operation, index) => {\n const result = selectHttpOptionsAndBodyInternal(\n { ...operation, query: queries[index]! },\n print,\n fallbackHttpConfig,\n linkConfig,\n contextConfig\n );\n\n if (result.body.variables && !includeUnusedVariables) {\n result.body.variables = filterOperationVariables(\n result.body.variables,\n operation.query\n );\n }\n\n return result;\n });\n\n const loadedBody = optsAndBody.map(({ body }) => body);\n const options = optsAndBody[0].options;\n\n // There's no spec for using GET with batches.\n if (options.method === \"GET\") {\n return fromError<FetchResult[]>(\n new Error(\"apollo-link-batch-http does not support GET requests\")\n );\n }\n\n try {\n (options as any).body = serializeFetchParameter(loadedBody, \"Payload\");\n } catch (parseError) {\n return fromError<FetchResult[]>(parseError);\n }\n\n let controller: AbortController | undefined;\n if (!options.signal && typeof AbortController !== \"undefined\") {\n controller = new AbortController();\n options.signal = controller.signal;\n }\n\n return new Observable<FetchResult[]>((observer) => {\n // Prefer BatchHttpLink.Options.fetch (preferredFetch) if provided, and\n // otherwise fall back to the *current* global window.fetch function\n // (see issue #7832), or (if all else fails) the backupFetch function we\n // saved when this module was first evaluated. This last option protects\n // against the removal of window.fetch, which is unlikely but not\n // impossible.\n const currentFetch =\n preferredFetch || maybe(() => fetch) || backupFetch;\n\n currentFetch!(chosenURI, options)\n .then((response) => {\n // Make the raw response available in the context.\n operations.forEach((operation) =>\n operation.setContext({ response })\n );\n return response;\n })\n .then(parseAndCheckHttpResponse(operations))\n .then((result) => {\n controller = undefined;\n // we have data and can send it to back up the link chain\n observer.next(result);\n observer.complete();\n return result;\n })\n .catch((err) => {\n controller = undefined;\n // if it is a network error, BUT there is graphql result info\n // fire the next observer before calling error\n // this gives apollo-client (and react-apollo) the `graphqlErrors` and `networkErrors`\n // to pass to UI\n // this should only happen if we *also* have data as part of the response key per\n // the spec\n if (err.result && err.result.errors && err.result.data) {\n // if we dont' call next, the UI can only show networkError because AC didn't\n // get andy graphqlErrors\n // this is graphql execution result info (i.e errors and possibly data)\n // this is because there is no formal spec how errors should translate to\n // http status codes. So an auth error (401) could have both data\n // from a public field, errors from a private field, and a status of 401\n // {\n // user { // this will have errors\n // firstName\n // }\n // products { // this is public so will have data\n // cost\n // }\n // }\n //\n // the result of above *could* look like this:\n // {\n // data: { products: [{ cost: \"$10\" }] },\n // errors: [{\n // message: 'your session has timed out',\n // path: []\n // }]\n // }\n // status code of above would be a 401\n // in the UI you want to show data where you can, errors as data where you can\n // and use correct http status codes\n observer.next(err.result);\n }\n\n observer.error(err);\n });\n\n return () => {\n // XXX support canceling this request\n // https://developers.google.com/web/updates/2017/09/abortable-fetch\n if (controller) controller.abort();\n };\n });\n };\n\n batchKey =\n batchKey ||\n ((operation: Operation) => {\n const context = operation.getContext();\n\n const contextConfig = {\n http: context.http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: context.headers,\n };\n\n //may throw error if config not serializable\n return selectURI(operation, uri) + JSON.stringify(contextConfig);\n });\n\n this.batcher = new BatchLink({\n batchDebounce: this.batchDebounce,\n batchInterval: this.batchInterval,\n batchMax: this.batchMax,\n batchKey,\n batchHandler,\n });\n }\n\n public request(operation: Operation): Observable<FetchResult> | null {\n return this.batcher.request(operation);\n }\n}\n"]}
1
+ {"version":3,"file":"batchHttpLink.js","sourceRoot":"","sources":["../../../src/link/batch-http/batchHttpLink.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAA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AE,OAAO,CAAC,WAAW;wBAChC,OAAO,EAAE,OAAO,CAAC,OAAO;qBACzB,CAAC;oBAEF,4CAA4C;oBAC5C,OAAO,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;gBACnE,CAAC,CAAC,CAAC;QAEL,KAAI,CAAC,OAAO,GAAG,IAAI,SAAS,CAAC;YAC3B,aAAa,EAAE,KAAI,CAAC,aAAa;YACjC,aAAa,EAAE,KAAI,CAAC,aAAa;YACjC,QAAQ,EAAE,KAAI,CAAC,QAAQ;YACvB,QAAQ,UAAA;YACR,YAAY,cAAA;SACb,CAAC,CAAC;;IACL,CAAC;IAEM,+BAAO,GAAd,UAAe,SAAoB;QACjC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC;IACH,oBAAC;AAAD,CAAC,AA9OD,CAAmC,UAAU,GA8O5C","sourcesContent":["import type { Operation, FetchResult } from \"../core/index.js\";\nimport { ApolloLink } from \"../core/index.js\";\nimport {\n Observable,\n hasDirectives,\n maybe,\n removeClientSetsFromDocument,\n} from \"../../utilities/index.js\";\nimport { fromError } from \"../utils/index.js\";\nimport type { HttpOptions } from \"../http/index.js\";\nimport {\n serializeFetchParameter,\n selectURI,\n parseAndCheckHttpResponse,\n checkFetcher,\n selectHttpOptionsAndBodyInternal,\n defaultPrinter,\n fallbackHttpConfig,\n} from \"../http/index.js\";\nimport { BatchLink } from \"../batch/index.js\";\nimport { filterOperationVariables } from \"../utils/filterOperationVariables.js\";\nimport { invariant } from \"../../utilities/globals/index.js\";\n\nexport namespace BatchHttpLink {\n export type Options = Pick<\n BatchLink.Options,\n \"batchMax\" | \"batchDebounce\" | \"batchInterval\" | \"batchKey\"\n > &\n Omit<HttpOptions, \"useGETForQueries\">;\n}\n\nconst backupFetch = maybe(() => fetch);\n\n/**\n * Transforms Operation for into HTTP results.\n * context can include the headers property, which will be passed to the fetch function\n */\nexport class BatchHttpLink extends ApolloLink {\n private batchDebounce?: boolean;\n private batchInterval: number;\n private batchMax: number;\n private batcher: ApolloLink;\n\n constructor(fetchParams?: BatchHttpLink.Options) {\n super();\n\n let {\n uri = \"/graphql\",\n // use default global fetch if nothing is passed in\n fetch: preferredFetch,\n print = defaultPrinter,\n includeExtensions,\n preserveHeaderCase,\n batchInterval,\n batchDebounce,\n batchMax,\n batchKey,\n includeUnusedVariables = false,\n ...requestOptions\n } = fetchParams || ({} as BatchHttpLink.Options);\n\n if (__DEV__) {\n // Make sure at least one of preferredFetch, window.fetch, or backupFetch\n // is defined, so requests won't fail at runtime.\n checkFetcher(preferredFetch || backupFetch);\n }\n\n const linkConfig = {\n http: { includeExtensions, preserveHeaderCase },\n options: requestOptions.fetchOptions,\n credentials: requestOptions.credentials,\n headers: requestOptions.headers,\n };\n\n this.batchDebounce = batchDebounce;\n this.batchInterval = batchInterval || 10;\n this.batchMax = batchMax || 10;\n\n const batchHandler = (operations: Operation[]) => {\n const chosenURI = selectURI(operations[0], uri);\n\n const context = operations[0].getContext();\n\n const clientAwarenessHeaders: {\n \"apollographql-client-name\"?: string;\n \"apollographql-client-version\"?: string;\n } = {};\n if (context.clientAwareness) {\n const { name, version } = context.clientAwareness;\n if (name) {\n clientAwarenessHeaders[\"apollographql-client-name\"] = name;\n }\n if (version) {\n clientAwarenessHeaders[\"apollographql-client-version\"] = version;\n }\n }\n\n const contextConfig = {\n http: context.http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: { ...clientAwarenessHeaders, ...context.headers },\n };\n\n if (__DEV__) {\n if (operations.some(({ query }) => hasDirectives([\"client\"], query))) {\n invariant.warn(\n \"[BatchHttpLink]: Apollo Client 4.0 will no longer remove `@client` fields from queries sent through the link chain. Please open an issue if this warning is displayed under standard usage.\"\n );\n }\n }\n\n const queries = operations.map(({ query }) => {\n if (hasDirectives([\"client\"], query)) {\n return removeClientSetsFromDocument(query);\n }\n\n return query;\n });\n\n // If we have a query that returned `null` after removing client-only\n // fields, it indicates a query that is using all client-only fields.\n if (queries.some((query) => !query)) {\n return fromError<FetchResult[]>(\n new Error(\n \"BatchHttpLink: Trying to send a client-only query to the server. To send to the server, ensure a non-client field is added to the query or enable the `transformOptions.removeClientFields` option.\"\n )\n );\n }\n\n //uses fallback, link, and then context to build options\n const optsAndBody = operations.map((operation, index) => {\n const result = selectHttpOptionsAndBodyInternal(\n { ...operation, query: queries[index]! },\n print,\n fallbackHttpConfig,\n linkConfig,\n contextConfig\n );\n\n if (result.body.variables && !includeUnusedVariables) {\n result.body.variables = filterOperationVariables(\n result.body.variables,\n operation.query\n );\n }\n\n return result;\n });\n\n const loadedBody = optsAndBody.map(({ body }) => body);\n const options = optsAndBody[0].options;\n\n // There's no spec for using GET with batches.\n if (options.method === \"GET\") {\n return fromError<FetchResult[]>(\n new Error(\"apollo-link-batch-http does not support GET requests\")\n );\n }\n\n try {\n (options as any).body = serializeFetchParameter(loadedBody, \"Payload\");\n } catch (parseError) {\n return fromError<FetchResult[]>(parseError);\n }\n\n let controller: AbortController | undefined;\n if (!options.signal && typeof AbortController !== \"undefined\") {\n controller = new AbortController();\n options.signal = controller.signal;\n }\n\n return new Observable<FetchResult[]>((observer) => {\n // Prefer BatchHttpLink.Options.fetch (preferredFetch) if provided, and\n // otherwise fall back to the *current* global window.fetch function\n // (see issue #7832), or (if all else fails) the backupFetch function we\n // saved when this module was first evaluated. This last option protects\n // against the removal of window.fetch, which is unlikely but not\n // impossible.\n const currentFetch =\n preferredFetch || maybe(() => fetch) || backupFetch;\n\n currentFetch!(chosenURI, options)\n .then((response) => {\n // Make the raw response available in the context.\n operations.forEach((operation) =>\n operation.setContext({ response })\n );\n return response;\n })\n .then(parseAndCheckHttpResponse(operations))\n .then((result) => {\n controller = undefined;\n // we have data and can send it to back up the link chain\n observer.next(result);\n observer.complete();\n return result;\n })\n .catch((err) => {\n controller = undefined;\n // if it is a network error, BUT there is graphql result info\n // fire the next observer before calling error\n // this gives apollo-client (and react-apollo) the `graphqlErrors` and `networkErrors`\n // to pass to UI\n // this should only happen if we *also* have data as part of the response key per\n // the spec\n if (err.result && err.result.errors && err.result.data) {\n // if we dont' call next, the UI can only show networkError because AC didn't\n // get andy graphqlErrors\n // this is graphql execution result info (i.e errors and possibly data)\n // this is because there is no formal spec how errors should translate to\n // http status codes. So an auth error (401) could have both data\n // from a public field, errors from a private field, and a status of 401\n // {\n // user { // this will have errors\n // firstName\n // }\n // products { // this is public so will have data\n // cost\n // }\n // }\n //\n // the result of above *could* look like this:\n // {\n // data: { products: [{ cost: \"$10\" }] },\n // errors: [{\n // message: 'your session has timed out',\n // path: []\n // }]\n // }\n // status code of above would be a 401\n // in the UI you want to show data where you can, errors as data where you can\n // and use correct http status codes\n observer.next(err.result);\n }\n\n observer.error(err);\n });\n\n return () => {\n // XXX support canceling this request\n // https://developers.google.com/web/updates/2017/09/abortable-fetch\n if (controller) controller.abort();\n };\n });\n };\n\n batchKey =\n batchKey ||\n ((operation: Operation) => {\n const context = operation.getContext();\n\n const contextConfig = {\n http: context.http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: context.headers,\n };\n\n //may throw error if config not serializable\n return selectURI(operation, uri) + JSON.stringify(contextConfig);\n });\n\n this.batcher = new BatchLink({\n batchDebounce: this.batchDebounce,\n batchInterval: this.batchInterval,\n batchMax: this.batchMax,\n batchKey,\n batchHandler,\n });\n }\n\n public request(operation: Operation): Observable<FetchResult> | null {\n return this.batcher.request(operation);\n }\n}\n"]}
@@ -11,7 +11,15 @@ export declare class ApolloLink {
11
11
  split(test: (op: Operation) => boolean, left: ApolloLink | RequestHandler, right?: ApolloLink | RequestHandler): ApolloLink;
12
12
  concat(next: ApolloLink | RequestHandler): ApolloLink;
13
13
  request(operation: Operation, forward?: NextLink): Observable<FetchResult> | null;
14
+ /**
15
+ * @deprecated `onError` will be removed with Apollo Client 4.0. Please
16
+ * discontinue using this method.
17
+ */
14
18
  protected onError(error: any, observer?: Observer<FetchResult>): false | void;
19
+ /**
20
+ * @deprecated `setOnError` will be removed with Apollo Client 4.0. Please
21
+ * discontinue using this method.
22
+ */
15
23
  setOnError(fn: ApolloLink["onError"]): this;
16
24
  /**
17
25
  * @internal
@@ -1,6 +1,7 @@
1
1
  import { newInvariantError, invariant } from "../../utilities/globals/index.js";
2
2
  import { Observable } from "../../utilities/index.js";
3
3
  import { validateOperation, createOperation, transformOperation, } from "../utils/index.js";
4
+ import { warnDeprecated } from "../../utilities/deprecation/index.js";
4
5
  function passthrough(op, forward) {
5
6
  return (forward ? forward(op) : Observable.of());
6
7
  }
@@ -49,7 +50,7 @@ var ApolloLink = /** @class */ (function () {
49
50
  ApolloLink.concat = function (first, second) {
50
51
  var firstLink = toLink(first);
51
52
  if (isTerminating(firstLink)) {
52
- globalThis.__DEV__ !== false && invariant.warn(39, firstLink);
53
+ globalThis.__DEV__ !== false && invariant.warn(47, firstLink);
53
54
  return firstLink;
54
55
  }
55
56
  var nextLink = toLink(second);
@@ -75,9 +76,18 @@ var ApolloLink = /** @class */ (function () {
75
76
  return ApolloLink.concat(this, next);
76
77
  };
77
78
  ApolloLink.prototype.request = function (operation, forward) {
78
- throw newInvariantError(40);
79
+ throw newInvariantError(48);
79
80
  };
81
+ /**
82
+ * @deprecated `onError` will be removed with Apollo Client 4.0. Please
83
+ * discontinue using this method.
84
+ */
80
85
  ApolloLink.prototype.onError = function (error, observer) {
86
+ if (globalThis.__DEV__ !== false) {
87
+ warnDeprecated("onError", function () {
88
+ globalThis.__DEV__ !== false && invariant.warn(49);
89
+ });
90
+ }
81
91
  if (observer && observer.error) {
82
92
  observer.error(error);
83
93
  // Returning false indicates that observer.error does not need to be
@@ -91,7 +101,14 @@ var ApolloLink = /** @class */ (function () {
91
101
  // Throw errors will be passed to observer.error.
92
102
  throw error;
93
103
  };
104
+ /**
105
+ * @deprecated `setOnError` will be removed with Apollo Client 4.0. Please
106
+ * discontinue using this method.
107
+ */
94
108
  ApolloLink.prototype.setOnError = function (fn) {
109
+ if (globalThis.__DEV__ !== false) {
110
+ globalThis.__DEV__ !== false && invariant.warn(50);
111
+ }
95
112
  this.onError = fn;
96
113
  return this;
97
114
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ApolloLink.js","sourceRoot":"","sources":["../../../src/link/core/ApolloLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAGhF,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAQtD,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAE3B,SAAS,WAAW,CAAC,EAAa,EAAE,OAAiB;IACnD,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,EAAE,CAA4B,CAAC;AAC9E,CAAC;AAED,SAAS,MAAM,CAAC,OAAoC;IAClD,OAAO,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAC3E,CAAC;AAED,SAAS,aAAa,CAAC,IAAgB;IACrC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;AAClC,CAAC;AAED;IAoFE,oBAAY,OAAwB;QAClC,IAAI,OAAO;YAAE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACtC,CAAC;IArFa,gBAAK,GAAnB;QACE,OAAO,IAAI,UAAU,CAAC,cAAM,OAAA,UAAU,CAAC,EAAE,EAAE,EAAf,CAAe,CAAC,CAAC;IAC/C,CAAC;IAEa,eAAI,GAAlB,UAAmB,KAAsC;QACvD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,UAAU,CAAC,KAAK,EAAE,CAAC;QAClD,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,CAA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,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IAClE,CAAC;IAMM,0BAAK,GAAZ,UACE,IAAgC,EAChC,IAAiC,EACjC,KAAmC;QAEnC,OAAO,IAAI,CAAC,MAAM,CAChB,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CACnE,CAAC;IACJ,CAAC;IAEM,2BAAM,GAAb,UAAc,IAAiC;QAC7C,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IAEM,4BAAO,GAAd,UACE,SAAoB,EACpB,OAAkB;QAElB,MAAM,iBAAiB,CAAC,4BAA4B,CAAC,CAAC;IACxD,CAAC;IAES,4BAAO,GAAjB,UACE,KAAU,EACV,QAAgC;QAEhC,IAAI,QAAQ,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;YAC/B,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACtB,oEAAoE;YACpE,oEAAoE;YACpE,kEAAkE;YAClE,kEAAkE;YAClE,8DAA8D;YAC9D,+BAA+B;YAC/B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,iDAAiD;QACjD,MAAM,KAAK,CAAC;IACd,CAAC;IAEM,+BAAU,GAAjB,UAAkB,EAAyB;QACzC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAkBH,iBAAC;AAAD,CAAC,AApJD,IAoJC","sourcesContent":["import { newInvariantError, invariant } from \"../../utilities/globals/index.js\";\n\nimport type { Observer } from \"../../utilities/index.js\";\nimport { Observable } from \"../../utilities/index.js\";\nimport type {\n NextLink,\n Operation,\n RequestHandler,\n FetchResult,\n GraphQLRequest,\n} from \"./types.js\";\nimport {\n validateOperation,\n createOperation,\n transformOperation,\n} from \"../utils/index.js\";\n\nfunction passthrough(op: Operation, forward: NextLink) {\n return (forward ? forward(op) : Observable.of()) as Observable<FetchResult>;\n}\n\nfunction toLink(handler: RequestHandler | ApolloLink) {\n return typeof handler === \"function\" ? new ApolloLink(handler) : handler;\n}\n\nfunction isTerminating(link: ApolloLink): boolean {\n return link.request.length <= 1;\n}\n\nexport class ApolloLink {\n public static empty(): ApolloLink {\n return new ApolloLink(() => Observable.of());\n }\n\n public static from(links: (ApolloLink | RequestHandler)[]): ApolloLink {\n if (links.length === 0) return ApolloLink.empty();\n return links.map(toLink).reduce((x, y) => x.concat(y)) as ApolloLink;\n }\n\n public static split(\n test: (op: Operation) => boolean,\n left: ApolloLink | RequestHandler,\n right?: ApolloLink | RequestHandler\n ): ApolloLink {\n const leftLink = toLink(left);\n const rightLink = toLink(right || new ApolloLink(passthrough));\n\n let ret: ApolloLink;\n if (isTerminating(leftLink) && isTerminating(rightLink)) {\n ret = new ApolloLink((operation) => {\n return test(operation) ?\n leftLink.request(operation) || Observable.of()\n : rightLink.request(operation) || Observable.of();\n });\n } else {\n ret = new ApolloLink((operation, forward) => {\n return test(operation) ?\n leftLink.request(operation, forward) || Observable.of()\n : rightLink.request(operation, forward) || Observable.of();\n });\n }\n return Object.assign(ret, { left: leftLink, right: rightLink });\n }\n\n public static execute(\n link: ApolloLink,\n operation: GraphQLRequest\n ): Observable<FetchResult> {\n return (\n link.request(\n createOperation(\n operation.context,\n transformOperation(validateOperation(operation))\n )\n ) || Observable.of()\n );\n }\n\n public static concat(\n first: ApolloLink | RequestHandler,\n second: ApolloLink | RequestHandler\n ) {\n const firstLink = toLink(first);\n if (isTerminating(firstLink)) {\n invariant.warn(\n `You are calling concat on a terminating link, which will have no effect %o`,\n firstLink\n );\n return firstLink;\n }\n const nextLink = toLink(second);\n\n let ret: ApolloLink;\n if (isTerminating(nextLink)) {\n ret = new ApolloLink(\n (operation) =>\n firstLink.request(\n operation,\n (op) => nextLink.request(op) || Observable.of()\n ) || Observable.of()\n );\n } else {\n ret = new ApolloLink((operation, forward) => {\n return (\n firstLink.request(operation, (op) => {\n return nextLink.request(op, forward) || Observable.of();\n }) || Observable.of()\n );\n });\n }\n return Object.assign(ret, { left: firstLink, right: nextLink });\n }\n\n constructor(request?: RequestHandler) {\n if (request) this.request = request;\n }\n\n public split(\n test: (op: Operation) => boolean,\n left: ApolloLink | RequestHandler,\n right?: ApolloLink | RequestHandler\n ): ApolloLink {\n return this.concat(\n ApolloLink.split(test, left, right || new ApolloLink(passthrough))\n );\n }\n\n public concat(next: ApolloLink | RequestHandler): ApolloLink {\n return ApolloLink.concat(this, next);\n }\n\n public request(\n operation: Operation,\n forward?: NextLink\n ): Observable<FetchResult> | null {\n throw newInvariantError(\"request is not implemented\");\n }\n\n protected onError(\n error: any,\n observer?: Observer<FetchResult>\n ): false | void {\n if (observer && observer.error) {\n observer.error(error);\n // Returning false indicates that observer.error does not need to be\n // called again, since it was already called (on the previous line).\n // Calling observer.error again would not cause any real problems,\n // since only the first call matters, but custom onError functions\n // might have other reasons for wanting to prevent the default\n // behavior by returning false.\n return false;\n }\n // Throw errors will be passed to observer.error.\n throw error;\n }\n\n public setOnError(fn: ApolloLink[\"onError\"]): this {\n this.onError = fn;\n return this;\n }\n\n /**\n * @internal\n * Used to iterate through all links that are concatenations or `split` links.\n */\n readonly left?: ApolloLink;\n /**\n * @internal\n * Used to iterate through all links that are concatenations or `split` links.\n */\n readonly right?: ApolloLink;\n\n /**\n * @internal\n * Can be provided by a link that has an internal cache to report it's memory details.\n */\n getMemoryInternals?: () => unknown;\n}\n"]}
1
+ {"version":3,"file":"ApolloLink.js","sourceRoot":"","sources":["../../../src/link/core/ApolloLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAGhF,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAQtD,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,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AM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IAEM,4BAAO,GAAd,UACE,SAAoB,EACpB,OAAkB;QAElB,MAAM,iBAAiB,CAAC,4BAA4B,CAAC,CAAC;IACxD,CAAC;IAED;;;OAGG;IACO,4BAAO,GAAjB,UACE,KAAU,EACV,QAAgC;QAEhC,IAAI,OAAO,EAAE,CAAC;YACZ,cAAc,CAAC,SAAS,EAAE;gBACxB,SAAS,CAAC,IAAI,CACZ,+GAA+G,CAChH,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,QAAQ,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;YAC/B,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACtB,oEAAoE;YACpE,oEAAoE;YACpE,kEAAkE;YAClE,kEAAkE;YAClE,8DAA8D;YAC9D,+BAA+B;YAC/B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,iDAAiD;QACjD,MAAM,KAAK,CAAC;IACd,CAAC;IAED;;;OAGG;IACI,+BAAU,GAAjB,UAAkB,EAAyB;QACzC,IAAI,OAAO,EAAE,CAAC;YACZ,SAAS,CAAC,IAAI,CACZ,kHAAkH,CACnH,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAkBH,iBAAC;AAAD,CAAC,AAxKD,IAwKC","sourcesContent":["import { newInvariantError, invariant } from \"../../utilities/globals/index.js\";\n\nimport type { Observer } from \"../../utilities/index.js\";\nimport { Observable } from \"../../utilities/index.js\";\nimport type {\n NextLink,\n Operation,\n RequestHandler,\n FetchResult,\n GraphQLRequest,\n} from \"./types.js\";\nimport {\n validateOperation,\n createOperation,\n transformOperation,\n} from \"../utils/index.js\";\nimport { warnDeprecated } from \"../../utilities/deprecation/index.js\";\n\nfunction passthrough(op: Operation, forward: NextLink) {\n return (forward ? forward(op) : Observable.of()) as Observable<FetchResult>;\n}\n\nfunction toLink(handler: RequestHandler | ApolloLink) {\n return typeof handler === \"function\" ? new ApolloLink(handler) : handler;\n}\n\nfunction isTerminating(link: ApolloLink): boolean {\n return link.request.length <= 1;\n}\n\nexport class ApolloLink {\n public static empty(): ApolloLink {\n return new ApolloLink(() => Observable.of());\n }\n\n public static from(links: (ApolloLink | RequestHandler)[]): ApolloLink {\n if (links.length === 0) return ApolloLink.empty();\n return links.map(toLink).reduce((x, y) => x.concat(y)) as ApolloLink;\n }\n\n public static split(\n test: (op: Operation) => boolean,\n left: ApolloLink | RequestHandler,\n right?: ApolloLink | RequestHandler\n ): ApolloLink {\n const leftLink = toLink(left);\n const rightLink = toLink(right || new ApolloLink(passthrough));\n\n let ret: ApolloLink;\n if (isTerminating(leftLink) && isTerminating(rightLink)) {\n ret = new ApolloLink((operation) => {\n return test(operation) ?\n leftLink.request(operation) || Observable.of()\n : rightLink.request(operation) || Observable.of();\n });\n } else {\n ret = new ApolloLink((operation, forward) => {\n return test(operation) ?\n leftLink.request(operation, forward) || Observable.of()\n : rightLink.request(operation, forward) || Observable.of();\n });\n }\n return Object.assign(ret, { left: leftLink, right: rightLink });\n }\n\n public static execute(\n link: ApolloLink,\n operation: GraphQLRequest\n ): Observable<FetchResult> {\n return (\n link.request(\n createOperation(\n operation.context,\n transformOperation(validateOperation(operation))\n )\n ) || Observable.of()\n );\n }\n\n public static concat(\n first: ApolloLink | RequestHandler,\n second: ApolloLink | RequestHandler\n ) {\n const firstLink = toLink(first);\n if (isTerminating(firstLink)) {\n invariant.warn(\n `You are calling concat on a terminating link, which will have no effect %o`,\n firstLink\n );\n return firstLink;\n }\n const nextLink = toLink(second);\n\n let ret: ApolloLink;\n if (isTerminating(nextLink)) {\n ret = new ApolloLink(\n (operation) =>\n firstLink.request(\n operation,\n (op) => nextLink.request(op) || Observable.of()\n ) || Observable.of()\n );\n } else {\n ret = new ApolloLink((operation, forward) => {\n return (\n firstLink.request(operation, (op) => {\n return nextLink.request(op, forward) || Observable.of();\n }) || Observable.of()\n );\n });\n }\n return Object.assign(ret, { left: firstLink, right: nextLink });\n }\n\n constructor(request?: RequestHandler) {\n if (request) this.request = request;\n }\n\n public split(\n test: (op: Operation) => boolean,\n left: ApolloLink | RequestHandler,\n right?: ApolloLink | RequestHandler\n ): ApolloLink {\n return this.concat(\n ApolloLink.split(test, left, right || new ApolloLink(passthrough))\n );\n }\n\n public concat(next: ApolloLink | RequestHandler): ApolloLink {\n return ApolloLink.concat(this, next);\n }\n\n public request(\n operation: Operation,\n forward?: NextLink\n ): Observable<FetchResult> | null {\n throw newInvariantError(\"request is not implemented\");\n }\n\n /**\n * @deprecated `onError` will be removed with Apollo Client 4.0. Please\n * discontinue using this method.\n */\n protected onError(\n error: any,\n observer?: Observer<FetchResult>\n ): false | void {\n if (__DEV__) {\n warnDeprecated(\"onError\", () => {\n invariant.warn(\n \"[ApolloLink] `onError` is deprecated and will be removed with Apollo Client 4.0. Please discontinue using it.\"\n );\n });\n }\n if (observer && observer.error) {\n observer.error(error);\n // Returning false indicates that observer.error does not need to be\n // called again, since it was already called (on the previous line).\n // Calling observer.error again would not cause any real problems,\n // since only the first call matters, but custom onError functions\n // might have other reasons for wanting to prevent the default\n // behavior by returning false.\n return false;\n }\n // Throw errors will be passed to observer.error.\n throw error;\n }\n\n /**\n * @deprecated `setOnError` will be removed with Apollo Client 4.0. Please\n * discontinue using this method.\n */\n public setOnError(fn: ApolloLink[\"onError\"]): this {\n if (__DEV__) {\n invariant.warn(\n \"[ApolloLink] `setOnError` is deprecated and will be removed with Apollo Client 4.0. Please discontinue using it.\"\n );\n }\n this.onError = fn;\n return this;\n }\n\n /**\n * @internal\n * Used to iterate through all links that are concatenations or `split` links.\n */\n readonly left?: ApolloLink;\n /**\n * @internal\n * Used to iterate through all links that are concatenations or `split` links.\n */\n readonly right?: ApolloLink;\n\n /**\n * @internal\n * Can be provided by a link that has an internal cache to report it's memory details.\n */\n getMemoryInternals?: () => unknown;\n}\n"]}
@@ -5,6 +5,20 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var globals = require('../../utilities/globals');
6
6
  var utilities = require('../../utilities');
7
7
  var utils = require('../utils');
8
+ require('tslib');
9
+ var optimism = require('optimism');
10
+
11
+ var muteAllDeprecations = Symbol.for("apollo.deprecations");
12
+ var global = globals.global;
13
+ var slot = new optimism.Slot();
14
+ function isMuted(name) {
15
+ return global[muteAllDeprecations] || (slot.getValue() || []).includes(name);
16
+ }
17
+ function warnDeprecated(name, cb) {
18
+ if (!isMuted(name)) {
19
+ cb();
20
+ }
21
+ }
8
22
 
9
23
  function passthrough(op, forward) {
10
24
  return (forward ? forward(op) : utilities.Observable.of());
@@ -54,7 +68,7 @@ var ApolloLink = (function () {
54
68
  ApolloLink.concat = function (first, second) {
55
69
  var firstLink = toLink(first);
56
70
  if (isTerminating(firstLink)) {
57
- globalThis.__DEV__ !== false && globals.invariant.warn(39, firstLink);
71
+ globalThis.__DEV__ !== false && globals.invariant.warn(47, firstLink);
58
72
  return firstLink;
59
73
  }
60
74
  var nextLink = toLink(second);
@@ -80,9 +94,14 @@ var ApolloLink = (function () {
80
94
  return ApolloLink.concat(this, next);
81
95
  };
82
96
  ApolloLink.prototype.request = function (operation, forward) {
83
- throw globals.newInvariantError(40);
97
+ throw globals.newInvariantError(48);
84
98
  };
85
99
  ApolloLink.prototype.onError = function (error, observer) {
100
+ if (globalThis.__DEV__ !== false) {
101
+ warnDeprecated("onError", function () {
102
+ globalThis.__DEV__ !== false && globals.invariant.warn(49);
103
+ });
104
+ }
86
105
  if (observer && observer.error) {
87
106
  observer.error(error);
88
107
  return false;
@@ -90,6 +109,9 @@ var ApolloLink = (function () {
90
109
  throw error;
91
110
  };
92
111
  ApolloLink.prototype.setOnError = function (fn) {
112
+ if (globalThis.__DEV__ !== false) {
113
+ globalThis.__DEV__ !== false && globals.invariant.warn(50);
114
+ }
93
115
  this.onError = fn;
94
116
  return this;
95
117
  };
@@ -1 +1 @@
1
- {"version":3,"file":"core.cjs","sources":["ApolloLink.js","empty.js","from.js","split.js","concat.js","execute.js"],"sourcesContent":["import { newInvariantError, invariant } from \"../../utilities/globals/index.js\";\nimport { Observable } from \"../../utilities/index.js\";\nimport { validateOperation, createOperation, transformOperation, } from \"../utils/index.js\";\nfunction passthrough(op, forward) {\n return (forward ? forward(op) : Observable.of());\n}\nfunction toLink(handler) {\n return typeof handler === \"function\" ? new ApolloLink(handler) : handler;\n}\nfunction isTerminating(link) {\n return link.request.length <= 1;\n}\nvar ApolloLink = /** @class */ (function () {\n function ApolloLink(request) {\n if (request)\n this.request = request;\n }\n ApolloLink.empty = function () {\n return new ApolloLink(function () { return Observable.of(); });\n };\n ApolloLink.from = function (links) {\n if (links.length === 0)\n return ApolloLink.empty();\n return links.map(toLink).reduce(function (x, y) { return x.concat(y); });\n };\n ApolloLink.split = function (test, left, right) {\n var leftLink = toLink(left);\n var rightLink = toLink(right || new ApolloLink(passthrough));\n var ret;\n if (isTerminating(leftLink) && isTerminating(rightLink)) {\n ret = new ApolloLink(function (operation) {\n return test(operation) ?\n leftLink.request(operation) || Observable.of()\n : rightLink.request(operation) || Observable.of();\n });\n }\n else {\n ret = new ApolloLink(function (operation, forward) {\n return test(operation) ?\n leftLink.request(operation, forward) || Observable.of()\n : rightLink.request(operation, forward) || Observable.of();\n });\n }\n return Object.assign(ret, { left: leftLink, right: rightLink });\n };\n ApolloLink.execute = function (link, operation) {\n return (link.request(createOperation(operation.context, transformOperation(validateOperation(operation)))) || Observable.of());\n };\n ApolloLink.concat = function (first, second) {\n var firstLink = toLink(first);\n if (isTerminating(firstLink)) {\n globalThis.__DEV__ !== false && invariant.warn(39, firstLink);\n return firstLink;\n }\n var nextLink = toLink(second);\n var ret;\n if (isTerminating(nextLink)) {\n ret = new ApolloLink(function (operation) {\n return firstLink.request(operation, function (op) { return nextLink.request(op) || Observable.of(); }) || Observable.of();\n });\n }\n else {\n ret = new ApolloLink(function (operation, forward) {\n return (firstLink.request(operation, function (op) {\n return nextLink.request(op, forward) || Observable.of();\n }) || Observable.of());\n });\n }\n return Object.assign(ret, { left: firstLink, right: nextLink });\n };\n ApolloLink.prototype.split = function (test, left, right) {\n return this.concat(ApolloLink.split(test, left, right || new ApolloLink(passthrough)));\n };\n ApolloLink.prototype.concat = function (next) {\n return ApolloLink.concat(this, next);\n };\n ApolloLink.prototype.request = function (operation, forward) {\n throw newInvariantError(40);\n };\n ApolloLink.prototype.onError = function (error, observer) {\n if (observer && observer.error) {\n observer.error(error);\n // Returning false indicates that observer.error does not need to be\n // called again, since it was already called (on the previous line).\n // Calling observer.error again would not cause any real problems,\n // since only the first call matters, but custom onError functions\n // might have other reasons for wanting to prevent the default\n // behavior by returning false.\n return false;\n }\n // Throw errors will be passed to observer.error.\n throw error;\n };\n ApolloLink.prototype.setOnError = function (fn) {\n this.onError = fn;\n return this;\n };\n return ApolloLink;\n}());\nexport { ApolloLink };\n//# sourceMappingURL=ApolloLink.js.map","import { ApolloLink } from \"./ApolloLink.js\";\nexport var empty = ApolloLink.empty;\n//# sourceMappingURL=empty.js.map","import { ApolloLink } from \"./ApolloLink.js\";\nexport var from = ApolloLink.from;\n//# sourceMappingURL=from.js.map","import { ApolloLink } from \"./ApolloLink.js\";\nexport var split = ApolloLink.split;\n//# sourceMappingURL=split.js.map","import { ApolloLink } from \"./ApolloLink.js\";\nexport var concat = ApolloLink.concat;\n//# sourceMappingURL=concat.js.map","import { ApolloLink } from \"./ApolloLink.js\";\nexport var execute = ApolloLink.execute;\n//# sourceMappingURL=execute.js.map"],"names":["Observable","createOperation","transformOperation","validateOperation","invariant","newInvariantError"],"mappings":";;;;;;;;AAGA,SAAS,WAAW,CAAC,EAAE,EAAE,OAAO,EAAE;AAClC,IAAI,QAAQ,OAAO,GAAG,OAAO,CAAC,EAAE,CAAC,GAAGA,oBAAU,CAAC,EAAE,EAAE,EAAE;AACrD,CAAC;AACD,SAAS,MAAM,CAAC,OAAO,EAAE;AACzB,IAAI,OAAO,OAAO,OAAO,KAAK,UAAU,G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AAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;AAC/F,KAAK,CAAC;AACN,IAAI,UAAU,CAAC,SAAS,CAAC,MAAM,GAAG,UAAU,IAAI,EAAE;AAClD,QAAQ,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC7C,KAAK,CAAC;AACN,IAAI,UAAU,CAAC,SAAS,CAAC,OAAO,GAAG,UAAU,SAAS,EAAE,OAAO,EAAE;AACjE,QAAQ,MAAMK,yBAAiB,CAAC,EAAE,CAAC,CAAC;AACpC,KAAK,CAAC;AACN,IAAI,UAAU,CAAC,SAAS,CAAC,OAAO,GAAG,UAAU,KAAK,EAAE,QAAQ,EAAE;AAC9D,QAAQ,IAAI,QAAQ,IAAI,QAAQ,CAAC,KAAK,EAAE;AACxC,YAAY,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAOlC,YAAY,OAAO,KAAK,CAAC;AACzB,SAAS;AAET,QAAQ,MAAM,KAAK,CAAC;AACpB,KAAK,CAAC;AACN,IAAI,UAAU,CAAC,SAAS,CAAC,UAAU,GAAG,UAAU,EAAE,EAAE;AACpD,QAAQ,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;AAC1B,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK,CAAC;AACN,IAAI,OAAO,UAAU,CAAC;AACtB,CAAC,EAAE;;ACjGO,IAAC,KAAK,GAAG,UAAU,CAAC;;ACApB,IAAC,IAAI,GAAG,UAAU,CAAC;;ACAnB,IAAC,KAAK,GAAG,UAAU,CAAC;;ACApB,IAAC,MAAM,GAAG,UAAU,CAAC;;ACArB,IAAC,OAAO,GAAG,UAAU,CAAC;;;;;;;;;"}
1
+ {"version":3,"file":"core.cjs","sources":["../../utilities/deprecation/index.js","ApolloLink.js","empty.js","from.js","split.js","concat.js","execute.js"],"sourcesContent":["import { __spreadArray } from \"tslib\";\nimport { Slot } from \"optimism\";\nimport { invariant, global as untypedGlobal } from \"../globals/index.js\";\nvar muteAllDeprecations = Symbol.for(\"apollo.deprecations\");\nvar global = untypedGlobal;\nvar slot = new Slot();\nfunction isMuted(name) {\n return global[muteAllDeprecations] || (slot.getValue() || []).includes(name);\n}\nexport function muteDeprecations(name) {\n var args = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n args[_i - 1] = arguments[_i];\n }\n return slot.withValue.apply(slot, __spreadArray([Array.isArray(name) ? name : [name]], args, false));\n}\nexport function warnRemovedOption(options, name, callSite, recommendation) {\n if (recommendation === void 0) { recommendation = \"Please remove this option.\"; }\n warnDeprecated(name, function () {\n if (name in options) {\n globalThis.__DEV__ !== false && invariant.warn(104, callSite, name, recommendation);\n }\n });\n}\nexport function warnDeprecated(name, cb) {\n if (!isMuted(name)) {\n cb();\n }\n}\nexport function withDisabledDeprecations() {\n var _a;\n var prev = global[muteAllDeprecations];\n global[muteAllDeprecations] = true;\n return _a = {},\n _a[Symbol.dispose] = function () {\n global[muteAllDeprecations] = prev;\n },\n _a;\n}\n//# sourceMappingURL=index.js.map","import { newInvariantError, invariant } from \"../../utilities/globals/index.js\";\nimport { Observable } from \"../../utilities/index.js\";\nimport { validateOperation, createOperation, transformOperation, } from \"../utils/index.js\";\nimport { warnDeprecated } from \"../../utilities/deprecation/index.js\";\nfunction passthrough(op, forward) {\n return (forward ? forward(op) : Observable.of());\n}\nfunction toLink(handler) {\n return typeof handler === \"function\" ? new ApolloLink(handler) : handler;\n}\nfunction isTerminating(link) {\n return link.request.length <= 1;\n}\nvar ApolloLink = /** @class */ (function () {\n function ApolloLink(request) {\n if (request)\n this.request = request;\n }\n ApolloLink.empty = function () {\n return new ApolloLink(function () { return Observable.of(); });\n };\n ApolloLink.from = function (links) {\n if (links.length === 0)\n return ApolloLink.empty();\n return links.map(toLink).reduce(function (x, y) { return x.concat(y); });\n };\n ApolloLink.split = function (test, left, right) {\n var leftLink = toLink(left);\n var rightLink = toLink(right || new ApolloLink(passthrough));\n var ret;\n if (isTerminating(leftLink) && isTerminating(rightLink)) {\n ret = new ApolloLink(function (operation) {\n return test(operation) ?\n leftLink.request(operation) || Observable.of()\n : rightLink.request(operation) || Observable.of();\n });\n }\n else {\n ret = new ApolloLink(function (operation, forward) {\n return test(operation) ?\n leftLink.request(operation, forward) || Observable.of()\n : rightLink.request(operation, forward) || Observable.of();\n });\n }\n return Object.assign(ret, { left: leftLink, right: rightLink });\n };\n ApolloLink.execute = function (link, operation) {\n return (link.request(createOperation(operation.context, transformOperation(validateOperation(operation)))) || Observable.of());\n };\n ApolloLink.concat = function (first, second) {\n var firstLink = toLink(first);\n if (isTerminating(firstLink)) {\n globalThis.__DEV__ !== false && invariant.warn(47, firstLink);\n return firstLink;\n }\n var nextLink = toLink(second);\n var ret;\n if (isTerminating(nextLink)) {\n ret = new ApolloLink(function (operation) {\n return firstLink.request(operation, function (op) { return nextLink.request(op) || Observable.of(); }) || Observable.of();\n });\n }\n else {\n ret = new ApolloLink(function (operation, forward) {\n return (firstLink.request(operation, function (op) {\n return nextLink.request(op, forward) || Observable.of();\n }) || Observable.of());\n });\n }\n return Object.assign(ret, { left: firstLink, right: nextLink });\n };\n ApolloLink.prototype.split = function (test, left, right) {\n return this.concat(ApolloLink.split(test, left, right || new ApolloLink(passthrough)));\n };\n ApolloLink.prototype.concat = function (next) {\n return ApolloLink.concat(this, next);\n };\n ApolloLink.prototype.request = function (operation, forward) {\n throw newInvariantError(48);\n };\n /**\n * @deprecated `onError` will be removed with Apollo Client 4.0. Please\n * discontinue using this method.\n */\n ApolloLink.prototype.onError = function (error, observer) {\n if (globalThis.__DEV__ !== false) {\n warnDeprecated(\"onError\", function () {\n globalThis.__DEV__ !== false && invariant.warn(49);\n });\n }\n if (observer && observer.error) {\n observer.error(error);\n // Returning false indicates that observer.error does not need to be\n // called again, since it was already called (on the previous line).\n // Calling observer.error again would not cause any real problems,\n // since only the first call matters, but custom onError functions\n // might have other reasons for wanting to prevent the default\n // behavior by returning false.\n return false;\n }\n // Throw errors will be passed to observer.error.\n throw error;\n };\n /**\n * @deprecated `setOnError` will be removed with Apollo Client 4.0. Please\n * discontinue using this method.\n */\n ApolloLink.prototype.setOnError = function (fn) {\n if (globalThis.__DEV__ !== false) {\n globalThis.__DEV__ !== false && invariant.warn(50);\n }\n this.onError = fn;\n return this;\n };\n return ApolloLink;\n}());\nexport { ApolloLink };\n//# sourceMappingURL=ApolloLink.js.map","import { ApolloLink } from \"./ApolloLink.js\";\nexport var empty = ApolloLink.empty;\n//# sourceMappingURL=empty.js.map","import { ApolloLink } from \"./ApolloLink.js\";\nexport var from = ApolloLink.from;\n//# sourceMappingURL=from.js.map","import { ApolloLink } from \"./ApolloLink.js\";\nexport var split = ApolloLink.split;\n//# sourceMappingURL=split.js.map","import { ApolloLink } from \"./ApolloLink.js\";\nexport var concat = ApolloLink.concat;\n//# sourceMappingURL=concat.js.map","import { ApolloLink } from \"./ApolloLink.js\";\nexport var execute = ApolloLink.execute;\n//# sourceMappingURL=execute.js.map"],"names":["untypedGlobal","Slot","Observable","createOperation","transformOperation","validateOperation","invariant","newInvariantError"],"mappings":";;;;;;;;;;AAGA,IAAI,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;AAC5D,IAAI,MAAM,GAAGA,cAAa,CAAC;AAC3B,IAAI,IAAI,GAAG,IAAIC,aAAI,EAAE,CAAC;AACtB,SAAS,OAAO,CAAC,IAAI,EAAE;AACvB,IAAI,OAAO,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;AACjF,CAAC;AAgBM,SAAS,cAAc,CAAC,IAAI,EAAE,EAAE,EAAE;AACzC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;AACxB,QAAQ,EAAE,EAAE,CAAC;AACb,KAAK;AACL;;ACxBA,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pD,QAAQ,IAAI,UAAU,CAAC,OAAO,KAAK,KAAK,EAAE;AAC1C,YAAY,UAAU,CAAC,OAAO,KAAK,KAAK,IAAIA,iBAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC/D,SAAS;AACT,QAAQ,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;AAC1B,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK,CAAC;AACN,IAAI,OAAO,UAAU,CAAC;AACtB,CAAC,EAAE;;AClHO,IAAC,KAAK,GAAG,UAAU,CAAC;;ACApB,IAAC,IAAI,GAAG,UAAU,CAAC;;ACAnB,IAAC,KAAK,GAAG,UAAU,CAAC;;ACApB,IAAC,MAAM,GAAG,UAAU,CAAC;;ACArB,IAAC,OAAO,GAAG,UAAU,CAAC;;;;;;;;;"}
@@ -5,6 +5,20 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var globals = require('../../utilities/globals');
6
6
  var utilities = require('../../utilities');
7
7
  var utils = require('../utils');
8
+ require('tslib');
9
+ var optimism = require('optimism');
10
+
11
+ var muteAllDeprecations = Symbol.for("apollo.deprecations");
12
+ var global = globals.global;
13
+ var slot = new optimism.Slot();
14
+ function isMuted(name) {
15
+ return global[muteAllDeprecations] || (slot.getValue() || []).includes(name);
16
+ }
17
+ function warnDeprecated(name, cb) {
18
+ if (!isMuted(name)) {
19
+ cb();
20
+ }
21
+ }
8
22
 
9
23
  function passthrough(op, forward) {
10
24
  return (forward ? forward(op) : utilities.Observable.of());
@@ -54,7 +68,7 @@ var ApolloLink = (function () {
54
68
  ApolloLink.concat = function (first, second) {
55
69
  var firstLink = toLink(first);
56
70
  if (isTerminating(firstLink)) {
57
- globalThis.__DEV__ !== false && globals.invariant.warn(39, firstLink);
71
+ globalThis.__DEV__ !== false && globals.invariant.warn(47, firstLink);
58
72
  return firstLink;
59
73
  }
60
74
  var nextLink = toLink(second);
@@ -80,9 +94,14 @@ var ApolloLink = (function () {
80
94
  return ApolloLink.concat(this, next);
81
95
  };
82
96
  ApolloLink.prototype.request = function (operation, forward) {
83
- throw globals.newInvariantError(40);
97
+ throw globals.newInvariantError(48);
84
98
  };
85
99
  ApolloLink.prototype.onError = function (error, observer) {
100
+ if (globalThis.__DEV__ !== false) {
101
+ warnDeprecated("onError", function () {
102
+ globalThis.__DEV__ !== false && globals.invariant.warn(49);
103
+ });
104
+ }
86
105
  if (observer && observer.error) {
87
106
  observer.error(error);
88
107
  return false;
@@ -90,6 +109,9 @@ var ApolloLink = (function () {
90
109
  throw error;
91
110
  };
92
111
  ApolloLink.prototype.setOnError = function (fn) {
112
+ if (globalThis.__DEV__ !== false) {
113
+ globalThis.__DEV__ !== false && globals.invariant.warn(50);
114
+ }
93
115
  this.onError = fn;
94
116
  return this;
95
117
  };
@@ -3,16 +3,28 @@ import type { DocumentNode } from "graphql";
3
3
  import type { DefaultContext } from "../../core/index.js";
4
4
  export type { DocumentNode };
5
5
  import type { Observable } from "../../utilities/index.js";
6
+ /**
7
+ * @deprecated `ExecutionPatchResult` will be removed in Apollo Client 4.0. This
8
+ * type is safe to use in Apollo Client 3.x.
9
+ */
6
10
  export type Path = ReadonlyArray<string | number>;
7
11
  interface ExecutionPatchResultBase {
8
12
  hasNext?: boolean;
9
13
  }
14
+ /**
15
+ * @deprecated `ExecutionPatchResult` will be removed in Apollo Client 4.0. This
16
+ * type is safe to use in Apollo Client 3.x.
17
+ */
10
18
  export interface ExecutionPatchInitialResult<TData = Record<string, any>, TExtensions = Record<string, any>> extends ExecutionPatchResultBase {
11
19
  data: TData | null | undefined;
12
20
  incremental?: never;
13
21
  errors?: ReadonlyArray<GraphQLFormattedError>;
14
22
  extensions?: TExtensions;
15
23
  }
24
+ /**
25
+ * @deprecated `ExecutionPatchResult` will be removed in Apollo Client 4.0. This
26
+ * type is safe to use in Apollo Client 3.x.
27
+ */
16
28
  export interface IncrementalPayload<TData, TExtensions> {
17
29
  data: TData | null;
18
30
  label?: string;
@@ -20,6 +32,10 @@ export interface IncrementalPayload<TData, TExtensions> {
20
32
  errors?: ReadonlyArray<GraphQLFormattedError>;
21
33
  extensions?: TExtensions;
22
34
  }
35
+ /**
36
+ * @deprecated `ExecutionPatchResult` will be removed in Apollo Client 4.0. This
37
+ * type is safe to use in Apollo Client 3.x.
38
+ */
23
39
  export interface ExecutionPatchIncrementalResult<TData = Record<string, any>, TExtensions = Record<string, any>> extends ExecutionPatchResultBase {
24
40
  incremental?: IncrementalPayload<TData, TExtensions>[];
25
41
  data?: never;
@@ -30,6 +46,10 @@ export interface ApolloPayloadResult<TData = Record<string, any>, TExtensions =
30
46
  payload: SingleExecutionResult<TData, DefaultContext, TExtensions> | ExecutionPatchResult<TData, TExtensions> | null;
31
47
  errors?: ReadonlyArray<GraphQLFormattedError>;
32
48
  }
49
+ /**
50
+ * @deprecated `ExecutionPatchResult` will be removed in Apollo Client 4.0. This
51
+ * type is safe to use in Apollo Client 3.x.
52
+ */
33
53
  export type ExecutionPatchResult<TData = Record<string, any>, TExtensions = Record<string, any>> = ExecutionPatchInitialResult<TData, TExtensions> | ExecutionPatchIncrementalResult<TData, TExtensions>;
34
54
  export interface GraphQLRequest<TVariables = Record<string, any>> {
35
55
  query: DocumentNode;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/link/core/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { GraphQLFormattedError } from \"graphql\";\nimport type { DocumentNode } from \"graphql\";\nimport type { DefaultContext } from \"../../core/index.js\";\nexport type { DocumentNode };\n\nimport type { Observable } from \"../../utilities/index.js\";\n\nexport type Path = ReadonlyArray<string | number>;\n\ninterface ExecutionPatchResultBase {\n hasNext?: boolean;\n}\n\nexport interface ExecutionPatchInitialResult<\n TData = Record<string, any>,\n TExtensions = Record<string, any>,\n> extends ExecutionPatchResultBase {\n // if data is present, incremental is not\n data: TData | null | undefined;\n incremental?: never;\n errors?: ReadonlyArray<GraphQLFormattedError>;\n extensions?: TExtensions;\n}\n\nexport interface IncrementalPayload<TData, TExtensions> {\n // data and path must both be present\n // https://github.com/graphql/graphql-spec/pull/742/files#diff-98d0cd153b72b63c417ad4238e8cc0d3385691ccbde7f7674bc0d2a718b896ecR288-R293\n data: TData | null;\n label?: string;\n path: Path;\n errors?: ReadonlyArray<GraphQLFormattedError>;\n extensions?: TExtensions;\n}\n\nexport interface ExecutionPatchIncrementalResult<\n TData = Record<string, any>,\n TExtensions = Record<string, any>,\n> extends ExecutionPatchResultBase {\n // the reverse is also true: if incremental is present,\n // data (and errors and extensions) are not\n incremental?: IncrementalPayload<TData, TExtensions>[];\n data?: never;\n // Errors only exist for chunks, not at the top level\n // https://github.com/robrichard/defer-stream-wg/discussions/50#discussioncomment-3466739\n errors?: never;\n extensions?: never;\n}\n\nexport interface ApolloPayloadResult<\n TData = Record<string, any>,\n TExtensions = Record<string, any>,\n> {\n payload:\n | SingleExecutionResult<TData, DefaultContext, TExtensions>\n | ExecutionPatchResult<TData, TExtensions>\n | null;\n // Transport layer errors (as distinct from GraphQL or NetworkErrors),\n // these are fatal errors that will include done: true.\n errors?: ReadonlyArray<GraphQLFormattedError>;\n}\n\nexport type ExecutionPatchResult<\n TData = Record<string, any>,\n TExtensions = Record<string, any>,\n> =\n | ExecutionPatchInitialResult<TData, TExtensions>\n | ExecutionPatchIncrementalResult<TData, TExtensions>;\n\nexport interface GraphQLRequest<TVariables = Record<string, any>> {\n query: DocumentNode;\n variables?: TVariables;\n operationName?: string;\n context?: DefaultContext;\n extensions?: Record<string, any>;\n}\n\nexport interface Operation {\n query: DocumentNode;\n variables: Record<string, any>;\n operationName: string;\n extensions: Record<string, any>;\n setContext: {\n (context: Partial<DefaultContext>): void;\n (\n updateContext: (\n previousContext: DefaultContext\n ) => Partial<DefaultContext>\n ): void;\n };\n getContext: () => DefaultContext;\n}\n\nexport interface SingleExecutionResult<\n TData = Record<string, any>,\n TContext = DefaultContext,\n TExtensions = Record<string, any>,\n> {\n // data might be undefined if errorPolicy was set to 'ignore'\n data?: TData | null;\n context?: TContext;\n errors?: ReadonlyArray<GraphQLFormattedError>;\n extensions?: TExtensions;\n}\n\nexport type FetchResult<\n TData = Record<string, any>,\n TContext = Record<string, any>,\n TExtensions = Record<string, any>,\n> =\n | SingleExecutionResult<TData, TContext, TExtensions>\n | ExecutionPatchResult<TData, TExtensions>;\n\nexport type NextLink = (operation: Operation) => Observable<FetchResult>;\n\nexport type RequestHandler = (\n operation: Operation,\n forward: NextLink\n) => Observable<FetchResult> | null;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/link/core/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { GraphQLFormattedError } from \"graphql\";\nimport type { DocumentNode } from \"graphql\";\nimport type { DefaultContext } from \"../../core/index.js\";\nexport type { DocumentNode };\n\nimport type { Observable } from \"../../utilities/index.js\";\n\n/**\n * @deprecated `ExecutionPatchResult` will be removed in Apollo Client 4.0. This\n * type is safe to use in Apollo Client 3.x.\n */\nexport type Path = ReadonlyArray<string | number>;\n\ninterface ExecutionPatchResultBase {\n hasNext?: boolean;\n}\n\n/**\n * @deprecated `ExecutionPatchResult` will be removed in Apollo Client 4.0. This\n * type is safe to use in Apollo Client 3.x.\n */\nexport interface ExecutionPatchInitialResult<\n TData = Record<string, any>,\n TExtensions = Record<string, any>,\n> extends ExecutionPatchResultBase {\n // if data is present, incremental is not\n data: TData | null | undefined;\n incremental?: never;\n errors?: ReadonlyArray<GraphQLFormattedError>;\n extensions?: TExtensions;\n}\n\n/**\n * @deprecated `ExecutionPatchResult` will be removed in Apollo Client 4.0. This\n * type is safe to use in Apollo Client 3.x.\n */\nexport interface IncrementalPayload<TData, TExtensions> {\n // data and path must both be present\n // https://github.com/graphql/graphql-spec/pull/742/files#diff-98d0cd153b72b63c417ad4238e8cc0d3385691ccbde7f7674bc0d2a718b896ecR288-R293\n data: TData | null;\n label?: string;\n path: Path;\n errors?: ReadonlyArray<GraphQLFormattedError>;\n extensions?: TExtensions;\n}\n\n/**\n * @deprecated `ExecutionPatchResult` will be removed in Apollo Client 4.0. This\n * type is safe to use in Apollo Client 3.x.\n */\nexport interface ExecutionPatchIncrementalResult<\n TData = Record<string, any>,\n TExtensions = Record<string, any>,\n> extends ExecutionPatchResultBase {\n // the reverse is also true: if incremental is present,\n // data (and errors and extensions) are not\n incremental?: IncrementalPayload<TData, TExtensions>[];\n data?: never;\n // Errors only exist for chunks, not at the top level\n // https://github.com/robrichard/defer-stream-wg/discussions/50#discussioncomment-3466739\n errors?: never;\n extensions?: never;\n}\n\nexport interface ApolloPayloadResult<\n TData = Record<string, any>,\n TExtensions = Record<string, any>,\n> {\n payload:\n | SingleExecutionResult<TData, DefaultContext, TExtensions>\n | ExecutionPatchResult<TData, TExtensions>\n | null;\n // Transport layer errors (as distinct from GraphQL or NetworkErrors),\n // these are fatal errors that will include done: true.\n errors?: ReadonlyArray<GraphQLFormattedError>;\n}\n\n/**\n * @deprecated `ExecutionPatchResult` will be removed in Apollo Client 4.0. This\n * type is safe to use in Apollo Client 3.x.\n */\nexport type ExecutionPatchResult<\n TData = Record<string, any>,\n TExtensions = Record<string, any>,\n> =\n | ExecutionPatchInitialResult<TData, TExtensions>\n | ExecutionPatchIncrementalResult<TData, TExtensions>;\n\nexport interface GraphQLRequest<TVariables = Record<string, any>> {\n query: DocumentNode;\n variables?: TVariables;\n operationName?: string;\n context?: DefaultContext;\n extensions?: Record<string, any>;\n}\n\nexport interface Operation {\n query: DocumentNode;\n variables: Record<string, any>;\n operationName: string;\n extensions: Record<string, any>;\n setContext: {\n (context: Partial<DefaultContext>): void;\n (\n updateContext: (\n previousContext: DefaultContext\n ) => Partial<DefaultContext>\n ): void;\n };\n getContext: () => DefaultContext;\n}\n\nexport interface SingleExecutionResult<\n TData = Record<string, any>,\n TContext = DefaultContext,\n TExtensions = Record<string, any>,\n> {\n // data might be undefined if errorPolicy was set to 'ignore'\n data?: TData | null;\n context?: TContext;\n errors?: ReadonlyArray<GraphQLFormattedError>;\n extensions?: TExtensions;\n}\n\nexport type FetchResult<\n TData = Record<string, any>,\n TContext = Record<string, any>,\n TExtensions = Record<string, any>,\n> =\n | SingleExecutionResult<TData, TContext, TExtensions>\n | ExecutionPatchResult<TData, TExtensions>;\n\nexport type NextLink = (operation: Operation) => Observable<FetchResult>;\n\nexport type RequestHandler = (\n operation: Operation,\n forward: NextLink\n) => Observable<FetchResult> | null;\n"]}