@apollo/client
Version:
A fully-featured caching GraphQL client.
1 lines • 5.39 kB
Source Map (JSON)
{"version":3,"file":"HttpLink.cjs","sources":["../../../../src/link/http/HttpLink.ts"],"sourcesContent":["import { ApolloLink } from \"@apollo/client/link\";\nimport { ClientAwarenessLink } from \"@apollo/client/link/client-awareness\";\n\nimport { BaseHttpLink } from \"./BaseHttpLink.js\";\n\nexport declare namespace HttpLink {\n /**\n * Options passed to `HttpLink` through [request context](https://apollographql.com/docs/react/api/link/introduction#managing-context). Previous\n * non-terminating links in the link chain also can set these values to\n * customize the behavior of `HttpLink` for each operation.\n *\n * > [!NOTE]\n * > Some of these values can also be provided to the `HttpLink` constructor.\n * > If a value is provided to both, the value in `context` takes precedence.\n */\n interface ContextOptions\n extends BaseHttpLink.ContextOptions,\n ClientAwarenessLink.ContextOptions {}\n\n /**\n * Options provided to the `HttpLink` constructor.\n *\n * > [!NOTE]\n * > Some of these options are also available to override in [request context](https://apollographql.com/docs/react/api/link/introduction#managing-context).\n * > Context options override the options passed to the constructor. Treat\n * > these options as default values that are used when the request context\n * > does not override the value.\n */\n interface Options extends BaseHttpLink.Options, ClientAwarenessLink.Options {}\n}\n\n/**\n * `HttpLink` is a terminating link that sends a GraphQL operation to a remote\n * endpoint over HTTP. It combines the functionality of `BaseHttpLink` and\n * `ClientAwarenessLink` into a single link.\n *\n * @remarks\n *\n * `HttpLink` supports both POST and GET requests, and you can configure HTTP\n * options on a per-operation basis. You can use these options for\n * authentication, persisted queries, dynamic URIs, and other granular updates.\n *\n * @example\n *\n * ```ts\n * import { HttpLink } from \"@apollo/client\";\n *\n * const link = new HttpLink({\n * uri: \"http://localhost:4000/graphql\",\n * // Additional options\n * });\n * ```\n */\nexport class HttpLink extends ApolloLink {\n constructor(options: HttpLink.Options = {}) {\n const { left, right, request } = ApolloLink.from([\n new ClientAwarenessLink(options),\n new BaseHttpLink(options),\n ]);\n super(request);\n Object.assign(this, { left, right });\n }\n}\n\n/**\n * @deprecated\n * Use `HttpLink`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