@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryLink.js","sourceRoot":"","sources":["../../../src/link/retry/retryLink.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGlC,OAAO,EACL,8BAA8B,EAC9B,sBAAsB,EACtB,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAuFxD;;GAEG;AACH,MAAM,kBAAkB;IAMZ;IACA;IACA;IACA;IACA;IATF,UAAU,GAAW,CAAC,CAAC;IACvB,mBAAmB,GAAwB,IAAI,CAAC;IAChD,OAAO,CAA4C;IAE3D,YACU,QAAqC,EACrC,SAA+B,EAC/B,OAAmC,EACnC,QAAiC,EACjC,OAAmC;QAJnC,aAAQ,GAAR,QAA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AAC,OAAO;YACV,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC7E,CAAC;IAEM,OAAO,CACZ,SAA+B,EAC/B,OAAmC;QAEnC,OAAO,IAAI,UAAU,CAAC,CAAC,QAAQ,EAAE,EAAE;YACjC,MAAM,SAAS,GAAG,IAAI,kBAAkB,CACtC,QAAQ,EACR,SAAS,EACT,OAAO,EACP,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,OAAO,CACb,CAAC;YACF,OAAO,GAAG,EAAE;gBACV,SAAS,CAAC,MAAM,EAAE,CAAC;YACrB,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type { Subscription } from \"rxjs\";\nimport type { Observer } from \"rxjs\";\nimport { Observable } from \"rxjs\";\n\nimport type { ErrorLike } from \"@apollo/client\";\nimport {\n graphQLResultHasProtocolErrors,\n PROTOCOL_ERRORS_SYMBOL,\n toErrorLike,\n} from \"@apollo/client/errors\";\nimport { ApolloLink } from \"@apollo/client/link\";\n\nimport { buildDelayFunction } from \"./delayFunction.js\";\nimport { buildRetryFunction } from \"./retryFunction.js\";\n\nexport declare namespace RetryLink {\n export type DelayFunction = (\n count: number,\n operation: ApolloLink.Operation,\n error: ErrorLike\n ) => number;\n\n export interface DelayOptions {\n /**\n * The number of milliseconds to wait before attempting the first retry.\n *\n * Delays will increase exponentially for each attempt. E.g. if this is\n * set to 100, subsequent retries will be delayed by 200, 400, 800, etc,\n * until they reach maxDelay.\n *\n * Note that if jittering is enabled, this is the _average_ delay.\n *\n * @defaultValue `300`\n */\n initial?: number;\n\n /**\n * The maximum number of milliseconds that the link should wait for any\n * retry.\n *\n * @defaultValue `Infinity`\n */\n max?: number;\n\n /**\n * Whether delays between attempts should be randomized.\n *\n * This helps avoid thundering herd type situations by better distributing\n * load during major outages.\n *\n * @defaultValue `true`\n */\n jitter?: boolean;\n }\n\n export type AttemptsFunction = (\n count: number,\n operation: ApolloLink.Operation,\n error: ErrorLike\n ) => boolean | Promise<boolean>;\n\n export interface AttemptsOptions {\n /**\n * The max number of times to try a single operation before giving up. Pass\n * `Infinity` for infinite retries.\n *\n * Note that this INCLUDES the initial request as part of the count.\n * E.g. maxTries of 1 indicates no retrying should occur.\n *\n * @defaultValue `5`\n */\n max?: number;\n\n /**\n * Predicate function that determines whether a particular error should\n * trigger a retry.\n *\n * For example, you may want to not retry 4xx class HTTP errors.\n *\n * @defaultValue `() => true`\n */\n retryIf?: (\n error: ErrorLike,\n operation: ApolloLink.Operation\n ) => boolean | Promise<boolean>;\n }\n\n export interface Options {\n /**\n * Configuration for the delay strategy to use, or a custom delay strategy.\n */\n delay?: RetryLink.DelayOptions | RetryLink.DelayFunction;\n\n /**\n * Configuration for the retry strategy to use, or a custom retry strategy.\n */\n attempts?: RetryLink.AttemptsOptions | RetryLink.AttemptsFunction;\n }\n}\n\n/**\n * Tracking and management of operations that may be (or currently are) retried.\n */\nclass RetryableOperation {\n private retryCount: number = 0;\n private currentSubscription: Subscription | null = null;\n private timerId: ReturnType<typeof setTimeout> | undefined;\n\n constructor(\n private observer: Observer<ApolloLink.Result>,\n private operation: ApolloLink.Operation,\n private forward: ApolloLink.ForwardFunction,\n private delayFor: RetryLink.DelayFunction,\n private retryIf: RetryLink.AttemptsFunction\n ) {\n this.try();\n }\n\n /**\n * Stop retrying for the operation, and cancel any in-progress requests.\n */\n public cancel() {\n if (this.currentSubscription) {\n this.currentSubscription.unsubscribe();\n }\n clearTimeout(this.timerId);\n this.timerId = undefined;\n this.currentSubscription = null;\n }\n\n private try() {\n this.currentSubscription = this.forward(this.operation).subscribe({\n next: (result) => {\n if (graphQLResultHasProtocolErrors(result)) {\n this.onError(result.extensions[PROTOCOL_ERRORS_SYMBOL], () =>\n // Pretend like we never encountered this error and move the result\n // along for Apollo Client core to handle this error.\n this.observer.next(result)\n );\n // Unsubscribe from the current subscription to prevent the `complete`\n // handler to be called as a result of the stream closing.\n this.currentSubscription?.unsubscribe();\n return;\n }\n\n this.observer.next(result);\n },\n error: (error) => this.onError(error, () => this.observer.error(error)),\n complete: this.observer.complete.bind(this.observer),\n });\n }\n\n private onError = async (error: unknown, onContinue: () => void) => {\n this.retryCount += 1;\n const errorLike = toErrorLike(error);\n\n const shouldRetry = await this.retryIf(\n this.retryCount,\n this.operation,\n errorLike\n );\n if (shouldRetry) {\n this.scheduleRetry(\n this.delayFor(this.retryCount, this.operation, errorLike)\n );\n return;\n }\n\n onContinue();\n };\n\n private scheduleRetry(delay: number) {\n if (this.timerId) {\n throw new Error(`RetryLink BUG! Encountered overlapping retries`);\n }\n\n this.timerId = setTimeout(() => {\n this.timerId = undefined;\n this.try();\n }, delay);\n }\n}\n\nexport class RetryLink extends ApolloLink {\n private delayFor: RetryLink.DelayFunction;\n private retryIf: RetryLink.AttemptsFunction;\n\n constructor(options?: RetryLink.Options) {\n super();\n const { attempts, delay } = options || ({} as RetryLink.Options);\n this.delayFor =\n typeof delay === \"function\" ? delay : buildDelayFunction(delay);\n this.retryIf =\n typeof attempts === \"function\" ? attempts : buildRetryFunction(attempts);\n }\n\n public request(\n operation: ApolloLink.Operation,\n forward: ApolloLink.ForwardFunction\n ): Observable<ApolloLink.Result> {\n return new Observable((observer) => {\n const retryable = new RetryableOperation(\n observer,\n operation,\n forward,\n this.delayFor,\n this.retryIf\n );\n return () => {\n retryable.cancel();\n };\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"retryLink.js","sourceRoot":"","sources":["../../../src/link/retry/retryLink.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGlC,OAAO,EACL,8BAA8B,EAC9B,sBAAsB,EACtB,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC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O,SAAU,SAAQ,UAAU;IAC/B,QAAQ,CAA0B;IAClC,OAAO,CAA6B;IAE5C,YAAY,OAA2B;QACrC,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,OAAO,IAAK,EAAwB,CAAC;QACjE,IAAI,CAAC,QAAQ;YACX,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAClE,IAAI,CAAC,OAAO;YACV,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC7E,CAAC;IAEM,OAAO,CACZ,SAA+B,EAC/B,OAAmC;QAEnC,OAAO,IAAI,UAAU,CAAC,CAAC,QAAQ,EAAE,EAAE;YACjC,MAAM,SAAS,GAAG,IAAI,kBAAkB,CACtC,QAAQ,EACR,SAAS,EACT,OAAO,EACP,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,OAAO,CACb,CAAC;YACF,OAAO,GAAG,EAAE;gBACV,SAAS,CAAC,MAAM,EAAE,CAAC;YACrB,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type { Subscription } from \"rxjs\";\nimport type { Observer } from \"rxjs\";\nimport { Observable } from \"rxjs\";\n\nimport type { ErrorLike } from \"@apollo/client\";\nimport {\n graphQLResultHasProtocolErrors,\n PROTOCOL_ERRORS_SYMBOL,\n toErrorLike,\n} from \"@apollo/client/errors\";\nimport { ApolloLink } from \"@apollo/client/link\";\n\nimport { buildDelayFunction } from \"./delayFunction.js\";\nimport { buildRetryFunction } from \"./retryFunction.js\";\n\nexport declare namespace RetryLink {\n namespace RetryLinkDocumentationTypes {\n /**\n * A function used to determine whether to retry the current operation.\n *\n * @param attempt - The current attempt number\n * @param operation - The current `ApolloLink.Operation` for the request\n * @param error - The error that triggered the retry attempt\n * @returns A boolean to indicate whether to retry the current operation\n */\n function AttemptsFunction(\n attempt: number,\n operation: ApolloLink.Operation,\n error: ErrorLike\n ): boolean | Promise<boolean>;\n\n /**\n * A function used to determine the delay for a retry attempt.\n *\n * @param attempt - The current attempt number\n * @param operation - The current `ApolloLink.Operation` for the request\n * @param error - The error that triggered the retry attempt\n * @returns The delay in milliseconds before attempting the request again\n */\n function DelayFunction(\n attempt: number,\n operation: ApolloLink.Operation,\n error: ErrorLike\n ): number;\n }\n\n /** {@inheritDoc @apollo/client/link/retry!RetryLink.RetryLinkDocumentationTypes.DelayFunction:function(1)} */\n export type DelayFunction = (\n attempt: number,\n operation: ApolloLink.Operation,\n error: ErrorLike\n ) => number;\n\n /**\n * Configuration options for the standard retry delay strategy.\n */\n export interface DelayOptions {\n /**\n * The number of milliseconds to wait before attempting the first retry.\n *\n * Delays will increase exponentially for each attempt. E.g. if this is\n * set to 100, subsequent retries will be delayed by 200, 400, 800, etc,\n * until they reach the maximum delay.\n *\n * Note that if jittering is enabled, this is the average delay.\n *\n * @defaultValue `300`\n */\n initial?: number;\n\n /**\n * The maximum number of milliseconds that the link should wait for any\n * retry.\n *\n * @defaultValue `Infinity`\n */\n max?: number;\n\n /**\n * Whether delays between attempts should be randomized.\n *\n * This helps avoid [thundering herd](https://en.wikipedia.org/wiki/Thundering_herd_problem)\n * type situations by better distributing load during major outages. Without\n * these strategies, when your server comes back up it will be hit by all\n * of your clients at once, possibly causing it to go down again.\n *\n * @defaultValue `true`\n */\n jitter?: boolean;\n }\n\n /** {@inheritDoc @apollo/client/link/retry!RetryLink.RetryLinkDocumentationTypes.AttemptsFunction:function(1)} */\n export type AttemptsFunction = (\n attempt: number,\n operation: ApolloLink.Operation,\n error: ErrorLike\n ) => boolean | Promise<boolean>;\n\n /**\n * Configuration options for the standard retry attempt strategy.\n */\n export interface AttemptsOptions {\n /**\n * The max number of times to try a single operation before giving up.\n *\n * Note that this INCLUDES the initial request as part of the count.\n * E.g. `max` of 1 indicates no retrying should occur.\n *\n * Pass `Infinity` for infinite retries.\n *\n * @defaultValue `5`\n */\n max?: number;\n\n /**\n * Predicate function that determines whether a particular error should\n * trigger a retry.\n *\n * For example, you may want to not retry 4xx class HTTP errors.\n *\n * @defaultValue `() => true`\n */\n retryIf?: (\n error: ErrorLike,\n operation: ApolloLink.Operation\n ) => boolean | Promise<boolean>;\n }\n\n /**\n * Options provided to the `RetryLink` constructor.\n */\n export interface Options {\n /**\n * Configuration for the delay strategy to use, or a custom delay strategy.\n */\n delay?: RetryLink.DelayOptions | RetryLink.DelayFunction;\n\n /**\n * Configuration for the retry strategy to use, or a custom retry strategy.\n */\n attempts?: RetryLink.AttemptsOptions | RetryLink.AttemptsFunction;\n }\n}\n\nclass RetryableOperation {\n private retryCount: number = 0;\n private currentSubscription: Subscription | null = null;\n private timerId: ReturnType<typeof setTimeout> | undefined;\n\n constructor(\n private observer: Observer<ApolloLink.Result>,\n private operation: ApolloLink.Operation,\n private forward: ApolloLink.ForwardFunction,\n private delayFor: RetryLink.DelayFunction,\n private retryIf: RetryLink.AttemptsFunction\n ) {\n this.try();\n }\n\n /**\n * Stop retrying for the operation, and cancel any in-progress requests.\n */\n public cancel() {\n if (this.currentSubscription) {\n this.currentSubscription.unsubscribe();\n }\n clearTimeout(this.timerId);\n this.timerId = undefined;\n this.currentSubscription = null;\n }\n\n private try() {\n this.currentSubscription = this.forward(this.operation).subscribe({\n next: (result) => {\n if (graphQLResultHasProtocolErrors(result)) {\n this.onError(result.extensions[PROTOCOL_ERRORS_SYMBOL], () =>\n // Pretend like we never encountered this error and move the result\n // along for Apollo Client core to handle this error.\n this.observer.next(result)\n );\n // Unsubscribe from the current subscription to prevent the `complete`\n // handler to be called as a result of the stream closing.\n this.currentSubscription?.unsubscribe();\n return;\n }\n\n this.observer.next(result);\n },\n error: (error) => this.onError(error, () => this.observer.error(error)),\n complete: this.observer.complete.bind(this.observer),\n });\n }\n\n private onError = async (error: unknown, onContinue: () => void) => {\n this.retryCount += 1;\n const errorLike = toErrorLike(error);\n\n const shouldRetry = await this.retryIf(\n this.retryCount,\n this.operation,\n errorLike\n );\n if (shouldRetry) {\n this.scheduleRetry(\n this.delayFor(this.retryCount, this.operation, errorLike)\n );\n return;\n }\n\n onContinue();\n };\n\n private scheduleRetry(delay: number) {\n if (this.timerId) {\n throw new Error(`RetryLink BUG! Encountered overlapping retries`);\n }\n\n this.timerId = setTimeout(() => {\n this.timerId = undefined;\n this.try();\n }, delay);\n }\n}\n\n/**\n * `RetryLink` is a non-terminating link that attempts to retry operations that\n * fail due to network errors. It enables resilient GraphQL operations by\n * automatically retrying failed requests with configurable delay and retry\n * strategies.\n *\n * @remarks\n *\n * `RetryLink` is particularly useful for handling unreliable network conditions\n * where you would rather wait longer than explicitly fail an operation. It\n * provides exponential backoff and jitters delays between attempts by default.\n *\n * > [!NOTE]\n * > This link does not handle retries for GraphQL errors in the response. Use\n * > `ErrorLink` to retry an operation after a GraphQL error. For more\n * > information, see the [Error handling documentation](https://apollographql.com/docs/react/data/error-handling#on-graphql-errors).\n *\n * @example\n *\n * ```ts\n * import { RetryLink } from \"@apollo/client/link/retry\";\n *\n * const link = new RetryLink();\n * ```\n */\nexport class RetryLink extends ApolloLink {\n private delayFor: RetryLink.DelayFunction;\n private retryIf: RetryLink.AttemptsFunction;\n\n constructor(options?: RetryLink.Options) {\n super();\n const { attempts, delay } = options || ({} as RetryLink.Options);\n this.delayFor =\n typeof delay === \"function\" ? delay : buildDelayFunction(delay);\n this.retryIf =\n typeof attempts === \"function\" ? attempts : buildRetryFunction(attempts);\n }\n\n public request(\n operation: ApolloLink.Operation,\n forward: ApolloLink.ForwardFunction\n ): Observable<ApolloLink.Result> {\n return new Observable((observer) => {\n const retryable = new RetryableOperation(\n observer,\n operation,\n forward,\n this.delayFor,\n this.retryIf\n );\n return () => {\n retryable.cancel();\n };\n });\n }\n}\n"]}
|
package/link/schema/index.d.ts
CHANGED
|
@@ -2,28 +2,150 @@ import type { GraphQLSchema } from "graphql";
|
|
|
2
2
|
import { Observable } from "rxjs";
|
|
3
3
|
import { ApolloLink } from "@apollo/client/link";
|
|
4
4
|
export declare namespace SchemaLink {
|
|
5
|
+
namespace SchemaLinkDocumentationTypes {
|
|
6
|
+
/**
|
|
7
|
+
* A function that returns the resolver context for a given operation.
|
|
8
|
+
*
|
|
9
|
+
* This function is called for each operation and allows you to create
|
|
10
|
+
* operation-specific context. This is useful when you need to include
|
|
11
|
+
* information from the operation (like headers, variables, etc.) in the
|
|
12
|
+
* resolver context.
|
|
13
|
+
*
|
|
14
|
+
* @param operation - The Apollo Link operation
|
|
15
|
+
* @returns The resolver context object or a promise that resolves to the context
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* const link = new SchemaLink({
|
|
21
|
+
* schema,
|
|
22
|
+
* context: (operation) => {
|
|
23
|
+
* return {
|
|
24
|
+
* userId: operation.getContext().userId,
|
|
25
|
+
* dataSources: {
|
|
26
|
+
* userAPI: new UserAPI(),
|
|
27
|
+
* },
|
|
28
|
+
* };
|
|
29
|
+
* },
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
function ResolverContextFunction(operation: ApolloLink.Operation): SchemaLink.ResolverContext | PromiseLike<SchemaLink.ResolverContext>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The resolver context object passed to GraphQL resolvers.
|
|
37
|
+
*
|
|
38
|
+
* This context object is passed as the third parameter to GraphQL resolvers
|
|
39
|
+
* and typically contains data-fetching connectors, authentication information,
|
|
40
|
+
* and other request-specific data.
|
|
41
|
+
*/
|
|
5
42
|
type ResolverContext = Record<string, any>;
|
|
6
|
-
|
|
43
|
+
/**
|
|
44
|
+
* A function that returns the resolver context for a given operation.
|
|
45
|
+
*
|
|
46
|
+
* This function is called for each operation and allows you to create
|
|
47
|
+
* operation-specific context. This is useful when you need to include
|
|
48
|
+
* information from the operation (like headers, variables, etc.) in the
|
|
49
|
+
* resolver context.
|
|
50
|
+
*
|
|
51
|
+
* @param operation - The Apollo Link operation
|
|
52
|
+
* @returns The resolver context object or a promise that resolves to the context
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
*
|
|
56
|
+
* ```ts
|
|
57
|
+
* const link = new SchemaLink({
|
|
58
|
+
* schema,
|
|
59
|
+
* context: (operation) => {
|
|
60
|
+
* return {
|
|
61
|
+
* userId: operation.getContext().userId,
|
|
62
|
+
* dataSources: {
|
|
63
|
+
* userAPI: new UserAPI(),
|
|
64
|
+
* },
|
|
65
|
+
* };
|
|
66
|
+
* },
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
type ResolverContextFunction = (operation: ApolloLink.Operation) => SchemaLink.ResolverContext | PromiseLike<SchemaLink.ResolverContext>;
|
|
71
|
+
/**
|
|
72
|
+
* Options for configuring the `SchemaLink`.
|
|
73
|
+
*/
|
|
7
74
|
interface Options {
|
|
8
75
|
/**
|
|
9
|
-
*
|
|
76
|
+
* An executable GraphQL schema to use for operation execution.
|
|
77
|
+
*
|
|
78
|
+
* @remarks
|
|
79
|
+
*
|
|
80
|
+
* This should be a complete, executable GraphQL schema created using
|
|
81
|
+
* tools like `makeExecutableSchema` from `@graphql-tools/schema` or
|
|
82
|
+
* `buildSchema` from `graphql`.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
*
|
|
86
|
+
* ```ts
|
|
87
|
+
* import { makeExecutableSchema } from "@graphql-tools/schema";
|
|
88
|
+
*
|
|
89
|
+
* const schema = makeExecutableSchema({
|
|
90
|
+
* typeDefs,
|
|
91
|
+
* resolvers,
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* const link = new SchemaLink({ schema });
|
|
95
|
+
* ```
|
|
10
96
|
*/
|
|
11
97
|
schema: GraphQLSchema;
|
|
12
98
|
/**
|
|
13
|
-
* The root value to
|
|
99
|
+
* The root value passed to root-level resolvers. It's typically not used in
|
|
100
|
+
* most schemas but can be useful for certain advanced patterns.
|
|
14
101
|
*/
|
|
15
102
|
rootValue?: any;
|
|
16
103
|
/**
|
|
17
|
-
*
|
|
104
|
+
* Context object or function that returns the context object to provide to
|
|
105
|
+
* resolvers. The context is passed as the third parameter to all GraphQL
|
|
106
|
+
* resolvers.
|
|
107
|
+
*
|
|
108
|
+
* - If a static object is provided, the same context will be used for all
|
|
109
|
+
* operations
|
|
110
|
+
* - If a function is provided, the function is called for each operation to
|
|
111
|
+
* generate operation-specific context
|
|
18
112
|
*/
|
|
19
113
|
context?: SchemaLink.ResolverContext | SchemaLink.ResolverContextFunction;
|
|
20
114
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
115
|
+
* Whether to validate incoming queries against the schema before execution.
|
|
116
|
+
*
|
|
117
|
+
* When enabled, queries will be validated against the schema before execution,
|
|
118
|
+
* and validation errors will be returned in the result's `errors` array,
|
|
119
|
+
* just like a remote GraphQL server would.
|
|
120
|
+
*
|
|
121
|
+
* This is useful for testing and development to catch query errors early,
|
|
122
|
+
* but may add overhead in production environments.
|
|
123
|
+
*
|
|
124
|
+
* @defaultValue false
|
|
23
125
|
*/
|
|
24
126
|
validate?: boolean;
|
|
25
127
|
}
|
|
26
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* `SchemaLink` is a terminating link that executes GraphQL operations against
|
|
131
|
+
* a local GraphQL schema instead of making network requests. This is commonly
|
|
132
|
+
* used for server-side rendering (SSR) and mocking dataa.
|
|
133
|
+
*
|
|
134
|
+
* > [!NOTE]
|
|
135
|
+
* > While `SchemaLink` can provide GraphQL results on the client, the GraphQL
|
|
136
|
+
* > execution layer is [quite large](https://bundlephobia.com/result?p=graphql) for practical client-side use.
|
|
137
|
+
* > For client-side state management, consider Apollo Client's [local state management](https://apollographql.com/docs/react/local-state/local-state-management/)
|
|
138
|
+
* > functionality instead, which integrates with the Apollo Client cache.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
*
|
|
142
|
+
* ```ts
|
|
143
|
+
* import { SchemaLink } from "@apollo/client/link/schema";
|
|
144
|
+
* import schema from "./path/to/your/schema";
|
|
145
|
+
*
|
|
146
|
+
* const link = new SchemaLink({ schema });
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
27
149
|
export declare class SchemaLink extends ApolloLink {
|
|
28
150
|
schema: SchemaLink.Options["schema"];
|
|
29
151
|
rootValue: SchemaLink.Options["rootValue"];
|
|
@@ -32,4 +154,4 @@ export declare class SchemaLink extends ApolloLink {
|
|
|
32
154
|
constructor(options: SchemaLink.Options);
|
|
33
155
|
request(operation: ApolloLink.Operation): Observable<ApolloLink.Result>;
|
|
34
156
|
}
|
|
35
|
-
//# sourceMappingURL=index.d.ts.map
|
|
157
|
+
//# sourceMappingURL=index.d.ts.map
|
package/link/schema/index.js
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
import { execute, validate } from "graphql";
|
|
2
2
|
import { Observable } from "rxjs";
|
|
3
3
|
import { ApolloLink } from "@apollo/client/link";
|
|
4
|
+
/**
|
|
5
|
+
* `SchemaLink` is a terminating link that executes GraphQL operations against
|
|
6
|
+
* a local GraphQL schema instead of making network requests. This is commonly
|
|
7
|
+
* used for server-side rendering (SSR) and mocking dataa.
|
|
8
|
+
*
|
|
9
|
+
* > [!NOTE]
|
|
10
|
+
* > While `SchemaLink` can provide GraphQL results on the client, the GraphQL
|
|
11
|
+
* > execution layer is [quite large](https://bundlephobia.com/result?p=graphql) for practical client-side use.
|
|
12
|
+
* > For client-side state management, consider Apollo Client's [local state management](https://apollographql.com/docs/react/local-state/local-state-management/)
|
|
13
|
+
* > functionality instead, which integrates with the Apollo Client cache.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { SchemaLink } from "@apollo/client/link/schema";
|
|
19
|
+
* import schema from "./path/to/your/schema";
|
|
20
|
+
*
|
|
21
|
+
* const link = new SchemaLink({ schema });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
4
24
|
export class SchemaLink extends ApolloLink {
|
|
5
25
|
schema;
|
|
6
26
|
rootValue;
|
package/link/schema/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/schema/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/schema/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AA+GjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;IACjC,MAAM,CAA+B;IACrC,SAAS,CAAkC;IAC3C,OAAO,CAAgC;IACvC,QAAQ,CAAU;IAEzB,YAAY,OAA2B;QACrC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IACrC,CAAC;IAEM,OAAO,CACZ,SAA+B;QAE/B,OAAO,IAAI,UAAU,CAAoB,CAAC,QAAQ,EAAE,EAAE;YACpD,IAAI,OAAO,CAA6B,CAAC,OAAO,EAAE,EAAE,CAClD,OAAO,CACL,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC;gBAClC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;gBACzB,CAAC,CAAC,IAAI,CAAC,OAAO,CACf,CACF;iBACE,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;gBAChB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;oBAClB,MAAM,gBAAgB,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;oBAChE,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBAChC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;oBACtC,CAAC;gBACH,CAAC;gBAED,OAAO,OAAO,CAAC;oBACb,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,QAAQ,EAAE,SAAS,CAAC,KAAK;oBACzB,SAAS,EAAE,IAAI,CAAC,SAAS;oBACzB,YAAY,EAAE,OAAO;oBACrB,cAAc,EAAE,SAAS,CAAC,SAAS;oBACnC,aAAa,EAAE,SAAS,CAAC,aAAa;iBACvC,CAAC,CAAC;YACL,CAAC,CAAC;iBACD,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;gBACb,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;oBACrB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACpB,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBACtB,CAAC;YACH,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACf,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;oBACrB,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACxB,CAAC;YACH,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type { GraphQLSchema } from \"graphql\";\nimport { execute, validate } from \"graphql\";\nimport { Observable } from \"rxjs\";\n\nimport { ApolloLink } from \"@apollo/client/link\";\n\nexport declare namespace SchemaLink {\n export namespace SchemaLinkDocumentationTypes {\n /**\n * A function that returns the resolver context for a given operation.\n *\n * This function is called for each operation and allows you to create\n * operation-specific context. This is useful when you need to include\n * information from the operation (like headers, variables, etc.) in the\n * resolver context.\n *\n * @param operation - The Apollo Link operation\n * @returns The resolver context object or a promise that resolves to the context\n *\n * @example\n *\n * ```ts\n * const link = new SchemaLink({\n * schema,\n * context: (operation) => {\n * return {\n * userId: operation.getContext().userId,\n * dataSources: {\n * userAPI: new UserAPI(),\n * },\n * };\n * },\n * });\n * ```\n */\n export function ResolverContextFunction(\n operation: ApolloLink.Operation\n ): SchemaLink.ResolverContext | PromiseLike<SchemaLink.ResolverContext>;\n }\n /**\n * The resolver context object passed to GraphQL resolvers.\n *\n * This context object is passed as the third parameter to GraphQL resolvers\n * and typically contains data-fetching connectors, authentication information,\n * and other request-specific data.\n */\n export type ResolverContext = Record<string, any>;\n\n /** {@inheritDoc @apollo/client/link/schema!SchemaLink.SchemaLinkDocumentationTypes.ResolverContextFunction:function(1)} */\n export type ResolverContextFunction = (\n operation: ApolloLink.Operation\n ) => SchemaLink.ResolverContext | PromiseLike<SchemaLink.ResolverContext>;\n\n /**\n * Options for configuring the `SchemaLink`.\n */\n export interface Options {\n /**\n * An executable GraphQL schema to use for operation execution.\n *\n * @remarks\n *\n * This should be a complete, executable GraphQL schema created using\n * tools like `makeExecutableSchema` from `@graphql-tools/schema` or\n * `buildSchema` from `graphql`.\n *\n * @example\n *\n * ```ts\n * import { makeExecutableSchema } from \"@graphql-tools/schema\";\n *\n * const schema = makeExecutableSchema({\n * typeDefs,\n * resolvers,\n * });\n *\n * const link = new SchemaLink({ schema });\n * ```\n */\n schema: GraphQLSchema;\n\n /**\n * The root value passed to root-level resolvers. It's typically not used in\n * most schemas but can be useful for certain advanced patterns.\n */\n rootValue?: any;\n\n /**\n * Context object or function that returns the context object to provide to\n * resolvers. The context is passed as the third parameter to all GraphQL\n * resolvers.\n *\n * - If a static object is provided, the same context will be used for all\n * operations\n * - If a function is provided, the function is called for each operation to\n * generate operation-specific context\n */\n context?: SchemaLink.ResolverContext | SchemaLink.ResolverContextFunction;\n\n /**\n * Whether to validate incoming queries against the schema before execution.\n *\n * When enabled, queries will be validated against the schema before execution,\n * and validation errors will be returned in the result's `errors` array,\n * just like a remote GraphQL server would.\n *\n * This is useful for testing and development to catch query errors early,\n * but may add overhead in production environments.\n *\n * @defaultValue false\n */\n validate?: boolean;\n }\n}\n\n/**\n * `SchemaLink` is a terminating link that executes GraphQL operations against\n * a local GraphQL schema instead of making network requests. This is commonly\n * used for server-side rendering (SSR) and mocking dataa.\n *\n * > [!NOTE]\n * > While `SchemaLink` can provide GraphQL results on the client, the GraphQL\n * > execution layer is [quite large](https://bundlephobia.com/result?p=graphql) for practical client-side use.\n * > For client-side state management, consider Apollo Client's [local state management](https://apollographql.com/docs/react/local-state/local-state-management/)\n * > functionality instead, which integrates with the Apollo Client cache.\n *\n * @example\n *\n * ```ts\n * import { SchemaLink } from \"@apollo/client/link/schema\";\n * import schema from \"./path/to/your/schema\";\n *\n * const link = new SchemaLink({ schema });\n * ```\n */\nexport class SchemaLink extends ApolloLink {\n public schema: SchemaLink.Options[\"schema\"];\n public rootValue: SchemaLink.Options[\"rootValue\"];\n public context: SchemaLink.Options[\"context\"];\n public validate: boolean;\n\n constructor(options: SchemaLink.Options) {\n super();\n this.schema = options.schema;\n this.rootValue = options.rootValue;\n this.context = options.context;\n this.validate = !!options.validate;\n }\n\n public request(\n operation: ApolloLink.Operation\n ): Observable<ApolloLink.Result> {\n return new Observable<ApolloLink.Result>((observer) => {\n new Promise<SchemaLink.ResolverContext>((resolve) =>\n resolve(\n typeof this.context === \"function\" ?\n this.context(operation)\n : this.context\n )\n )\n .then((context) => {\n if (this.validate) {\n const validationErrors = validate(this.schema, operation.query);\n if (validationErrors.length > 0) {\n return { errors: validationErrors };\n }\n }\n\n return execute({\n schema: this.schema,\n document: operation.query,\n rootValue: this.rootValue,\n contextValue: context,\n variableValues: operation.variables,\n operationName: operation.operationName,\n });\n })\n .then((data) => {\n if (!observer.closed) {\n observer.next(data);\n observer.complete();\n }\n })\n .catch((error) => {\n if (!observer.closed) {\n observer.error(error);\n }\n });\n });\n }\n}\n"]}
|
package/link/ws/index.d.ts
CHANGED
|
@@ -4,25 +4,76 @@ import { SubscriptionClient } from "subscriptions-transport-ws";
|
|
|
4
4
|
import { ApolloLink } from "@apollo/client/link";
|
|
5
5
|
export declare namespace WebSocketLink {
|
|
6
6
|
/**
|
|
7
|
-
* Configuration
|
|
7
|
+
* Configuration options for creating a `WebSocketLink` instance.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
*
|
|
11
|
+
* These configuration options are used when creating a `WebSocketLink` without
|
|
12
|
+
* providing an existing `SubscriptionClient` instance. The options are passed
|
|
13
|
+
* directly to the `SubscriptionClient` constructor from the `subscriptions-transport-ws`
|
|
14
|
+
* library.
|
|
8
15
|
*/
|
|
9
16
|
interface Configuration {
|
|
10
17
|
/**
|
|
11
|
-
* The endpoint to connect to.
|
|
18
|
+
* The WebSocket endpoint URI to connect to.
|
|
19
|
+
*
|
|
20
|
+
* This should be a valid WebSocket URI (starting with `ws://` or `wss://`)
|
|
21
|
+
* that points to your GraphQL subscription endpoint.
|
|
22
|
+
*
|
|
23
|
+
* @example "ws://localhost:4000/subscriptions"
|
|
24
|
+
* @example "wss://api.example.com/graphql"
|
|
12
25
|
*/
|
|
13
26
|
uri: string;
|
|
14
27
|
/**
|
|
15
|
-
*
|
|
28
|
+
* Configuration options passed to the underlying `SubscriptionClient`.
|
|
29
|
+
*
|
|
30
|
+
* These options configure the WebSocket connection behavior, including
|
|
31
|
+
* reconnection settings, connection parameters, and event handlers.
|
|
32
|
+
*
|
|
33
|
+
* For a complete list of available options, see the
|
|
34
|
+
* [supported `subscriptions-transport-ws` options](https://github.com/apollographql/subscriptions-transport-ws/blob/master/src/client.ts#L61-L71).
|
|
16
35
|
*/
|
|
17
36
|
options?: ClientOptions;
|
|
18
37
|
/**
|
|
19
|
-
* A custom WebSocket implementation to use.
|
|
38
|
+
* A custom WebSocket implementation to use for the connection.
|
|
39
|
+
*
|
|
40
|
+
* This is useful in environments that don't have native WebSocket support.
|
|
41
|
+
* You can provide a WebSocket polyfill or implementation that conforms to
|
|
42
|
+
* the W3C WebSocket API.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* import WebSocket from "ws";
|
|
48
|
+
*
|
|
49
|
+
* const wsLink = new WebSocketLink({
|
|
50
|
+
* uri: "ws://localhost:4000/subscriptions",
|
|
51
|
+
* webSocketImpl: WebSocket,
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
20
54
|
*/
|
|
21
55
|
webSocketImpl?: any;
|
|
22
56
|
}
|
|
23
57
|
}
|
|
24
|
-
export import WebSocketParams = WebSocketLink.Configuration;
|
|
25
58
|
/**
|
|
59
|
+
* `WebSocketLink` is a terminating link that executes GraphQL operations over
|
|
60
|
+
* WebSocket connections using the `subscriptions-transport-ws` library. It's
|
|
61
|
+
* primarily used for GraphQL subscriptions but can also handle queries and
|
|
62
|
+
* mutations.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
*
|
|
66
|
+
* ```ts
|
|
67
|
+
* import { WebSocketLink } from "@apollo/client/link/ws";
|
|
68
|
+
* import { SubscriptionClient } from "subscriptions-transport-ws";
|
|
69
|
+
*
|
|
70
|
+
* const wsLink = new WebSocketLink(
|
|
71
|
+
* new SubscriptionClient("ws://localhost:4000/subscriptions", {
|
|
72
|
+
* reconnect: true,
|
|
73
|
+
* })
|
|
74
|
+
* );
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
26
77
|
* @deprecated `WebSocketLink` uses the deprecated and unmaintained
|
|
27
78
|
* `subscriptions-transport-ws` library. This link is no longer maintained and
|
|
28
79
|
* will be removed in a future major version of Apollo Client. We recommend
|
package/link/ws/index.js
CHANGED
|
@@ -3,6 +3,24 @@ import { ApolloLink } from "@apollo/client/link";
|
|
|
3
3
|
import { __DEV__ } from "@apollo/client/utilities/environment";
|
|
4
4
|
import { invariant } from "@apollo/client/utilities/invariant";
|
|
5
5
|
/**
|
|
6
|
+
* `WebSocketLink` is a terminating link that executes GraphQL operations over
|
|
7
|
+
* WebSocket connections using the `subscriptions-transport-ws` library. It's
|
|
8
|
+
* primarily used for GraphQL subscriptions but can also handle queries and
|
|
9
|
+
* mutations.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { WebSocketLink } from "@apollo/client/link/ws";
|
|
15
|
+
* import { SubscriptionClient } from "subscriptions-transport-ws";
|
|
16
|
+
*
|
|
17
|
+
* const wsLink = new WebSocketLink(
|
|
18
|
+
* new SubscriptionClient("ws://localhost:4000/subscriptions", {
|
|
19
|
+
* reconnect: true,
|
|
20
|
+
* })
|
|
21
|
+
* );
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
6
24
|
* @deprecated `WebSocketLink` uses the deprecated and unmaintained
|
|
7
25
|
* `subscriptions-transport-ws` library. This link is no longer maintained and
|
|
8
26
|
* will be removed in a future major version of Apollo Client. We recommend
|
package/link/ws/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/link/ws/index.ts"],"sourcesContent":["import type { Observable } from \"rxjs\";\nimport type { ClientOptions } from \"subscriptions-transport-ws\";\nimport { SubscriptionClient } from \"subscriptions-transport-ws\";\n\nimport { ApolloLink } from \"@apollo/client/link\";\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport { invariant } from \"@apollo/client/utilities/invariant\";\n\nexport declare namespace WebSocketLink {\n /**\n * Configuration
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/link/ws/index.ts"],"sourcesContent":["import type { Observable } from \"rxjs\";\nimport type { ClientOptions } from \"subscriptions-transport-ws\";\nimport { SubscriptionClient } from \"subscriptions-transport-ws\";\n\nimport { ApolloLink } from \"@apollo/client/link\";\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport { invariant } from \"@apollo/client/utilities/invariant\";\n\nexport declare namespace WebSocketLink {\n /**\n * Configuration options for creating a `WebSocketLink` instance.\n *\n * @remarks\n *\n * These configuration options are used when creating a `WebSocketLink` without\n * providing an existing `SubscriptionClient` instance. The options are passed\n * directly to the `SubscriptionClient` constructor from the `subscriptions-transport-ws`\n * library.\n */\n export interface Configuration {\n /**\n * The WebSocket endpoint URI to connect to.\n *\n * This should be a valid WebSocket URI (starting with `ws://` or `wss://`)\n * that points to your GraphQL subscription endpoint.\n *\n * @example \"ws://localhost:4000/subscriptions\"\n * @example \"wss://api.example.com/graphql\"\n */\n uri: string;\n\n /**\n * Configuration options passed to the underlying `SubscriptionClient`.\n *\n * These options configure the WebSocket connection behavior, including\n * reconnection settings, connection parameters, and event handlers.\n *\n * For a complete list of available options, see the\n * [supported `subscriptions-transport-ws` options](https://github.com/apollographql/subscriptions-transport-ws/blob/master/src/client.ts#L61-L71).\n */\n options?: ClientOptions;\n\n /**\n * A custom WebSocket implementation to use for the connection.\n *\n * This is useful in environments that don't have native WebSocket support.\n * You can provide a WebSocket polyfill or implementation that conforms to\n * the W3C WebSocket API.\n *\n * @example\n *\n * ```ts\n * import WebSocket from \"ws\";\n *\n * const wsLink = new WebSocketLink({\n * uri: \"ws://localhost:4000/subscriptions\",\n * webSocketImpl: WebSocket,\n * });\n * ```\n */\n webSocketImpl?: any;\n }\n}\n\n/**\n * `WebSocketLink` is a terminating link that executes GraphQL operations over\n * WebSocket connections using the `subscriptions-transport-ws` library. It's\n * primarily used for GraphQL subscriptions but can also handle queries and\n * mutations.\n *\n * @example\n *\n * ```ts\n * import { WebSocketLink } from \"@apollo/client/link/ws\";\n * import { SubscriptionClient } from \"subscriptions-transport-ws\";\n *\n * const wsLink = new WebSocketLink(\n * new SubscriptionClient(\"ws://localhost:4000/subscriptions\", {\n * reconnect: true,\n * })\n * );\n * ```\n *\n * @deprecated `WebSocketLink` uses the deprecated and unmaintained\n * `subscriptions-transport-ws` library. This link is no longer maintained and\n * will be removed in a future major version of Apollo Client. We recommend\n * switching to `GraphQLWsLink`, which uses the [`graphql-ws` library](https://the-guild.dev/graphql/ws) to\n * send GraphQL operations through WebSocket connections.\n */\nexport class WebSocketLink extends ApolloLink {\n private subscriptionClient: SubscriptionClient;\n\n constructor(\n paramsOrClient: WebSocketLink.Configuration | SubscriptionClient\n ) {\n super();\n\n if (__DEV__) {\n invariant.warn(\n \"`WebSocketLink` uses the deprecated and unmaintained `subscriptions-transport-ws` library. This link is no longer maintained and will be removed in a future major version of Apollo Client. We recommend switching to `GraphQLWsLink` which uses the `graphql-ws` library to send GraphQL operations through WebSocket connections (https://the-guild.dev/graphql/ws).\"\n );\n }\n\n if (paramsOrClient instanceof SubscriptionClient) {\n this.subscriptionClient = paramsOrClient;\n } else {\n this.subscriptionClient = new SubscriptionClient(\n paramsOrClient.uri,\n paramsOrClient.options,\n paramsOrClient.webSocketImpl\n );\n }\n }\n\n public request(\n operation: ApolloLink.Operation\n ): Observable<ApolloLink.Result> {\n return this.subscriptionClient.request(\n operation\n ) as Observable<ApolloLink.Result>;\n }\n}\n"],"names":[],"mappings":"AAEA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAE,CAAT,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAAmC,CAAnC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA+D;AAE/D,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAE,CAAT,CAAA,CAAA,CAAA,CAA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