@apollo/client 4.0.0-rc.8 → 4.0.0
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.
- package/CHANGELOG.md +2488 -0
- package/README.md +6 -2
- package/__cjs/cache/inmemory/inMemoryCache.cjs +2 -2
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.cjs +18 -12
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.cjs +1 -1
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.cjs +1 -1
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +1 -1
- package/__cjs/core/QueryInfo.cjs +2 -6
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +1 -1
- package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
- package/__cjs/incremental/handlers/defer20220824.d.cts +9 -6
- package/__cjs/incremental/handlers/notImplemented.cjs.map +1 -1
- package/__cjs/incremental/handlers/notImplemented.d.cts +11 -0
- package/__cjs/link/batch/batchLink.cjs +30 -2
- package/__cjs/link/batch/batchLink.cjs.map +1 -1
- package/__cjs/link/batch/batchLink.d.cts +69 -2
- package/__cjs/link/batch-http/BaseBatchHttpLink.cjs +156 -0
- package/__cjs/link/batch-http/BaseBatchHttpLink.cjs.map +1 -0
- package/__cjs/link/batch-http/BaseBatchHttpLink.d.cts +68 -0
- package/__cjs/link/batch-http/batchHttpLink.cjs +3 -128
- package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
- package/__cjs/link/batch-http/batchHttpLink.d.cts +4 -20
- package/__cjs/link/batch-http/index.cjs +2 -1
- package/__cjs/link/batch-http/index.cjs.map +1 -1
- package/__cjs/link/batch-http/index.d.cts +2 -1
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +3 -3
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -1
- package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +20 -1
- package/__cjs/link/context/index.cjs +19 -0
- package/__cjs/link/context/index.cjs.map +1 -1
- package/__cjs/link/context/index.d.cts +64 -2
- package/__cjs/link/core/ApolloLink.cjs.map +1 -1
- package/__cjs/link/core/ApolloLink.d.cts +5 -2
- package/__cjs/link/core/types.d.cts +0 -4
- package/__cjs/link/http/BaseHttpLink.cjs +59 -8
- package/__cjs/link/http/BaseHttpLink.cjs.map +1 -1
- package/__cjs/link/http/BaseHttpLink.d.cts +256 -2
- package/__cjs/link/http/HttpLink.cjs +1 -1
- package/__cjs/link/http/HttpLink.cjs.map +1 -1
- package/__cjs/link/http/HttpLink.d.cts +5 -208
- package/__cjs/link/http/rewriteURIForGET.cjs.map +1 -1
- package/__cjs/link/http/rewriteURIForGET.d.cts +2 -2
- package/__cjs/link/http/selectHttpOptionsAndBody.cjs.map +1 -1
- package/__cjs/link/http/selectHttpOptionsAndBody.d.cts +7 -7
- package/__cjs/link/index.cjs.map +1 -1
- package/__cjs/link/index.d.cts +2 -1
- package/__cjs/link/persisted-queries/index.cjs +16 -0
- package/__cjs/link/persisted-queries/index.cjs.map +1 -1
- package/__cjs/link/persisted-queries/index.d.cts +181 -0
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs +48 -0
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +115 -0
- package/__cjs/link/retry/retryLink.cjs +25 -3
- package/__cjs/link/retry/retryLink.cjs.map +1 -1
- package/__cjs/link/retry/retryLink.d.cts +82 -9
- package/__cjs/link/schema/index.cjs +20 -0
- package/__cjs/link/schema/index.cjs.map +1 -1
- package/__cjs/link/schema/index.d.cts +128 -6
- package/__cjs/link/ws/index.cjs +18 -0
- package/__cjs/link/ws/index.cjs.map +1 -1
- package/__cjs/link/ws/index.d.cts +56 -5
- package/__cjs/local-state/LocalState.cjs.map +1 -1
- package/__cjs/masking/GraphQLCodegenDataMasking.d.cts +10 -42
- package/__cjs/masking/PreserveTypes.cjs +3 -0
- package/__cjs/masking/PreserveTypes.cjs.map +1 -0
- package/__cjs/masking/PreserveTypes.d.cts +26 -0
- package/__cjs/masking/index.cjs.map +1 -1
- package/__cjs/masking/index.d.cts +1 -1
- package/__cjs/masking/internal/types.d.cts +0 -1
- package/__cjs/masking/types.d.cts +6 -23
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +2 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +1 -1
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +2 -1
- package/__cjs/react/hooks/useQuery.d.cts +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.d.cts +2 -1
- package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useReadQuery.d.cts +1 -1
- package/__cjs/react/hooks/useSyncExternalStore.cjs +2 -6
- package/__cjs/react/hooks/useSyncExternalStore.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.d.cts +1 -1
- package/__cjs/react/types/deprecated.d.cts +1 -1
- package/__cjs/react/types/types.documentation.d.cts +1 -1
- package/__cjs/testing/core/mocking/mockSubscriptionLink.d.cts +1 -1
- package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
- package/__cjs/testing/react/MockedProvider.d.cts +5 -0
- package/__cjs/utilities/common/stripTypename.cjs +11 -0
- package/__cjs/utilities/common/stripTypename.cjs.map +1 -1
- package/__cjs/utilities/common/stripTypename.d.cts +11 -0
- package/__cjs/utilities/graphql/DocumentTransform.cjs +84 -1
- package/__cjs/utilities/graphql/DocumentTransform.cjs.map +1 -1
- package/__cjs/utilities/graphql/DocumentTransform.d.cts +94 -5
- package/__cjs/utilities/graphql/isFormattedExecutionResult.cjs +27 -0
- package/__cjs/utilities/graphql/isFormattedExecutionResult.cjs.map +1 -1
- package/__cjs/utilities/graphql/isFormattedExecutionResult.d.cts +27 -0
- package/__cjs/utilities/graphql/operations.cjs +54 -3
- package/__cjs/utilities/graphql/operations.cjs.map +1 -1
- package/__cjs/utilities/graphql/operations.d.cts +54 -3
- package/__cjs/utilities/graphql/storeUtils.cjs +9 -0
- package/__cjs/utilities/graphql/storeUtils.cjs.map +1 -1
- package/__cjs/utilities/graphql/storeUtils.d.cts +9 -0
- package/__cjs/utilities/graphql/transform.cjs +12 -1
- package/__cjs/utilities/graphql/transform.cjs.map +1 -1
- package/__cjs/utilities/graphql/transform.d.cts +12 -1
- package/__cjs/utilities/internal/canonicalStringify.cjs +30 -7
- package/__cjs/utilities/internal/canonicalStringify.cjs.map +1 -1
- package/__cjs/utilities/internal/canonicalStringify.d.cts +30 -7
- package/__cjs/utilities/internal/getMainDefinition.cjs +36 -8
- package/__cjs/utilities/internal/getMainDefinition.cjs.map +1 -1
- package/__cjs/utilities/internal/getMainDefinition.d.cts +36 -8
- package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs +2 -6
- package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs.map +1 -1
- package/__cjs/utilities/internal/types/DocumentationTypes.d.cts +1 -1
- package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
- package/__cjs/v4-migration.cjs +9 -0
- package/__cjs/v4-migration.cjs.map +1 -0
- package/__cjs/v4-migration.d.cts +826 -0
- package/__cjs/version.cjs +1 -1
- package/__cjs/version.cjs.map +1 -1
- package/cache/inmemory/inMemoryCache.js +2 -2
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/policies.js +18 -12
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/writeToStore.js +1 -1
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ObservableQuery.d.ts +1 -1
- package/core/ObservableQuery.js +1 -1
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.js +1 -2
- package/core/QueryInfo.js.map +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js.map +1 -1
- package/incremental/handlers/defer20220824.d.ts +9 -6
- package/incremental/handlers/defer20220824.js.map +1 -1
- package/incremental/handlers/notImplemented.d.ts +11 -0
- package/incremental/handlers/notImplemented.js.map +1 -1
- package/legacyEntryPoints/v4-migration/index.d.ts +1 -0
- package/legacyEntryPoints/v4-migration/index.js +1 -0
- package/legacyEntryPoints/v4-migration/v4-migration.cjs +1 -0
- package/legacyEntryPoints/v4-migration/v4-migration.d.cts +1 -0
- package/link/batch/batchLink.d.ts +69 -2
- package/link/batch/batchLink.js +30 -2
- package/link/batch/batchLink.js.map +1 -1
- package/link/batch-http/BaseBatchHttpLink.d.ts +68 -0
- package/link/batch-http/BaseBatchHttpLink.js +152 -0
- package/link/batch-http/BaseBatchHttpLink.js.map +1 -0
- package/link/batch-http/batchHttpLink.d.ts +5 -21
- package/link/batch-http/batchHttpLink.js +1 -125
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/batch-http/index.d.ts +2 -1
- package/link/batch-http/index.js +2 -1
- package/link/batch-http/index.js.map +1 -1
- package/link/client-awareness/ClientAwarenessLink.d.ts +21 -2
- package/link/client-awareness/ClientAwarenessLink.js +3 -3
- package/link/client-awareness/ClientAwarenessLink.js.map +1 -1
- package/link/context/index.d.ts +65 -3
- package/link/context/index.js +19 -0
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.d.ts +5 -2
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/types.d.ts +0 -4
- package/link/core/types.js.map +1 -1
- package/link/http/BaseHttpLink.d.ts +257 -3
- package/link/http/BaseHttpLink.js +59 -8
- package/link/http/BaseHttpLink.js.map +1 -1
- package/link/http/HttpLink.d.ts +6 -209
- package/link/http/HttpLink.js +1 -1
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/rewriteURIForGET.d.ts +2 -2
- package/link/http/rewriteURIForGET.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +7 -7
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/index.d.ts +2 -1
- package/link/index.js.map +1 -1
- package/link/persisted-queries/index.d.ts +182 -1
- package/link/persisted-queries/index.js +16 -0
- package/link/persisted-queries/index.js.map +1 -1
- package/link/remove-typename/removeTypenameFromVariables.d.ts +115 -0
- package/link/remove-typename/removeTypenameFromVariables.js +48 -0
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/retry/retryLink.d.ts +83 -10
- package/link/retry/retryLink.js +25 -3
- package/link/retry/retryLink.js.map +1 -1
- package/link/schema/index.d.ts +129 -7
- package/link/schema/index.js +20 -0
- package/link/schema/index.js.map +1 -1
- package/link/ws/index.d.ts +56 -5
- package/link/ws/index.js +18 -0
- package/link/ws/index.js.map +1 -1
- package/local-state/LocalState.js.map +1 -1
- package/masking/GraphQLCodegenDataMasking.d.ts +10 -42
- package/masking/GraphQLCodegenDataMasking.js.map +1 -1
- package/masking/PreserveTypes.d.ts +26 -0
- package/masking/PreserveTypes.js +2 -0
- package/masking/PreserveTypes.js.map +1 -0
- package/masking/index.d.ts +1 -1
- package/masking/index.js.map +1 -1
- package/masking/internal/types.d.ts +0 -1
- package/masking/internal/types.js.map +1 -1
- package/masking/types.d.ts +6 -23
- package/masking/types.js.map +1 -1
- package/package.json +8 -2
- package/react/hooks/useBackgroundQuery.d.ts +2 -1
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +1 -1
- package/react/hooks/useLoadableQuery.d.ts +2 -1
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useQuery.d.ts +1 -1
- package/react/hooks/useQueryRefHandlers.d.ts +2 -1
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +1 -1
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/hooks/useSyncExternalStore.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +2 -1
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +1 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +2 -1
- package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +1 -1
- package/react/hooks-compiled/useQueryRefHandlers.d.ts +2 -1
- package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
- package/react/hooks-compiled/useReadQuery.d.ts +1 -1
- package/react/hooks-compiled/useReadQuery.js.map +1 -1
- package/react/hooks-compiled/useSyncExternalStore.js +1 -1
- package/react/hooks-compiled/useSyncExternalStore.js.map +1 -1
- package/react/query-preloader/createQueryPreloader.d.ts +1 -1
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/types/deprecated.d.ts +1 -1
- package/react/types/deprecated.js.map +1 -1
- package/react/types/types.documentation.d.ts +1 -1
- package/react/types/types.documentation.js.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
- package/testing/react/MockedProvider.d.ts +5 -0
- package/testing/react/MockedProvider.js.map +1 -1
- package/utilities/common/stripTypename.d.ts +11 -0
- package/utilities/common/stripTypename.js +11 -0
- package/utilities/common/stripTypename.js.map +1 -1
- package/utilities/graphql/DocumentTransform.d.ts +94 -5
- package/utilities/graphql/DocumentTransform.js +84 -1
- package/utilities/graphql/DocumentTransform.js.map +1 -1
- package/utilities/graphql/isFormattedExecutionResult.d.ts +27 -0
- package/utilities/graphql/isFormattedExecutionResult.js +27 -0
- package/utilities/graphql/isFormattedExecutionResult.js.map +1 -1
- package/utilities/graphql/operations.d.ts +54 -3
- package/utilities/graphql/operations.js +54 -3
- package/utilities/graphql/operations.js.map +1 -1
- package/utilities/graphql/storeUtils.d.ts +9 -0
- package/utilities/graphql/storeUtils.js +9 -0
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.d.ts +12 -1
- package/utilities/graphql/transform.js +12 -1
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/internal/canonicalStringify.d.ts +30 -7
- package/utilities/internal/canonicalStringify.js +30 -7
- package/utilities/internal/canonicalStringify.js.map +1 -1
- package/utilities/internal/getMainDefinition.d.ts +37 -9
- package/utilities/internal/getMainDefinition.js +36 -8
- package/utilities/internal/getMainDefinition.js.map +1 -1
- package/utilities/internal/removeDirectivesFromDocument.js +1 -2
- package/utilities/internal/removeDirectivesFromDocument.js.map +1 -1
- package/utilities/internal/types/DocumentationTypes.d.ts +1 -1
- package/utilities/subscriptions/relay/index.js.map +1 -1
- package/v4-migration.d.ts +826 -0
- package/v4-migration.js +8 -0
- package/v4-migration.js.map +1 -0
- package/version.js +1 -1
- package/version.js.map +1 -1
package/link/http/HttpLink.js
CHANGED
|
@@ -37,5 +37,5 @@ export class HttpLink extends ApolloLink {
|
|
|
37
37
|
* @deprecated
|
|
38
38
|
* Use `HttpLink` from `@apollo/client/link/http` instead.
|
|
39
39
|
*/
|
|
40
|
-
export const createHttpLink = (
|
|
40
|
+
export const createHttpLink = (options = {}) => new HttpLink(options);
|
|
41
41
|
//# sourceMappingURL=HttpLink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpLink.js","sourceRoot":"","sources":["../../../src/link/http/HttpLink.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HttpLink.js","sourceRoot":"","sources":["../../../src/link/http/HttpLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA4BjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,QAAS,SAAQ,UAAU;IACtC,YAAY,UAA4B,EAAE;QACxC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC;YAC/C,IAAI,mBAAmB,CAAC,OAAO,CAAC;YAChC,IAAI,YAAY,CAAC,OAAO,CAAC;SAC1B,CAAC,CAAC;QACH,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACvC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,UAA4B,EAAE,EAAE,EAAE,CAC/D,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC","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` from `@apollo/client/link/http` instead.\n */\nexport const createHttpLink = (options: HttpLink.Options = {}) =>\n new HttpLink(options);\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function rewriteURIForGET(chosenURI: string, body:
|
|
1
|
+
import type { BaseHttpLink } from "./BaseHttpLink.js";
|
|
2
|
+
export declare function rewriteURIForGET(chosenURI: string, body: BaseHttpLink.Body): {
|
|
3
3
|
parseError: unknown;
|
|
4
4
|
newURI?: undefined;
|
|
5
5
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewriteURIForGET.js","sourceRoot":"","sources":["../../../src/link/http/rewriteURIForGET.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,eAAe;AACf,MAAM,UAAU,gBAAgB,CAAC,SAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"rewriteURIForGET.js","sourceRoot":"","sources":["../../../src/link/http/rewriteURIForGET.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,eAAe;AACf,MAAM,UAAU,gBAAgB,CAAC,SAAiB,EAAE,IAAuB;IACzE,yEAAyE;IACzE,yCAAyC;IACzC,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,EAAE;QACnD,WAAW,CAA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S,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QAC3C,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;IACnD,CAAC;IACD,MAAM,iBAAiB,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IACtE,MAAM,MAAM,GACV,WAAW,GAAG,iBAAiB,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;IACrE,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC","sourcesContent":["import type { BaseHttpLink } from \"./BaseHttpLink.js\";\n\n// For GET operations, returns the given URI rewritten with parameters, or a\n// parse error.\nexport function rewriteURIForGET(chosenURI: string, body: BaseHttpLink.Body) {\n // Implement the standard HTTP GET serialization, plus 'extensions'. Note\n // the extra level of JSON serialization!\n const queryParams: string[] = [];\n const addQueryParam = (key: string, value: string) => {\n queryParams.push(`${key}=${encodeURIComponent(value)}`);\n };\n\n if (\"query\" in body) {\n addQueryParam(\"query\", body.query!);\n }\n if (body.operationName) {\n addQueryParam(\"operationName\", body.operationName);\n }\n if (body.variables) {\n let serializedVariables;\n try {\n serializedVariables = JSON.stringify(body.variables);\n } catch (parseError) {\n return { parseError };\n }\n addQueryParam(\"variables\", serializedVariables);\n }\n if (body.extensions) {\n let serializedExtensions;\n try {\n serializedExtensions = JSON.stringify(body.extensions);\n } catch (parseError) {\n return { parseError };\n }\n addQueryParam(\"extensions\", serializedExtensions);\n }\n\n // Reconstruct the URI with added query params.\n // XXX This assumes that the URI is well-formed and that it doesn't\n // already contain any of these query params. We could instead use the\n // URL API and take a polyfill (whatwg-url@6) for older browsers that\n // don't support URLSearchParams. Note that some browsers (and\n // versions of whatwg-url) support URL but not URLSearchParams!\n let fragment = \"\",\n preFragment = chosenURI;\n const fragmentStart = chosenURI.indexOf(\"#\");\n if (fragmentStart !== -1) {\n fragment = chosenURI.substr(fragmentStart);\n preFragment = chosenURI.substr(0, fragmentStart);\n }\n const queryParamsPrefix = preFragment.indexOf(\"?\") === -1 ? \"?\" : \"&\";\n const newURI =\n preFragment + queryParamsPrefix + queryParams.join(\"&\") + fragment;\n return { newURI };\n}\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { ApolloLink } from "@apollo/client/link";
|
|
2
|
-
import type {
|
|
2
|
+
import type { BaseHttpLink } from "./BaseHttpLink.js";
|
|
3
3
|
interface HttpConfig {
|
|
4
|
-
http?:
|
|
4
|
+
http?: BaseHttpLink.HttpOptions;
|
|
5
5
|
options?: any;
|
|
6
6
|
headers?: Record<string, string>;
|
|
7
7
|
credentials?: any;
|
|
8
8
|
}
|
|
9
9
|
export declare const fallbackHttpConfig: {
|
|
10
|
-
http:
|
|
10
|
+
http: BaseHttpLink.HttpOptions;
|
|
11
11
|
headers: {
|
|
12
12
|
accept: string;
|
|
13
13
|
"content-type": string;
|
|
@@ -16,14 +16,14 @@ export declare const fallbackHttpConfig: {
|
|
|
16
16
|
method: string;
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
-
export declare const defaultPrinter:
|
|
19
|
+
export declare const defaultPrinter: BaseHttpLink.Printer;
|
|
20
20
|
export declare function selectHttpOptionsAndBody(operation: ApolloLink.Operation, fallbackConfig: HttpConfig, ...configs: Array<HttpConfig>): {
|
|
21
21
|
options: HttpConfig & Record<string, any>;
|
|
22
|
-
body:
|
|
22
|
+
body: BaseHttpLink.Body;
|
|
23
23
|
};
|
|
24
|
-
export declare function selectHttpOptionsAndBodyInternal(operation: ApolloLink.Operation, printer:
|
|
24
|
+
export declare function selectHttpOptionsAndBodyInternal(operation: ApolloLink.Operation, printer: BaseHttpLink.Printer, ...configs: HttpConfig[]): {
|
|
25
25
|
options: HttpConfig & Record<string, any>;
|
|
26
|
-
body:
|
|
26
|
+
body: BaseHttpLink.Body;
|
|
27
27
|
};
|
|
28
28
|
export {};
|
|
29
29
|
//# sourceMappingURL=selectHttpOptionsAndBody.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectHttpOptionsAndBody.js","sourceRoot":"","sources":["../../../src/link/http/selectHttpOptionsAndBody.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAWjD,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"selectHttpOptionsAndBody.js","sourceRoot":"","sources":["../../../src/link/http/selectHttpOptionsAndBody.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAWjD,MAAM,kBAAkB,GAA6B;IACnD,YAAY,EAAE,IAAI;IAClB,iBAAiB,EAAE,IAAI;IACvB,kBAAkB,EAAE,KAAK;CAC1B,CAAC;AAEF,MAAM,cAAc,GAAG;IACrB,qEAAqE;IACrE,MAAM,EAAE,0DAA0D;IAClE,6EAA6E;IAC7E,4EAA4E;IAC5E,8EAA8E;IAC9E,6EAA6E;IAC7E,2EAA2E;IAC3E,wEAAwE;IACxE,4EAA4E;IAC5E,6EAA6E;IAC7E,2EAA2E;IAC3E,iEAAiE;IACjE,6GAA6G;IAC7G,oBAAoB;IACpB,cAAc,EAAE,kBAAkB;CACnC,CAAC;AAEF,MAAM,cAAc,GAAG;IACrB,MAAM,EAAE,MAAM;CACf,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,cAAc;CACxB,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAyB,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CACnE,OAAO,CAAC,GAAG,CAAC,CAAC;AAEf,MAAM,UAAU,wBAAwB,CACtC,SAA+B,EAC/B,cAA0B,EAC1B,GAAG,OAA0B;IAE7B,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC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AC,CAAC,CAAC;IACH,OAAO,iBAAiB,CAAC;AAC3B,CAAC","sourcesContent":["import type { ApolloLink } from \"@apollo/client/link\";\nimport { print } from \"@apollo/client/utilities\";\n\nimport type { BaseHttpLink } from \"./BaseHttpLink.js\";\n\ninterface HttpConfig {\n http?: BaseHttpLink.HttpOptions;\n options?: any;\n headers?: Record<string, string>;\n credentials?: any;\n}\n\nconst defaultHttpOptions: BaseHttpLink.HttpOptions = {\n includeQuery: true,\n includeExtensions: true,\n preserveHeaderCase: false,\n};\n\nconst defaultHeaders = {\n // headers are case insensitive (https://stackoverflow.com/a/5259004)\n accept: \"application/graphql-response+json,application/json;q=0.9\",\n // The content-type header describes the type of the body of the request, and\n // so it typically only is sent with requests that actually have bodies. One\n // could imagine that Apollo Client would remove this header when constructing\n // a GET request (which has no body), but we historically have not done that.\n // This means that browsers will preflight all Apollo Client requests (even\n // GET requests). Apollo Server's CSRF prevention feature (introduced in\n // AS3.7) takes advantage of this fact and does not block requests with this\n // header. If you want to drop this header from GET requests, then you should\n // probably replace it with a `apollo-require-preflight` header, or servers\n // with CSRF prevention enabled might block your GET request. See\n // https://www.apollographql.com/docs/apollo-server/security/cors/#preventing-cross-site-request-forgery-csrf\n // for more details.\n \"content-type\": \"application/json\",\n};\n\nconst defaultOptions = {\n method: \"POST\",\n};\n\nexport const fallbackHttpConfig = {\n http: defaultHttpOptions,\n headers: defaultHeaders,\n options: defaultOptions,\n};\n\nexport const defaultPrinter: BaseHttpLink.Printer = (ast, printer) =>\n printer(ast);\n\nexport function selectHttpOptionsAndBody(\n operation: ApolloLink.Operation,\n fallbackConfig: HttpConfig,\n ...configs: Array<HttpConfig>\n) {\n configs.unshift(fallbackConfig);\n return selectHttpOptionsAndBodyInternal(\n operation,\n defaultPrinter,\n ...configs\n );\n}\n\nexport function selectHttpOptionsAndBodyInternal(\n operation: ApolloLink.Operation,\n printer: BaseHttpLink.Printer,\n ...configs: HttpConfig[]\n) {\n let options = {} as HttpConfig & Record<string, any>;\n let http = {} as BaseHttpLink.HttpOptions;\n\n configs.forEach((config) => {\n options = {\n ...options,\n ...config.options,\n headers: {\n ...options.headers,\n ...config.headers,\n },\n };\n\n if (config.credentials) {\n options.credentials = config.credentials;\n }\n\n options.headers!.accept = (config.http?.accept || [])\n .concat(options.headers!.accept)\n .join(\",\");\n\n http = {\n ...http,\n ...config.http,\n };\n });\n\n options.headers = removeDuplicateHeaders(\n options.headers!,\n http.preserveHeaderCase\n );\n\n //The body depends on the http options\n const { operationName, extensions, variables, query } = operation;\n const body: BaseHttpLink.Body = { operationName, variables };\n\n if (http.includeExtensions && Object.keys(extensions || {}).length)\n (body as any).extensions = extensions;\n\n // not sending the query (i.e persisted queries)\n if (http.includeQuery) (body as any).query = printer(query, print);\n\n return {\n options,\n body,\n };\n}\n\n// Remove potential duplicate header names, preserving last (by insertion order).\n// This is done to prevent unintentionally duplicating a header instead of\n// overwriting it (See #8447 and #8449).\nfunction removeDuplicateHeaders(\n headers: Record<string, string>,\n preserveHeaderCase: boolean | undefined\n): typeof headers {\n // If we're not preserving the case, just remove duplicates w/ normalization.\n if (!preserveHeaderCase) {\n const normalizedHeaders: Record<string, string> = {};\n Object.keys(Object(headers)).forEach((name) => {\n normalizedHeaders[name.toLowerCase()] = headers[name];\n });\n return normalizedHeaders;\n }\n\n // If we are preserving the case, remove duplicates w/ normalization,\n // preserving the original name.\n // This allows for non-http-spec-compliant servers that expect intentionally\n // capitalized header names (See #6741).\n const headerData: Record<string, { originalName: string; value: string }> =\n {};\n Object.keys(Object(headers)).forEach((name) => {\n headerData[name.toLowerCase()] = {\n originalName: name,\n value: headers[name],\n };\n });\n\n const normalizedHeaders: Record<string, string> = {};\n Object.keys(headerData).forEach((name) => {\n normalizedHeaders[headerData[name].originalName] = headerData[name].value;\n });\n return normalizedHeaders;\n}\n"]}
|
package/link/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
export type { DocumentNode } from "graphql";
|
|
1
2
|
export { empty } from "./core/empty.js";
|
|
2
3
|
export { from } from "./core/from.js";
|
|
3
4
|
export { split } from "./core/split.js";
|
|
4
5
|
export { concat } from "./core/concat.js";
|
|
5
6
|
export { execute } from "./core/execute.js";
|
|
6
7
|
export { ApolloLink } from "./core/ApolloLink.js";
|
|
7
|
-
export type {
|
|
8
|
+
export type { ApolloPayloadResult } from "./core/types.js";
|
|
8
9
|
export type { FetchResult, GraphQLRequest, Operation, RequestHandler, } from "./core/deprecated.js";
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
package/link/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/link/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/link/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export type { DocumentNode } from \"graphql\";\n\nexport { empty } from \"./core/empty.js\";\nexport { from } from \"./core/from.js\";\nexport { split } from \"./core/split.js\";\nexport { concat } from \"./core/concat.js\";\nexport { execute } from \"./core/execute.js\";\nexport { ApolloLink } from \"./core/ApolloLink.js\";\n\nexport type { ApolloPayloadResult } from \"./core/types.js\";\n\nexport type {\n FetchResult,\n GraphQLRequest,\n Operation,\n RequestHandler,\n} from \"./core/deprecated.js\";\n"]}
|
|
@@ -3,34 +3,199 @@ import type { ErrorLike } from "@apollo/client";
|
|
|
3
3
|
import { ApolloLink } from "@apollo/client/link";
|
|
4
4
|
export declare const VERSION = 1;
|
|
5
5
|
export declare namespace PersistedQueryLink {
|
|
6
|
+
namespace PersistedQueryLinkDocumentationTypes {
|
|
7
|
+
/**
|
|
8
|
+
* A SHA-256 hash function for hashing query strings.
|
|
9
|
+
*
|
|
10
|
+
* @param queryString - The query string to hash
|
|
11
|
+
* @returns The SHA-256 hash or a promise that resolves to the SHA-256 hash
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { sha256 } from "crypto-hash";
|
|
17
|
+
*
|
|
18
|
+
* const link = new PersistedQueryLink({ sha256 });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function SHA256Function(queryString: string): string | PromiseLike<string>;
|
|
22
|
+
/**
|
|
23
|
+
* A function that generates a hash for a GraphQL document.
|
|
24
|
+
*
|
|
25
|
+
* @param document - The GraphQL document to hash
|
|
26
|
+
* @returns The hash string or a promise that resolves to the hash string
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { print } from "graphql";
|
|
32
|
+
* import { sha256 } from "crypto-hash";
|
|
33
|
+
*
|
|
34
|
+
* const link = new PersistedQueryLink({
|
|
35
|
+
* generateHash: async (document) => {
|
|
36
|
+
* const query = print(document);
|
|
37
|
+
* return sha256(query);
|
|
38
|
+
* },
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
function GenerateHashFunction(document: DocumentNode): string | PromiseLike<string>;
|
|
43
|
+
}
|
|
6
44
|
namespace Base {
|
|
45
|
+
/**
|
|
46
|
+
* Base options shared between SHA256 and custom hash configurations.
|
|
47
|
+
*/
|
|
7
48
|
interface Options {
|
|
49
|
+
/**
|
|
50
|
+
* A function to disable persisted queries for the current session.
|
|
51
|
+
*
|
|
52
|
+
* This function is called when an error occurs and determines whether
|
|
53
|
+
* to disable persisted queries for all future requests in this session.
|
|
54
|
+
*
|
|
55
|
+
* @defaultValue Disables on `PersistedQueryNotSupported` errors
|
|
56
|
+
*/
|
|
8
57
|
disable?: (options: PersistedQueryLink.DisableFunctionOptions) => boolean;
|
|
58
|
+
/**
|
|
59
|
+
* A function to determine whether to retry a request with the full query.
|
|
60
|
+
*
|
|
61
|
+
* When a persisted query fails, this function determines whether to
|
|
62
|
+
* retry the request with the full query text included.
|
|
63
|
+
*
|
|
64
|
+
* @defaultValue Retries on `PersistedQueryNotSupported` or `PersistedQueryNotFound` errors
|
|
65
|
+
*/
|
|
9
66
|
retry?: (options: PersistedQueryLink.RetryFunctionOptions) => boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Whether to use HTTP GET for hashed queries (excluding mutations).
|
|
69
|
+
*
|
|
70
|
+
* > [!NOTE]
|
|
71
|
+
* > If you want to use `GET` for non-mutation queries whether or not they
|
|
72
|
+
* > are hashed, pass `useGETForQueries: true` option to `HttpLink`
|
|
73
|
+
* > instead. If you want to use GET for all requests, pass `fetchOptions: {method: 'GET'}`
|
|
74
|
+
* > to `HttpLink`.
|
|
75
|
+
*
|
|
76
|
+
* @defaultValue `false`
|
|
77
|
+
*/
|
|
10
78
|
useGETForHashedQueries?: boolean;
|
|
11
79
|
}
|
|
12
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Metadata about persisted query errors extracted from the response.
|
|
83
|
+
*/
|
|
13
84
|
interface ErrorMeta {
|
|
85
|
+
/**
|
|
86
|
+
* Whether the server responded with a "PersistedQueryNotSupported" error.
|
|
87
|
+
*
|
|
88
|
+
* When `true`, indicates the server doesn't support persisted queries
|
|
89
|
+
* or has disabled them for this client.
|
|
90
|
+
*/
|
|
14
91
|
persistedQueryNotSupported: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Whether the server responded with a "PersistedQueryNotFound" error.
|
|
94
|
+
*
|
|
95
|
+
* When `true`, indicates the server doesn't recognize the query hash
|
|
96
|
+
* and needs the full query text.
|
|
97
|
+
*/
|
|
15
98
|
persistedQueryNotFound: boolean;
|
|
16
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* A function that generates a hash for a GraphQL document.
|
|
102
|
+
*
|
|
103
|
+
* @param document - The GraphQL document to hash
|
|
104
|
+
* @returns The hash string or a promise that resolves to the hash string
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
*
|
|
108
|
+
* ```ts
|
|
109
|
+
* import { print } from "graphql";
|
|
110
|
+
* import { sha256 } from "crypto-hash";
|
|
111
|
+
*
|
|
112
|
+
* const link = new PersistedQueryLink({
|
|
113
|
+
* generateHash: async (document) => {
|
|
114
|
+
* const query = print(document);
|
|
115
|
+
* return sha256(query);
|
|
116
|
+
* },
|
|
117
|
+
* });
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
17
120
|
type GenerateHashFunction = (document: DocumentNode) => string | PromiseLike<string>;
|
|
121
|
+
/**
|
|
122
|
+
* A SHA-256 hash function for hashing query strings.
|
|
123
|
+
*
|
|
124
|
+
* @param queryString - The query string to hash
|
|
125
|
+
* @returns The SHA-256 hash or a promise that resolves to the SHA-256 hash
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
*
|
|
129
|
+
* ```ts
|
|
130
|
+
* import { sha256 } from "crypto-hash";
|
|
131
|
+
*
|
|
132
|
+
* const link = new PersistedQueryLink({ sha256 });
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
18
135
|
type SHA256Function = (queryString: string) => string | PromiseLike<string>;
|
|
136
|
+
/**
|
|
137
|
+
* Options for using SHA-256 hashing with persisted queries.
|
|
138
|
+
*
|
|
139
|
+
* Use this configuration when you want the link to handle query
|
|
140
|
+
* printing and hashing using a SHA-256 function.
|
|
141
|
+
*/
|
|
19
142
|
interface SHA256Options extends Base.Options {
|
|
143
|
+
/**
|
|
144
|
+
* The SHA-256 hash function to use for hashing queries. This function
|
|
145
|
+
* receives the printed query string and should return a SHA-256 hash. Can
|
|
146
|
+
* be synchronous or asynchronous.
|
|
147
|
+
*/
|
|
20
148
|
sha256: PersistedQueryLink.SHA256Function;
|
|
21
149
|
generateHash?: never;
|
|
22
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Options for using custom hash generation with persisted queries.
|
|
153
|
+
*
|
|
154
|
+
* Use this configuration when you need custom control over how
|
|
155
|
+
* query hashes are generated (e.g., using pre-computed hashes).
|
|
156
|
+
*/
|
|
23
157
|
interface GenerateHashOptions extends Base.Options {
|
|
24
158
|
sha256?: never;
|
|
159
|
+
/**
|
|
160
|
+
* A custom function for generating query hashes. This function receives
|
|
161
|
+
* the GraphQL document and should return a hash. Useful for custom hashing
|
|
162
|
+
* strategies or when using build-time generated hashes.
|
|
163
|
+
*/
|
|
25
164
|
generateHash: PersistedQueryLink.GenerateHashFunction;
|
|
26
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Configuration options for creating a `PersistedQueryLink`.
|
|
168
|
+
*
|
|
169
|
+
* You must provide either a `sha256` function or a custom `generateHash`
|
|
170
|
+
* function, but not both.
|
|
171
|
+
*/
|
|
27
172
|
type Options = PersistedQueryLink.SHA256Options | PersistedQueryLink.GenerateHashOptions;
|
|
173
|
+
/**
|
|
174
|
+
* Options passed to the `retry` function when a persisted query request
|
|
175
|
+
* fails.
|
|
176
|
+
*/
|
|
28
177
|
interface RetryFunctionOptions {
|
|
178
|
+
/**
|
|
179
|
+
* The error that occurred during the request.
|
|
180
|
+
*/
|
|
29
181
|
error: ErrorLike;
|
|
182
|
+
/**
|
|
183
|
+
* The GraphQL operation that failed.
|
|
184
|
+
*/
|
|
30
185
|
operation: ApolloLink.Operation;
|
|
186
|
+
/**
|
|
187
|
+
* Metadata about the persisted query error.
|
|
188
|
+
*/
|
|
31
189
|
meta: PersistedQueryLink.ErrorMeta;
|
|
190
|
+
/**
|
|
191
|
+
* The GraphQL result, if available.
|
|
192
|
+
*/
|
|
32
193
|
result?: FormattedExecutionResult;
|
|
33
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Options passed to the `disable` function when a persisted query request
|
|
197
|
+
* fails.
|
|
198
|
+
*/
|
|
34
199
|
interface DisableFunctionOptions extends PersistedQueryLink.RetryFunctionOptions {
|
|
35
200
|
}
|
|
36
201
|
}
|
|
@@ -39,8 +204,24 @@ export declare namespace PersistedQueryLink {
|
|
|
39
204
|
* Use `PersistedQueryLink` from `@apollo/client/link/persisted-queries` instead.
|
|
40
205
|
*/
|
|
41
206
|
export declare const createPersistedQueryLink: (options: PersistedQueryLink.Options) => PersistedQueryLink;
|
|
207
|
+
/**
|
|
208
|
+
* `PersistedQueryLink` is a non-terminating link that enables the use of
|
|
209
|
+
* persisted queries, a technique that reduces bandwidth by sending query hashes
|
|
210
|
+
* instead of full query strings.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
*
|
|
214
|
+
* ```ts
|
|
215
|
+
* import { PersistedQueryLink } from "@apollo/client/link/persisted-queries";
|
|
216
|
+
* import { sha256 } from "crypto-hash";
|
|
217
|
+
*
|
|
218
|
+
* const link = new PersistedQueryLink({
|
|
219
|
+
* sha256: (queryString) => sha256(queryString),
|
|
220
|
+
* });
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
42
223
|
export declare class PersistedQueryLink extends ApolloLink {
|
|
43
224
|
constructor(options: PersistedQueryLink.Options);
|
|
44
225
|
resetHashCache: () => void;
|
|
45
226
|
}
|
|
46
|
-
//# sourceMappingURL=index.d.ts.map
|
|
227
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -35,6 +35,22 @@ function operationDefinesMutation(operation) {
|
|
|
35
35
|
* Use `PersistedQueryLink` from `@apollo/client/link/persisted-queries` instead.
|
|
36
36
|
*/
|
|
37
37
|
export const createPersistedQueryLink = (options) => new PersistedQueryLink(options);
|
|
38
|
+
/**
|
|
39
|
+
* `PersistedQueryLink` is a non-terminating link that enables the use of
|
|
40
|
+
* persisted queries, a technique that reduces bandwidth by sending query hashes
|
|
41
|
+
* instead of full query strings.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* import { PersistedQueryLink } from "@apollo/client/link/persisted-queries";
|
|
47
|
+
* import { sha256 } from "crypto-hash";
|
|
48
|
+
*
|
|
49
|
+
* const link = new PersistedQueryLink({
|
|
50
|
+
* sha256: (queryString) => sha256(queryString),
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
38
54
|
export class PersistedQueryLink extends ApolloLink {
|
|
39
55
|
constructor(options) {
|
|
40
56
|
let hashesByQuery;
|