@apollo/client 4.0.0-rc.7 → 4.0.0-rc.8

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 (124) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/__cjs/core/index.cjs +1 -2
  3. package/__cjs/core/index.cjs.map +1 -1
  4. package/__cjs/core/index.d.cts +1 -2
  5. package/__cjs/invariantErrorCodes.cjs +9 -9
  6. package/__cjs/link/batch/batchLink.cjs +1 -3
  7. package/__cjs/link/batch/batchLink.cjs.map +1 -1
  8. package/__cjs/link/batch/batchLink.d.cts +35 -26
  9. package/__cjs/link/batch/batching.cjs.map +1 -1
  10. package/__cjs/link/batch/batching.d.cts +2 -2
  11. package/__cjs/link/batch/index.cjs +1 -2
  12. package/__cjs/link/batch/index.cjs.map +1 -1
  13. package/__cjs/link/batch/index.d.cts +1 -2
  14. package/__cjs/link/batch-http/batchHttpLink.cjs +23 -3
  15. package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
  16. package/__cjs/link/batch-http/batchHttpLink.d.cts +44 -4
  17. package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +33 -0
  18. package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -1
  19. package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +35 -2
  20. package/__cjs/link/error/index.cjs +44 -0
  21. package/__cjs/link/error/index.cjs.map +1 -1
  22. package/__cjs/link/error/index.d.cts +64 -4
  23. package/__cjs/link/http/BaseHttpLink.cjs +1 -2
  24. package/__cjs/link/http/BaseHttpLink.cjs.map +1 -1
  25. package/__cjs/link/http/HttpLink.cjs +22 -0
  26. package/__cjs/link/http/HttpLink.cjs.map +1 -1
  27. package/__cjs/link/http/HttpLink.d.cts +190 -87
  28. package/__cjs/link/http/checkFetcher.cjs +1 -1
  29. package/__cjs/link/http/index.cjs +1 -3
  30. package/__cjs/link/http/index.cjs.map +1 -1
  31. package/__cjs/link/http/index.d.cts +0 -2
  32. package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
  33. package/__cjs/link/http/rewriteURIForGET.cjs +2 -3
  34. package/__cjs/link/http/rewriteURIForGET.cjs.map +1 -1
  35. package/__cjs/link/persisted-queries/index.cjs +2 -2
  36. package/__cjs/link/persisted-queries/index.cjs.map +1 -1
  37. package/__cjs/link/persisted-queries/index.d.cts +23 -24
  38. package/__cjs/link/remove-typename/index.cjs.map +1 -1
  39. package/__cjs/link/remove-typename/index.d.cts +0 -1
  40. package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
  41. package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +9 -8
  42. package/__cjs/link/retry/delayFunction.cjs.map +1 -1
  43. package/__cjs/link/retry/delayFunction.d.cts +2 -39
  44. package/__cjs/link/retry/retryFunction.cjs.map +1 -1
  45. package/__cjs/link/retry/retryFunction.d.cts +2 -29
  46. package/__cjs/link/retry/retryLink.cjs +10 -7
  47. package/__cjs/link/retry/retryLink.cjs.map +1 -1
  48. package/__cjs/link/retry/retryLink.d.cts +56 -4
  49. package/__cjs/link/schema/index.cjs.map +1 -1
  50. package/__cjs/link/schema/index.d.cts +1 -1
  51. package/__cjs/link/subscriptions/index.cjs +23 -0
  52. package/__cjs/link/subscriptions/index.cjs.map +1 -1
  53. package/__cjs/link/subscriptions/index.d.cts +23 -0
  54. package/__cjs/link/ws/index.cjs +17 -1
  55. package/__cjs/link/ws/index.cjs.map +1 -1
  56. package/__cjs/link/ws/index.d.cts +7 -0
  57. package/__cjs/utilities/subscriptions/relay/index.cjs +1 -2
  58. package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
  59. package/__cjs/version.cjs +1 -1
  60. package/core/index.d.ts +1 -2
  61. package/core/index.js +1 -1
  62. package/core/index.js.map +1 -1
  63. package/invariantErrorCodes.js +9 -9
  64. package/link/batch/batchLink.d.ts +36 -27
  65. package/link/batch/batchLink.js +0 -1
  66. package/link/batch/batchLink.js.map +1 -1
  67. package/link/batch/batching.d.ts +2 -2
  68. package/link/batch/batching.js.map +1 -1
  69. package/link/batch/index.d.ts +1 -2
  70. package/link/batch/index.js +1 -1
  71. package/link/batch/index.js.map +1 -1
  72. package/link/batch-http/batchHttpLink.d.ts +45 -5
  73. package/link/batch-http/batchHttpLink.js +24 -4
  74. package/link/batch-http/batchHttpLink.js.map +1 -1
  75. package/link/client-awareness/ClientAwarenessLink.d.ts +35 -2
  76. package/link/client-awareness/ClientAwarenessLink.js +33 -0
  77. package/link/client-awareness/ClientAwarenessLink.js.map +1 -1
  78. package/link/error/index.d.ts +65 -5
  79. package/link/error/index.js +44 -0
  80. package/link/error/index.js.map +1 -1
  81. package/link/http/BaseHttpLink.js +1 -2
  82. package/link/http/BaseHttpLink.js.map +1 -1
  83. package/link/http/HttpLink.d.ts +191 -88
  84. package/link/http/HttpLink.js +22 -0
  85. package/link/http/HttpLink.js.map +1 -1
  86. package/link/http/checkFetcher.js +1 -1
  87. package/link/http/index.d.ts +0 -2
  88. package/link/http/index.js +0 -1
  89. package/link/http/index.js.map +1 -1
  90. package/link/http/parseAndCheckHttpResponse.js +1 -1
  91. package/link/http/rewriteURIForGET.js +2 -3
  92. package/link/http/rewriteURIForGET.js.map +1 -1
  93. package/link/persisted-queries/index.d.ts +23 -24
  94. package/link/persisted-queries/index.js +2 -2
  95. package/link/persisted-queries/index.js.map +1 -1
  96. package/link/remove-typename/index.d.ts +0 -1
  97. package/link/remove-typename/index.js.map +1 -1
  98. package/link/remove-typename/removeTypenameFromVariables.d.ts +9 -8
  99. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
  100. package/link/retry/delayFunction.d.ts +2 -39
  101. package/link/retry/delayFunction.js.map +1 -1
  102. package/link/retry/retryFunction.d.ts +2 -29
  103. package/link/retry/retryFunction.js.map +1 -1
  104. package/link/retry/retryLink.d.ts +56 -4
  105. package/link/retry/retryLink.js +11 -8
  106. package/link/retry/retryLink.js.map +1 -1
  107. package/link/schema/index.d.ts +1 -1
  108. package/link/schema/index.js.map +1 -1
  109. package/link/subscriptions/index.d.ts +23 -0
  110. package/link/subscriptions/index.js +23 -0
  111. package/link/subscriptions/index.js.map +1 -1
  112. package/link/ws/index.d.ts +7 -0
  113. package/link/ws/index.js +13 -1
  114. package/link/ws/index.js.map +1 -1
  115. package/package.json +1 -1
  116. package/utilities/subscriptions/relay/index.js +1 -2
  117. package/utilities/subscriptions/relay/index.js.map +1 -1
  118. package/version.js +1 -1
  119. package/__cjs/link/http/serializeFetchParameter.cjs +0 -18
  120. package/__cjs/link/http/serializeFetchParameter.cjs.map +0 -1
  121. package/__cjs/link/http/serializeFetchParameter.d.cts +0 -6
  122. package/link/http/serializeFetchParameter.d.ts +0 -6
  123. package/link/http/serializeFetchParameter.js +0 -14
  124. package/link/http/serializeFetchParameter.js.map +0 -1
@@ -2,12 +2,29 @@ import { Observable } from "rxjs";
2
2
  import type { ErrorLike } from "@apollo/client";
3
3
  import { ApolloLink } from "@apollo/client/link";
4
4
  export declare namespace ErrorLink {
5
+ namespace ErrorLinkDocumentationTypes {
6
+ /**
7
+ * Callback that is called by `ErrorLink` when an error occurs from a
8
+ * downstream link in link chain.
9
+ *
10
+ * @param options - The options object provided by `ErrorLink` to the error
11
+ * handler when an error occurs.
12
+ */
13
+ function ErrorHandler(options: ErrorHandlerOptions): Observable<ApolloLink.Result> | void;
14
+ }
5
15
  /**
6
- * Callback to be triggered when an error occurs within the link stack.
7
- */
16
+ * Callback that is called by `ErrorLink` when an error occurs from a
17
+ * downstream link in link chain.
18
+ *
19
+ * @param options - The options object provided by `ErrorLink` to the error
20
+ * handler when an error occurs.
21
+ */
8
22
  interface ErrorHandler {
9
23
  (options: ErrorHandlerOptions): Observable<ApolloLink.Result> | void;
10
24
  }
25
+ /**
26
+ * The object provided to the `ErrorHandler` callback function.
27
+ */
11
28
  interface ErrorHandlerOptions {
12
29
  /**
13
30
  * The error that occurred during the operation execution. This can be a
@@ -33,13 +50,56 @@ export declare namespace ErrorLink {
33
50
  forward: ApolloLink.ForwardFunction;
34
51
  }
35
52
  }
36
- export import ErrorHandler = ErrorLink.ErrorHandler;
37
53
  /**
38
54
  * @deprecated
39
55
  * Use `ErrorLink` from `@apollo/client/link/error` instead.
40
56
  */
41
- export declare function onError(errorHandler: ErrorHandler): ErrorLink;
57
+ export declare function onError(errorHandler: ErrorLink.ErrorHandler): ErrorLink;
58
+ /**
59
+ * Use the `ErrorLink` to perform custom logic when a [GraphQL or network error](https://apollographql.com/docs/react/data/error-handling)
60
+ * occurs.
61
+ *
62
+ * @remarks
63
+ *
64
+ * This link is used after the GraphQL operation completes and execution is
65
+ * moving back up your [link chain](https://apollographql.com/docs/react/introduction#handling-a-response). The `errorHandler` function should
66
+ * not return a value unless you want to [retry the operation](https://apollographql.com/docs/react/data/error-handling#retrying-operations).
67
+ *
68
+ * For more information on the types of errors that might be encountered, see
69
+ * the guide on [error handling](https://apollographql.com/docs/react/data/error-handling).
70
+ *
71
+ * @example
72
+ *
73
+ * ```ts
74
+ * import { ErrorLink } from "@apollo/client/link/error";
75
+ * import {
76
+ * CombinedGraphQLErrors,
77
+ * CombinedProtocolErrors,
78
+ * } from "@apollo/client/errors";
79
+ *
80
+ * // Log any GraphQL errors, protocol errors, or network error that occurred
81
+ * const errorLink = new ErrorLink(({ error, operation }) => {
82
+ * if (CombinedGraphQLErrors.is(error)) {
83
+ * error.errors.forEach(({ message, locations, path }) =>
84
+ * console.log(
85
+ * `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
86
+ * )
87
+ * );
88
+ * } else if (CombinedProtocolErrors.is(error)) {
89
+ * error.errors.forEach(({ message, extensions }) =>
90
+ * console.log(
91
+ * `[Protocol error]: Message: ${message}, Extensions: ${JSON.stringify(
92
+ * extensions
93
+ * )}`
94
+ * )
95
+ * );
96
+ * } else {
97
+ * console.error(`[Network error]: ${error}`);
98
+ * }
99
+ * });
100
+ * ```
101
+ */
42
102
  export declare class ErrorLink extends ApolloLink {
43
103
  constructor(errorHandler: ErrorLink.ErrorHandler);
44
104
  }
45
- //# sourceMappingURL=index.d.ts.map
105
+ //# sourceMappingURL=index.d.ts.map
@@ -8,6 +8,50 @@ import { ApolloLink } from "@apollo/client/link";
8
8
  export function onError(errorHandler) {
9
9
  return new ErrorLink(errorHandler);
10
10
  }
11
+ /**
12
+ * Use the `ErrorLink` to perform custom logic when a [GraphQL or network error](https://apollographql.com/docs/react/data/error-handling)
13
+ * occurs.
14
+ *
15
+ * @remarks
16
+ *
17
+ * This link is used after the GraphQL operation completes and execution is
18
+ * moving back up your [link chain](https://apollographql.com/docs/react/introduction#handling-a-response). The `errorHandler` function should
19
+ * not return a value unless you want to [retry the operation](https://apollographql.com/docs/react/data/error-handling#retrying-operations).
20
+ *
21
+ * For more information on the types of errors that might be encountered, see
22
+ * the guide on [error handling](https://apollographql.com/docs/react/data/error-handling).
23
+ *
24
+ * @example
25
+ *
26
+ * ```ts
27
+ * import { ErrorLink } from "@apollo/client/link/error";
28
+ * import {
29
+ * CombinedGraphQLErrors,
30
+ * CombinedProtocolErrors,
31
+ * } from "@apollo/client/errors";
32
+ *
33
+ * // Log any GraphQL errors, protocol errors, or network error that occurred
34
+ * const errorLink = new ErrorLink(({ error, operation }) => {
35
+ * if (CombinedGraphQLErrors.is(error)) {
36
+ * error.errors.forEach(({ message, locations, path }) =>
37
+ * console.log(
38
+ * `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
39
+ * )
40
+ * );
41
+ * } else if (CombinedProtocolErrors.is(error)) {
42
+ * error.errors.forEach(({ message, extensions }) =>
43
+ * console.log(
44
+ * `[Protocol error]: Message: ${message}, Extensions: ${JSON.stringify(
45
+ * extensions
46
+ * )}`
47
+ * )
48
+ * );
49
+ * } else {
50
+ * console.error(`[Network error]: ${error}`);
51
+ * }
52
+ * });
53
+ * ```
54
+ */
11
55
  export class ErrorLink extends ApolloLink {
12
56
  constructor(errorHandler) {
13
57
  super((operation, forward) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","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C,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type { Subscription } from \"rxjs\";\nimport { Observable } from \"rxjs\";\n\nimport type { ErrorLike } from \"@apollo/client\";\nimport {\n CombinedGraphQLErrors,\n graphQLResultHasProtocolErrors,\n PROTOCOL_ERRORS_SYMBOL,\n toErrorLike,\n} from \"@apollo/client/errors\";\nimport { ApolloLink } from \"@apollo/client/link\";\n\nexport declare namespace ErrorLink {\n /**\n * Callback to be triggered when an error occurs within the link stack.\n */\n export interface ErrorHandler {\n (options: ErrorHandlerOptions): Observable<ApolloLink.Result> | void;\n }\n\n export interface ErrorHandlerOptions {\n /**\n * The error that occurred during the operation execution. This can be a\n * `CombinedGraphQLErrors` instance (for GraphQL errors) or another error\n * type (for network errors).\n *\n * Use `CombinedGraphQLErrors.is(error)` to check if it's a GraphQL error with an `errors` array.\n */\n error: ErrorLike;\n /**\n * The raw GraphQL result from the server (if available), which may include\n * partial data alongside errors.\n */\n result?: ApolloLink.Result;\n\n /** The details of the GraphQL operation that produced an error. */\n operation: ApolloLink.Operation;\n\n /**\n * A function that calls the next link in the link chain. Calling\n * `return forward(operation)` in your `ErrorLink` callback\n * [retries the operation](../../data/error-handling#retrying-operations), returning a new observable for the\n * upstream link to subscribe to.\n */\n forward: ApolloLink.ForwardFunction;\n }\n}\n\n// For backwards compatibility.\nexport import ErrorHandler = ErrorLink.ErrorHandler;\n\n/**\n * @deprecated\n * Use `ErrorLink` from `@apollo/client/link/error` instead.\n */\nexport function onError(errorHandler: ErrorHandler) {\n return new ErrorLink(errorHandler);\n}\n\nexport class ErrorLink extends ApolloLink {\n constructor(errorHandler: ErrorLink.ErrorHandler) {\n super((operation, forward) => {\n return new Observable((observer) => {\n let sub: Subscription | undefined;\n let retriedSub: Subscription | undefined;\n let retriedResult: ReturnType<ErrorHandler>;\n\n try {\n sub = forward(operation).subscribe({\n next: (result) => {\n const handler =\n operation.client[\"queryManager\"].incrementalHandler;\n const errors =\n handler.isIncrementalResult(result) ?\n handler.extractErrors(result)\n : result.errors;\n if (errors) {\n retriedResult = errorHandler({\n error: new CombinedGraphQLErrors(result, errors),\n result,\n operation,\n forward,\n });\n } else if (graphQLResultHasProtocolErrors(result)) {\n retriedResult = errorHandler({\n error: result.extensions[PROTOCOL_ERRORS_SYMBOL],\n result,\n operation,\n forward,\n });\n }\n\n retriedSub = retriedResult?.subscribe(observer);\n\n if (!retriedSub) {\n observer.next(result);\n }\n },\n error: (error) => {\n retriedResult = errorHandler({\n operation,\n error: toErrorLike(error),\n forward,\n });\n retriedSub = retriedResult?.subscribe(observer);\n\n if (!retriedSub) {\n observer.error(error);\n }\n },\n complete: () => {\n // disable the previous sub from calling complete on observable\n // if retry is in flight.\n if (!retriedResult) {\n observer.complete();\n }\n },\n });\n } catch (e) {\n errorHandler({ error: toErrorLike(e), operation, forward });\n observer.error(e);\n }\n\n return () => {\n if (sub) sub.unsubscribe();\n if (retriedSub) retriedSub.unsubscribe();\n };\n });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/error/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGlC,OAAO,EACL,qBAAqB,EACrB,8BAA8B,EAC9B,sBAAsB,EACtB,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAsDjD;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,YAAoC;IAC1D,OAAO,IAAI,SAAS,CAAC,YAAY,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,OAAO,SAAU,SAAQ,UAAU;IACvC,YAAY,YAAoC;QAC9C,KAAK,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE;YAC3B,OAAO,IAAI,UAAU,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACjC,IAAI,G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BAEhD,IAAI,CAAC,UAAU,EAAE,CAAC;gCAChB,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;4BACxB,CAAC;wBACH,CAAC;wBACD,QAAQ,EAAE,GAAG,EAAE;4BACb,+DAA+D;4BAC/D,yBAAyB;4BACzB,IAAI,CAAC,aAAa,EAAE,CAAC;gCACnB,QAAQ,CAAC,QAAQ,EAAE,CAAC;4BACtB,CAAC;wBACH,CAAC;qBACF,CAAC,CAAC;gBACL,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,YAAY,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;oBAC5D,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACpB,CAAC;gBAED,OAAO,GAAG,EAAE;oBACV,IAAI,GAAG;wBAAE,GAAG,CAAC,WAAW,EAAE,CAAC;oBAC3B,IAAI,UAAU;wBAAE,UAAU,CAAC,WAAW,EAAE,CAAC;gBAC3C,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type { Subscription } from \"rxjs\";\nimport { Observable } from \"rxjs\";\n\nimport type { ErrorLike } from \"@apollo/client\";\nimport {\n CombinedGraphQLErrors,\n graphQLResultHasProtocolErrors,\n PROTOCOL_ERRORS_SYMBOL,\n toErrorLike,\n} from \"@apollo/client/errors\";\nimport { ApolloLink } from \"@apollo/client/link\";\n\nexport declare namespace ErrorLink {\n // Using a different namespace name to avoid clash with\n // `ApolloLink.DocumentationTypes`\n export namespace ErrorLinkDocumentationTypes {\n /**\n * Callback that is called by `ErrorLink` when an error occurs from a\n * downstream link in link chain.\n *\n * @param options - The options object provided by `ErrorLink` to the error\n * handler when an error occurs.\n */\n export function ErrorHandler(\n options: ErrorHandlerOptions\n ): Observable<ApolloLink.Result> | void;\n }\n\n /** {@inheritDoc @apollo/client/link/error!ErrorLink.ErrorLinkDocumentationTypes.ErrorHandler:function(1)} */\n export interface ErrorHandler {\n (options: ErrorHandlerOptions): Observable<ApolloLink.Result> | void;\n }\n\n /**\n * The object provided to the `ErrorHandler` callback function.\n */\n export interface ErrorHandlerOptions {\n /**\n * The error that occurred during the operation execution. This can be a\n * `CombinedGraphQLErrors` instance (for GraphQL errors) or another error\n * type (for network errors).\n *\n * Use `CombinedGraphQLErrors.is(error)` to check if it's a GraphQL error with an `errors` array.\n */\n error: ErrorLike;\n /**\n * The raw GraphQL result from the server (if available), which may include\n * partial data alongside errors.\n */\n result?: ApolloLink.Result;\n\n /** The details of the GraphQL operation that produced an error. */\n operation: ApolloLink.Operation;\n\n /**\n * A function that calls the next link in the link chain. Calling\n * `return forward(operation)` in your `ErrorLink` callback\n * [retries the operation](../../data/error-handling#retrying-operations), returning a new observable for the\n * upstream link to subscribe to.\n */\n forward: ApolloLink.ForwardFunction;\n }\n}\n\n/**\n * @deprecated\n * Use `ErrorLink` from `@apollo/client/link/error` instead.\n */\nexport function onError(errorHandler: ErrorLink.ErrorHandler) {\n return new ErrorLink(errorHandler);\n}\n\n/**\n * Use the `ErrorLink` to perform custom logic when a [GraphQL or network error](https://apollographql.com/docs/react/data/error-handling)\n * occurs.\n *\n * @remarks\n *\n * This link is used after the GraphQL operation completes and execution is\n * moving back up your [link chain](https://apollographql.com/docs/react/introduction#handling-a-response). The `errorHandler` function should\n * not return a value unless you want to [retry the operation](https://apollographql.com/docs/react/data/error-handling#retrying-operations).\n *\n * For more information on the types of errors that might be encountered, see\n * the guide on [error handling](https://apollographql.com/docs/react/data/error-handling).\n *\n * @example\n *\n * ```ts\n * import { ErrorLink } from \"@apollo/client/link/error\";\n * import {\n * CombinedGraphQLErrors,\n * CombinedProtocolErrors,\n * } from \"@apollo/client/errors\";\n *\n * // Log any GraphQL errors, protocol errors, or network error that occurred\n * const errorLink = new ErrorLink(({ error, operation }) => {\n * if (CombinedGraphQLErrors.is(error)) {\n * error.errors.forEach(({ message, locations, path }) =>\n * console.log(\n * `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`\n * )\n * );\n * } else if (CombinedProtocolErrors.is(error)) {\n * error.errors.forEach(({ message, extensions }) =>\n * console.log(\n * `[Protocol error]: Message: ${message}, Extensions: ${JSON.stringify(\n * extensions\n * )}`\n * )\n * );\n * } else {\n * console.error(`[Network error]: ${error}`);\n * }\n * });\n * ```\n */\nexport class ErrorLink extends ApolloLink {\n constructor(errorHandler: ErrorLink.ErrorHandler) {\n super((operation, forward) => {\n return new Observable((observer) => {\n let sub: Subscription | undefined;\n let retriedSub: Subscription | undefined;\n let retriedResult: ReturnType<ErrorLink.ErrorHandler>;\n\n try {\n sub = forward(operation).subscribe({\n next: (result) => {\n const handler =\n operation.client[\"queryManager\"].incrementalHandler;\n const errors =\n handler.isIncrementalResult(result) ?\n handler.extractErrors(result)\n : result.errors;\n if (errors) {\n retriedResult = errorHandler({\n error: new CombinedGraphQLErrors(result, errors),\n result,\n operation,\n forward,\n });\n } else if (graphQLResultHasProtocolErrors(result)) {\n retriedResult = errorHandler({\n error: result.extensions[PROTOCOL_ERRORS_SYMBOL],\n result,\n operation,\n forward,\n });\n }\n\n retriedSub = retriedResult?.subscribe(observer);\n\n if (!retriedSub) {\n observer.next(result);\n }\n },\n error: (error) => {\n retriedResult = errorHandler({\n operation,\n error: toErrorLike(error),\n forward,\n });\n retriedSub = retriedResult?.subscribe(observer);\n\n if (!retriedSub) {\n observer.error(error);\n }\n },\n complete: () => {\n // disable the previous sub from calling complete on observable\n // if retry is in flight.\n if (!retriedResult) {\n observer.complete();\n }\n },\n });\n } catch (e) {\n errorHandler({ error: toErrorLike(e), operation, forward });\n observer.error(e);\n }\n\n return () => {\n if (sub) sub.unsubscribe();\n if (retriedSub) retriedSub.unsubscribe();\n };\n });\n });\n }\n}\n"]}
@@ -10,7 +10,6 @@ import { parseAndCheckHttpResponse, readMultipartBody, } from "./parseAndCheckHt
10
10
  import { rewriteURIForGET } from "./rewriteURIForGET.js";
11
11
  import { defaultPrinter, fallbackHttpConfig, selectHttpOptionsAndBodyInternal, } from "./selectHttpOptionsAndBody.js";
12
12
  import { selectURI } from "./selectURI.js";
13
- import { serializeFetchParameter } from "./serializeFetchParameter.js";
14
13
  const backupFetch = maybe(() => fetch);
15
14
  export class BaseHttpLink extends ApolloLink {
16
15
  constructor(linkOptions = {}) {
@@ -66,7 +65,7 @@ export class BaseHttpLink extends ApolloLink {
66
65
  chosenURI = newURI;
67
66
  }
68
67
  else {
69
- options.body = serializeFetchParameter(body, "Payload");
68
+ options.body = JSON.stringify(body);
70
69
  }
71
70
  // Prefer linkOptions.fetch (preferredFetch) if provided, and otherwise
72
71
  // fall back to the *current* global window.fetch function (see issue
@@ -1 +1 @@
1
- {"version":3,"file":"BaseHttpLink.js","sourceRoot":"","sources":["../../../src/link/http/BaseHttpLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EACL,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,gCAAgC,GACjC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA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ApolloLink } from \"@apollo/client/link\";\nimport { filterOperationVariables } from \"@apollo/client/link/utils\";\nimport {\n isMutationOperation,\n isSubscriptionOperation,\n} from \"@apollo/client/utilities\";\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport { compact } from \"@apollo/client/utilities/internal\";\nimport { maybe } from \"@apollo/client/utilities/internal/globals\";\n\nimport { checkFetcher } from \"./checkFetcher.js\";\nimport type { HttpLink } from \"./HttpLink.js\";\nimport {\n parseAndCheckHttpResponse,\n readMultipartBody,\n} from \"./parseAndCheckHttpResponse.js\";\nimport { rewriteURIForGET } from \"./rewriteURIForGET.js\";\nimport {\n defaultPrinter,\n fallbackHttpConfig,\n selectHttpOptionsAndBodyInternal,\n} from \"./selectHttpOptionsAndBody.js\";\nimport { selectURI } from \"./selectURI.js\";\nimport { serializeFetchParameter } from \"./serializeFetchParameter.js\";\n\nconst backupFetch = maybe(() => fetch);\n\nexport class BaseHttpLink extends ApolloLink {\n constructor(linkOptions: HttpLink.Options = {}) {\n let {\n uri = \"/graphql\",\n // use default global fetch if nothing passed in\n fetch: preferredFetch,\n print = defaultPrinter,\n includeExtensions,\n preserveHeaderCase,\n useGETForQueries,\n includeUnusedVariables = false,\n ...requestOptions\n } = linkOptions;\n\n if (__DEV__) {\n // Make sure at least one of preferredFetch, window.fetch, or backupFetch is\n // defined, so requests won't fail at runtime.\n checkFetcher(preferredFetch || backupFetch);\n }\n\n const linkConfig = {\n http: compact({ includeExtensions, preserveHeaderCase }),\n options: requestOptions.fetchOptions,\n credentials: requestOptions.credentials,\n headers: requestOptions.headers,\n };\n\n super((operation) => {\n let chosenURI = selectURI(operation, uri);\n\n const context = operation.getContext();\n\n const http = { ...context.http };\n if (isSubscriptionOperation(operation.query)) {\n http.accept = [\n \"multipart/mixed;boundary=graphql;subscriptionSpec=1.0\",\n ...(http.accept || []),\n ];\n }\n\n const contextConfig = {\n http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: context.headers,\n };\n\n //uses fallback, link, and then context to build options\n const { options, body } = selectHttpOptionsAndBodyInternal(\n operation,\n print,\n fallbackHttpConfig,\n linkConfig,\n contextConfig\n );\n\n if (body.variables && !includeUnusedVariables) {\n body.variables = filterOperationVariables(\n body.variables,\n operation.query\n );\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 if (useGETForQueries && !isMutationOperation(operation.query)) {\n options.method = \"GET\";\n }\n\n return new Observable((observer) => {\n if (options.method === \"GET\") {\n const { newURI, parseError } = rewriteURIForGET(chosenURI, body);\n if (parseError) {\n throw parseError;\n }\n chosenURI = newURI;\n } else {\n options.body = serializeFetchParameter(body, \"Payload\");\n }\n // Prefer linkOptions.fetch (preferredFetch) if provided, and otherwise\n // fall back to the *current* global window.fetch function (see issue\n // #7832), or (if all else fails) the backupFetch function we saved when\n // this module was first evaluated. This last option protects against the\n // removal of window.fetch, which is unlikely but not impossible.\n const currentFetch =\n preferredFetch || maybe(() => fetch) || backupFetch;\n\n const observerNext = observer.next.bind(observer);\n currentFetch!(chosenURI, options)\n .then((response) => {\n operation.setContext({ response });\n const ctype = response.headers?.get(\"content-type\");\n\n if (ctype !== null && /^multipart\\/mixed/i.test(ctype)) {\n return readMultipartBody(response, observerNext);\n } else {\n return parseAndCheckHttpResponse(operation)(response).then(\n observerNext\n );\n }\n })\n .then(() => {\n controller = undefined;\n observer.complete();\n })\n .catch((err) => {\n controller = undefined;\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}\n"]}
1
+ {"version":3,"file":"BaseHttpLink.js","sourceRoot":"","sources":["../../../src/link/http/BaseHttpLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,wB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BACD,IAAI,CAAC,GAAG,EAAE;oBACT,UAAU,GAAG,SAAS,CAAC;oBACvB,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBACtB,CAAC,CAAC;qBACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;oBACb,UAAU,GAAG,SAAS,CAAC;oBACvB,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACtB,CAAC,CAAC,CAAC;gBAEL,OAAO,GAAG,EAAE;oBACV,qCAAqC;oBACrC,oEAAoE;oBACpE,IAAI,UAAU;wBAAE,UAAU,CAAC,KAAK,EAAE,CAAC;gBACrC,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { Observable } from \"rxjs\";\n\nimport { ApolloLink } from \"@apollo/client/link\";\nimport { filterOperationVariables } from \"@apollo/client/link/utils\";\nimport {\n isMutationOperation,\n isSubscriptionOperation,\n} from \"@apollo/client/utilities\";\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport { compact } from \"@apollo/client/utilities/internal\";\nimport { maybe } from \"@apollo/client/utilities/internal/globals\";\n\nimport { checkFetcher } from \"./checkFetcher.js\";\nimport type { HttpLink } from \"./HttpLink.js\";\nimport {\n parseAndCheckHttpResponse,\n readMultipartBody,\n} from \"./parseAndCheckHttpResponse.js\";\nimport { rewriteURIForGET } from \"./rewriteURIForGET.js\";\nimport {\n defaultPrinter,\n fallbackHttpConfig,\n selectHttpOptionsAndBodyInternal,\n} from \"./selectHttpOptionsAndBody.js\";\nimport { selectURI } from \"./selectURI.js\";\n\nconst backupFetch = maybe(() => fetch);\n\nexport class BaseHttpLink extends ApolloLink {\n constructor(linkOptions: HttpLink.Options = {}) {\n let {\n uri = \"/graphql\",\n // use default global fetch if nothing passed in\n fetch: preferredFetch,\n print = defaultPrinter,\n includeExtensions,\n preserveHeaderCase,\n useGETForQueries,\n includeUnusedVariables = false,\n ...requestOptions\n } = linkOptions;\n\n if (__DEV__) {\n // Make sure at least one of preferredFetch, window.fetch, or backupFetch is\n // defined, so requests won't fail at runtime.\n checkFetcher(preferredFetch || backupFetch);\n }\n\n const linkConfig = {\n http: compact({ includeExtensions, preserveHeaderCase }),\n options: requestOptions.fetchOptions,\n credentials: requestOptions.credentials,\n headers: requestOptions.headers,\n };\n\n super((operation) => {\n let chosenURI = selectURI(operation, uri);\n\n const context = operation.getContext();\n\n const http = { ...context.http };\n if (isSubscriptionOperation(operation.query)) {\n http.accept = [\n \"multipart/mixed;boundary=graphql;subscriptionSpec=1.0\",\n ...(http.accept || []),\n ];\n }\n\n const contextConfig = {\n http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: context.headers,\n };\n\n //uses fallback, link, and then context to build options\n const { options, body } = selectHttpOptionsAndBodyInternal(\n operation,\n print,\n fallbackHttpConfig,\n linkConfig,\n contextConfig\n );\n\n if (body.variables && !includeUnusedVariables) {\n body.variables = filterOperationVariables(\n body.variables,\n operation.query\n );\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 if (useGETForQueries && !isMutationOperation(operation.query)) {\n options.method = \"GET\";\n }\n\n return new Observable((observer) => {\n if (options.method === \"GET\") {\n const { newURI, parseError } = rewriteURIForGET(chosenURI, body);\n if (parseError) {\n throw parseError;\n }\n chosenURI = newURI;\n } else {\n options.body = JSON.stringify(body);\n }\n // Prefer linkOptions.fetch (preferredFetch) if provided, and otherwise\n // fall back to the *current* global window.fetch function (see issue\n // #7832), or (if all else fails) the backupFetch function we saved when\n // this module was first evaluated. This last option protects against the\n // removal of window.fetch, which is unlikely but not impossible.\n const currentFetch =\n preferredFetch || maybe(() => fetch) || backupFetch;\n\n const observerNext = observer.next.bind(observer);\n currentFetch!(chosenURI, options)\n .then((response) => {\n operation.setContext({ response });\n const ctype = response.headers?.get(\"content-type\");\n\n if (ctype !== null && /^multipart\\/mixed/i.test(ctype)) {\n return readMultipartBody(response, observerNext);\n } else {\n return parseAndCheckHttpResponse(operation)(response).then(\n observerNext\n );\n }\n })\n .then(() => {\n controller = undefined;\n observer.complete();\n })\n .catch((err) => {\n controller = undefined;\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}\n"]}
@@ -4,33 +4,52 @@ import { ClientAwarenessLink } from "@apollo/client/link/client-awareness";
4
4
  import type { print } from "@apollo/client/utilities";
5
5
  export declare namespace HttpLink {
6
6
  /**
7
- * Options passed to `HttpLink` through request context.
7
+ * Options passed to `HttpLink` through [request context](https://apollographql.com/docs/react/api/link/introduction#managing-context). Previous
8
+ * non-terminating links in the link chain also can set these values to
9
+ * customize the behavior of `HttpLink` for each operation.
10
+ *
11
+ * > [!NOTE]
12
+ * > Some of these values can also be provided to the `HttpLink` constructor.
13
+ * > If a value is provided to both, the value in `context` takes precedence.
8
14
  */
9
15
  interface ContextOptions {
10
16
  /**
11
- * The URL of the GraphQL endpoint to send requests to. Can also be a
12
- * function that accepts an `Operation` object and returns the string URL to
13
- * use for that operation.
14
- */
15
- uri?: string | UriFunction;
17
+ * The URL of the GraphQL endpoint to send requests to. Can also be a
18
+ * function that accepts an `ApolloLink.Operation` object and returns the
19
+ * string URL to use for that operation.
20
+ *
21
+ * @defaultValue "/graphql"
22
+ */
23
+ uri?: string | HttpLink.UriFunction;
16
24
  /**
17
- * An object representing headers to include in the HTTP request, such as
18
- * `{Authorization: 'Bearer abc123'}`.
19
- */
25
+ * An object representing headers to include in every HTTP request.
26
+ *
27
+ * @example
28
+ *
29
+ * ```json
30
+ * {
31
+ * "Authorization": "Bearer 1234"
32
+ * }
33
+ * ```
34
+ */
20
35
  headers?: Record<string, string>;
21
36
  /**
22
- * The credentials policy to use for this fetch call. Can be `omit`, `include`,
23
- * or `same-origin`.
24
- */
37
+ * The credentials policy to use for each `fetch` call.
38
+ */
25
39
  credentials?: RequestCredentials;
26
40
  /**
27
- * An object containing options to use for this call to `fetch`. If a
28
- * particular option is not included in this object, the default value of
29
- * that option is used.
30
- *
31
- * Note that if you set `fetchOptions.method` to `GET`, `HttpLink` follows
32
- * [standard GraphQL HTTP GET encoding](http://graphql.org/learn/serving-over-http/#get-request).
33
- */
41
+ * Any overrides of the fetch options argument to pass to the fetch call.
42
+ *
43
+ * An object containing options to use for each call to `fetch`. If a
44
+ * particular option is not included in this object, the default value of
45
+ * that option is used.
46
+ *
47
+ * > [!NOTE]
48
+ * > If you set `fetchOptions.method` to `GET`, `HttpLink` follows [standard
49
+ * > GraphQL HTTP GET encoding](http://graphql.org/learn/serving-over-http/#get-request).
50
+ *
51
+ * See [available options](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
52
+ */
34
53
  fetchOptions?: RequestInit;
35
54
  /**
36
55
  * An object that configures advanced `HttpLink` functionality, such as
@@ -39,16 +58,16 @@ export declare namespace HttpLink {
39
58
  http?: HttpLink.HttpOptions;
40
59
  }
41
60
  /**
42
- * Options passed to `HttpLink` through the `http` constructor option
43
- * or the `http` property of a request context.
61
+ * Options passed to `HttpLink` through the `http` property of a request
62
+ * context.
44
63
  */
45
64
  interface HttpOptions {
46
65
  /**
47
- * If `true`, includes the `extensions` field in operations sent to your
48
- * GraphQL endpoint.
49
- *
50
- * @defaultValue true
51
- */
66
+ * If `true`, includes the `extensions` field in operations sent to your
67
+ * GraphQL endpoint.
68
+ *
69
+ * @defaultValue true
70
+ */
52
71
  includeExtensions?: boolean;
53
72
  /**
54
73
  * If `false`, the GraphQL query string is not included in the request. Set
@@ -58,17 +77,16 @@ export declare namespace HttpLink {
58
77
  */
59
78
  includeQuery?: boolean;
60
79
  /**
61
- * If set to true, header names won't be automatically normalized to
62
- * lowercase. This allows for non-http-spec-compliant servers that might
63
- * expect capitalized header names.
64
- *
65
- * @defaultValue false
66
- */
80
+ * If `true`, header names won't be automatically normalized to lowercase.
81
+ * This allows for non-http-spec-compliant servers that might expect
82
+ * capitalized header names.
83
+ *
84
+ * @defaultValue false
85
+ */
67
86
  preserveHeaderCase?: boolean;
68
87
  /**
69
88
  * A list of additional `accept` headers to include in the request,
70
- * as defined in
71
- * https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.2
89
+ * as defined in https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.2
72
90
  *
73
91
  * @example
74
92
  *
@@ -78,65 +96,128 @@ export declare namespace HttpLink {
78
96
  */
79
97
  accept?: string[];
80
98
  }
99
+ namespace Shared {
100
+ /** These options are shared between `HttpLink` and `BatchHttpLink` */
101
+ interface Options {
102
+ /**
103
+ * The URL of the GraphQL endpoint to send requests to. Can also be a
104
+ * function that accepts an `ApolloLink.Operation` object and returns the
105
+ * string URL to use for that operation.
106
+ *
107
+ * @defaultValue "/graphql"
108
+ */
109
+ uri?: string | HttpLink.UriFunction;
110
+ /**
111
+ * If `true`, includes the `extensions` field in operations sent to your
112
+ * GraphQL endpoint.
113
+ *
114
+ * @defaultValue true
115
+ */
116
+ includeExtensions?: boolean;
117
+ /**
118
+ * A function to use instead of calling the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) directly
119
+ * when sending HTTP requests to your GraphQL endpoint. The function must
120
+ * conform to the signature of `fetch`.
121
+ *
122
+ * By default, the Fetch API is used unless it isn't available in your
123
+ * runtime environment.
124
+ *
125
+ * See [Customizing `fetch`](https://apollographql.com/docs/react/api/link/introduction#customizing-fetch).
126
+ */
127
+ fetch?: typeof fetch;
128
+ /**
129
+ * An object representing headers to include in every HTTP request.
130
+ *
131
+ * @example
132
+ *
133
+ * ```json
134
+ * {
135
+ * "Authorization": "Bearer 1234"
136
+ * }
137
+ * ```
138
+ */
139
+ headers?: Record<string, string>;
140
+ /**
141
+ * If `true`, header names won't be automatically normalized to lowercase.
142
+ * This allows for non-http-spec-compliant servers that might expect
143
+ * capitalized header names.
144
+ *
145
+ * @defaultValue false
146
+ */
147
+ preserveHeaderCase?: boolean;
148
+ /**
149
+ * The credentials policy to use for each `fetch` call.
150
+ */
151
+ credentials?: RequestCredentials;
152
+ /**
153
+ * Any overrides of the fetch options argument to pass to the fetch call.
154
+ *
155
+ * An object containing options to use for each call to `fetch`. If a
156
+ * particular option is not included in this object, the default value of
157
+ * that option is used.
158
+ *
159
+ * > [!NOTE]
160
+ * > If you set `fetchOptions.method` to `GET`, `HttpLink` follows [standard
161
+ * > GraphQL HTTP GET encoding](http://graphql.org/learn/serving-over-http/#get-request).
162
+ *
163
+ * See [available options](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
164
+ */
165
+ fetchOptions?: RequestInit;
166
+ /**
167
+ * If `true`, unused variables from the operation will not be stripped from
168
+ * the request and will instead be sent to the GraphQL endpoint.
169
+ *
170
+ * @remarks
171
+ * Unused variables are likely to trigger server-side validation errors,
172
+ * per https://spec.graphql.org/draft/#sec-All-Variables-Used.
173
+ * `includeUnusedVariables` can be useful if your server deviates
174
+ * from the GraphQL specification by not strictly enforcing that rule.
175
+ *
176
+ * @defaultValue false
177
+ */
178
+ includeUnusedVariables?: boolean;
179
+ /**
180
+ * A function to use when transforming a GraphQL document into a string. It
181
+ * accepts an `ASTNode` (typically a `DocumentNode`) and the original `print`
182
+ * function as arguments, and is expected to return a string. This option
183
+ * enables you to, for example, use `stripIgnoredCharacters` to remove
184
+ * whitespace from queries.
185
+ *
186
+ * By default the [GraphQL `print` function](https://graphql.org/graphql-js/language/#print) is used.
187
+ *
188
+ * @example
189
+ *
190
+ * ```ts
191
+ * import { stripIgnoredCharacters } from "graphql";
192
+ *
193
+ * const httpLink = new HttpLink({
194
+ * uri: "/graphql",
195
+ * print: (ast, originalPrint) => stripIgnoredCharacters(originalPrint(ast)),
196
+ * });
197
+ * ```
198
+ */
199
+ print?: HttpLink.Printer;
200
+ }
201
+ }
81
202
  /**
82
- * Options for the `HttpLink` constructor.
203
+ * Options provided to the `HttpLink` constructor.
204
+ *
205
+ * > [!NOTE]
206
+ * > Some of these options are also available to override in [request context](https://apollographql.com/docs/react/api/link/introduction#managing-context).
207
+ * > Context options override the options passed to the constructor. Treat
208
+ * > these options as default values that are used when the request context
209
+ * > does not override the value.
83
210
  */
84
- interface Options {
85
- /**
86
- * The URI to use when fetching operations.
87
- *
88
- * Defaults to '/graphql'.
89
- */
90
- uri?: string | UriFunction;
211
+ interface Options extends Shared.Options {
91
212
  /**
92
- * Passes the extensions field to your graphql server.
213
+ * If `true`, the link uses an HTTP `GET` request when sending query
214
+ * operations to your GraphQL endpoint. Mutation operations continue to use
215
+ * `POST` requests. If you want all operations to use `GET` requests,
216
+ * set `fetchOptions.method` instead.
93
217
  *
94
- * Defaults to true.
95
- */
96
- includeExtensions?: boolean;
97
- /**
98
- * A `fetch`-compatible API to use when making requests.
99
- */
100
- fetch?: typeof fetch;
101
- /**
102
- * An object representing values to be sent as headers on the request.
103
- */
104
- headers?: Record<string, string>;
105
- /**
106
- * If set to true, header names won't be automatically normalized to
107
- * lowercase. This allows for non-http-spec-compliant servers that might
108
- * expect capitalized header names.
109
- */
110
- preserveHeaderCase?: boolean;
111
- /**
112
- * The credentials policy you want to use for the fetch call.
113
- */
114
- credentials?: string;
115
- /**
116
- * Any overrides of the fetch options argument to pass to the fetch call.
117
- */
118
- fetchOptions?: any;
119
- /**
120
- * If set to true, use the HTTP GET method for query operations. Mutations
121
- * will still use the method specified in fetchOptions.method (which defaults
122
- * to POST).
218
+ * @defaultValue false
123
219
  */
124
220
  useGETForQueries?: boolean;
125
- /**
126
- * If set to true, the default behavior of stripping unused variables
127
- * from the request will be disabled.
128
- *
129
- * Unused variables are likely to trigger server-side validation errors,
130
- * per https://spec.graphql.org/draft/#sec-All-Variables-Used, but this
131
- * includeUnusedVariables option can be useful if your server deviates
132
- * from the GraphQL specification by not strictly enforcing that rule.
133
- */
134
- includeUnusedVariables?: boolean;
135
- /**
136
- * A function to substitute for the default query print function. Can be
137
- * used to apply changes to the results of the print function.
138
- */
139
- print?: Printer;
140
221
  }
141
222
  interface Body {
142
223
  query?: string;
@@ -147,6 +228,28 @@ export declare namespace HttpLink {
147
228
  type Printer = (node: ASTNode, originalPrint: typeof print) => string;
148
229
  type UriFunction = (operation: ApolloLink.Operation) => string;
149
230
  }
231
+ /**
232
+ * `HttpLink` is a terminating link that sends a GraphQL operation to a remote
233
+ * endpoint over HTTP. It combines the functionality of `BaseHttpLink` and
234
+ * `ClientAwarenessLink` into a single link.
235
+ *
236
+ * @remarks
237
+ *
238
+ * `HttpLink` supports both POST and GET requests, and you can configure HTTP
239
+ * options on a per-operation basis. You can use these options for
240
+ * authentication, persisted queries, dynamic URIs, and other granular updates.
241
+ *
242
+ * @example
243
+ *
244
+ * ```ts
245
+ * import { HttpLink } from "@apollo/client";
246
+ *
247
+ * const link = new HttpLink({
248
+ * uri: "http://localhost:4000/graphql",
249
+ * // Additional options
250
+ * });
251
+ * ```
252
+ */
150
253
  export declare class HttpLink extends ApolloLink {
151
254
  constructor(options?: HttpLink.Options & ClientAwarenessLink.Options);
152
255
  }
@@ -155,4 +258,4 @@ export declare class HttpLink extends ApolloLink {
155
258
  * Use `HttpLink` from `@apollo/client/link/http` instead.
156
259
  */
157
260
  export declare const createHttpLink: (linkOptions?: HttpLink.Options & ClientAwarenessLink.Options) => HttpLink;
158
- //# sourceMappingURL=HttpLink.d.ts.map
261
+ //# sourceMappingURL=HttpLink.d.ts.map
@@ -1,6 +1,28 @@
1
1
  import { ApolloLink } from "@apollo/client/link";
2
2
  import { ClientAwarenessLink } from "@apollo/client/link/client-awareness";
3
3
  import { BaseHttpLink } from "./BaseHttpLink.js";
4
+ /**
5
+ * `HttpLink` is a terminating link that sends a GraphQL operation to a remote
6
+ * endpoint over HTTP. It combines the functionality of `BaseHttpLink` and
7
+ * `ClientAwarenessLink` into a single link.
8
+ *
9
+ * @remarks
10
+ *
11
+ * `HttpLink` supports both POST and GET requests, and you can configure HTTP
12
+ * options on a per-operation basis. You can use these options for
13
+ * authentication, persisted queries, dynamic URIs, and other granular updates.
14
+ *
15
+ * @example
16
+ *
17
+ * ```ts
18
+ * import { HttpLink } from "@apollo/client";
19
+ *
20
+ * const link = new HttpLink({
21
+ * uri: "http://localhost:4000/graphql",
22
+ * // Additional options
23
+ * });
24
+ * ```
25
+ */
4
26
  export class HttpLink extends ApolloLink {
5
27
  constructor(options = {}) {
6
28
  const { left, right, request } = ApolloLink.from([