@apollo/client 3.5.10 → 3.6.9
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/LICENSE +1 -1
- package/README.md +5 -5
- package/apollo-client.cjs +563 -375
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +10 -11
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +2288 -0
- package/cache/inmemory/policies.js +1 -1
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +10 -11
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/core/ApolloClient.d.ts +2 -3
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +4 -8
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +10 -4
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +101 -46
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js +4 -2
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +5 -2
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +36 -27
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +148 -90
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +2146 -0
- package/core/index.d.ts +1 -1
- package/core/index.d.ts.map +1 -1
- package/core/index.js +1 -1
- package/core/index.js.map +1 -1
- package/core/watchQueryOptions.d.ts +9 -1
- package/core/watchQueryOptions.d.ts.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/errors/errors.cjs.native.js +48 -0
- package/invariantErrorCodes.js +1 -1
- package/link/batch/batch.cjs +46 -37
- package/link/batch/batch.cjs.map +1 -1
- package/link/batch/batch.cjs.native.js +160 -0
- package/link/batch/batching.d.ts +2 -6
- package/link/batch/batching.d.ts.map +1 -1
- package/link/batch/batching.js +46 -37
- package/link/batch/batching.js.map +1 -1
- package/link/batch-http/batch-http.cjs.native.js +127 -0
- package/link/context/context.cjs.native.js +38 -0
- package/link/core/core.cjs.native.js +121 -0
- package/link/error/error.cjs.native.js +90 -0
- package/link/http/http.cjs.native.js +320 -0
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/persisted-queries/index.d.ts +2 -1
- package/link/persisted-queries/index.d.ts.map +1 -1
- package/link/persisted-queries/index.js +26 -13
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs +25 -12
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +174 -0
- package/link/retry/retry.cjs.native.js +170 -0
- package/link/schema/schema.cjs.native.js +56 -0
- package/link/subscriptions/subscriptions.cjs.native.js +45 -0
- package/link/utils/utils.cjs.native.js +115 -0
- package/link/ws/ws.cjs.native.js +28 -0
- package/main.cjs.native.js +16 -0
- package/package.json +30 -27
- package/react/components/components.cjs.native.js +79 -0
- package/react/context/ApolloConsumer.js +2 -2
- package/react/context/ApolloProvider.js +2 -2
- package/react/context/context.cjs +4 -4
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +67 -0
- package/react/hoc/hoc.cjs.native.js +325 -0
- package/react/hooks/hooks.cjs +376 -253
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +623 -0
- package/react/hooks/index.d.ts +1 -1
- package/react/hooks/index.d.ts.map +1 -1
- package/react/hooks/index.js +1 -1
- package/react/hooks/index.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +2 -2
- package/react/hooks/useLazyQuery.d.ts.map +1 -1
- package/react/hooks/useLazyQuery.js +26 -21
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts.map +1 -1
- package/react/hooks/useMutation.js +13 -10
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +37 -2
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +256 -206
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts.map +1 -1
- package/react/hooks/useSubscription.js +17 -7
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSyncExternalStore.d.ts +4 -0
- package/react/hooks/useSyncExternalStore.d.ts.map +1 -0
- package/react/hooks/useSyncExternalStore.js +48 -0
- package/react/hooks/useSyncExternalStore.js.map +1 -0
- package/react/parser/index.d.ts.map +1 -1
- package/react/parser/index.js +24 -10
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs +24 -10
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +103 -0
- package/react/react.cjs.native.js +22 -0
- package/react/ssr/RenderPromises.d.ts +3 -2
- package/react/ssr/RenderPromises.d.ts.map +1 -1
- package/react/ssr/RenderPromises.js +25 -3
- package/react/ssr/RenderPromises.js.map +1 -1
- package/react/ssr/ssr.cjs +25 -3
- package/react/ssr/ssr.cjs.map +1 -1
- package/react/ssr/ssr.cjs.native.js +150 -0
- package/react/types/types.d.ts +10 -11
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs.native.js +288 -0
- package/testing/core/mocking/mockFetch.js +1 -1
- package/testing/core/mocking/mockFetch.js.map +1 -1
- package/testing/core/mocking/mockQueryManager.js +1 -1
- package/testing/core/mocking/mockWatchQuery.js +1 -1
- package/testing/core/wrap.js +1 -1
- package/testing/testing.cjs.native.js +58 -0
- package/utilities/common/canUse.d.ts +2 -0
- package/utilities/common/canUse.d.ts.map +1 -1
- package/utilities/common/canUse.js +6 -2
- package/utilities/common/canUse.js.map +1 -1
- package/utilities/common/mergeDeep.d.ts.map +1 -1
- package/utilities/common/mergeDeep.js +8 -11
- package/utilities/common/mergeDeep.js.map +1 -1
- package/utilities/common/mergeOptions.d.ts +5 -0
- package/utilities/common/mergeOptions.d.ts.map +1 -0
- package/utilities/common/mergeOptions.js +8 -0
- package/utilities/common/mergeOptions.js.map +1 -0
- package/utilities/globals/global.js +1 -2
- package/utilities/globals/globals.cjs.native.js +56 -0
- package/utilities/graphql/transform.d.ts +2 -2
- package/utilities/graphql/transform.d.ts.map +1 -1
- package/utilities/graphql/transform.js +1 -1
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +1 -0
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +1 -0
- package/utilities/index.js.map +1 -1
- package/utilities/observables/Concast.d.ts +1 -0
- package/utilities/observables/Concast.d.ts.map +1 -1
- package/utilities/observables/Concast.js +5 -2
- package/utilities/observables/Concast.js.map +1 -1
- package/utilities/policies/pagination.d.ts.map +1 -1
- package/utilities/policies/pagination.js +9 -7
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/utilities.cjs +37 -23
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +1281 -0
- package/version.js +1 -1
package/core/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ApolloClient, ApolloClientOptions, DefaultOptions, mergeOptions, } from './ApolloClient';
|
|
2
|
-
export { ObservableQuery, FetchMoreOptions, UpdateQueryOptions,
|
|
2
|
+
export { ObservableQuery, FetchMoreOptions, UpdateQueryOptions, } from './ObservableQuery';
|
|
3
3
|
export { QueryOptions, WatchQueryOptions, MutationOptions, SubscriptionOptions, FetchPolicy, WatchQueryFetchPolicy, ErrorPolicy, FetchMoreQueryOptions, SubscribeToMoreOptions, } from './watchQueryOptions';
|
|
4
4
|
export { NetworkStatus } from './networkStatus';
|
|
5
5
|
export * from './types';
|
package/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,WAAW,EACX,qBAAqB,EACrB,WAAW,EACX,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,QAAQ,EACR,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAIvD,OAAO,EAGL,KAAK,EACL,WAAW,EACX,WAAW,EACX,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,WAAW,EACX,OAAO,EACP,YAAY,EACZ,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAElB,cAAc,yBAAyB,CAAC;AAIxC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,WAAW,EACX,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAIvB,OAAO,EACL,UAAU,EACV,QAAQ,EACR,sBAAsB,EACtB,SAAS,EACT,WAAW,EACX,aAAa,EACb,WAAW,GACZ,MAAM,cAAc,CAAC;AAQtB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,IAAI,eAAe,EAAE,CAAA;AAe1C,OAAO,EACL,GAAG,EACH,WAAW,EACX,uBAAuB,EACvB,mCAAmC,EACnC,oCAAoC,GACrC,MAAM,aAAa,CAAC"}
|
package/core/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEV } from "../utilities/globals/index.js";
|
|
2
2
|
export { ApolloClient, mergeOptions, } from "./ApolloClient.js";
|
|
3
|
-
export { ObservableQuery,
|
|
3
|
+
export { ObservableQuery, } from "./ObservableQuery.js";
|
|
4
4
|
export { NetworkStatus } from "./networkStatus.js";
|
|
5
5
|
export * from "./types.js";
|
|
6
6
|
export { isApolloError, ApolloError } from "../errors/index.js";
|
package/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAE3C,OAAO,EACL,YAAY,EAGZ,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAE3C,OAAO,EACL,YAAY,EAGZ,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,GAGhB,MAAM,mBAAmB,CAAC;AAY3B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,cAAc,SAAS,CAAC;AAKxB,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAIvD,OAAO,EAGL,KAAK,EACL,WAAW,EAGX,aAAa,EAEb,iBAAiB,EACjB,uBAAuB,EAEvB,OAAO,GAQR,MAAM,UAAU,CAAC;AAElB,cAAc,yBAAyB,CAAC;AAIxC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EAEX,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAIvB,OAAO,EACL,UAAU,EAIV,WAAW,EACX,aAAa,GAEd,MAAM,cAAc,CAAC;AAQtB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,IAAI,eAAe,EAAE,CAAA;AAC1C,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAcrC,OAAO,EACL,GAAG,EACH,WAAW,EACX,uBAAuB,EACvB,mCAAmC,EACnC,oCAAoC,GACrC,MAAM,aAAa,CAAC","sourcesContent":["/* Core */\n\nimport { DEV } from '../utilities/globals';\n\nexport {\n ApolloClient,\n ApolloClientOptions,\n DefaultOptions,\n mergeOptions,\n} from './ApolloClient';\nexport {\n ObservableQuery,\n FetchMoreOptions,\n UpdateQueryOptions,\n} from './ObservableQuery';\nexport {\n QueryOptions,\n WatchQueryOptions,\n MutationOptions,\n SubscriptionOptions,\n FetchPolicy,\n WatchQueryFetchPolicy,\n ErrorPolicy,\n FetchMoreQueryOptions,\n SubscribeToMoreOptions,\n} from './watchQueryOptions';\nexport { NetworkStatus } from './networkStatus';\nexport * from './types';\nexport {\n Resolver,\n FragmentMatcher,\n} from './LocalState';\nexport { isApolloError, ApolloError } from '../errors';\n\n/* Cache */\n\nexport {\n // All the exports (types and values) from ../cache, minus cacheSlot,\n // which we want to keep semi-private.\n Cache,\n ApolloCache,\n Transaction,\n DataProxy,\n InMemoryCache,\n InMemoryCacheConfig,\n MissingFieldError,\n defaultDataIdFromObject,\n ReactiveVar,\n makeVar,\n TypePolicies,\n TypePolicy,\n FieldPolicy,\n FieldReadFunction,\n FieldMergeFunction,\n FieldFunctionOptions,\n PossibleTypesMap,\n} from '../cache';\n\nexport * from '../cache/inmemory/types';\n\n/* Link */\n\nexport * from '../link/core';\nexport * from '../link/http';\nexport {\n fromError,\n toPromise,\n fromPromise,\n ServerError,\n throwServerError,\n} from '../link/utils';\n\n/* Utilities */\n\nexport {\n Observable,\n Observer,\n ObservableSubscription,\n Reference,\n isReference,\n makeReference,\n StoreObject,\n} from '../utilities';\n\n/* Supporting */\n\n// The verbosity of invariant.{log,warn,error} can be controlled globally\n// (for anyone using the same ts-invariant package) by passing \"log\",\n// \"warn\", \"error\", or \"silent\" to setVerbosity (\"log\" is the default).\n// Note that all invariant.* logging is hidden in production.\nimport { setVerbosity } from \"ts-invariant\";\nexport { setVerbosity as setLogVerbosity }\nsetVerbosity(DEV ? \"log\" : \"silent\");\n\n// Note that importing `gql` by itself, then destructuring\n// additional properties separately before exporting, is intentional.\n// Due to the way the `graphql-tag` library is setup, certain bundlers\n// can't find the properties added to the exported `gql` function without\n// additional guidance (e.g. Rollup - see\n// https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module).\n// Instead of having people that are using bundlers with `@apollo/client` add\n// extra bundler config to help `graphql-tag` exports be found (which would be\n// awkward since they aren't importing `graphql-tag` themselves), this\n// workaround of pulling the extra properties off the `gql` function,\n// then re-exporting them separately, helps keeps bundlers happy without any\n// additional config changes.\nexport {\n gql,\n resetCaches,\n disableFragmentWarnings,\n enableExperimentalFragmentVariables,\n disableExperimentalFragmentVariables,\n} from 'graphql-tag';\n"]}
|
|
@@ -3,6 +3,7 @@ import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
|
3
3
|
import { FetchResult } from '../link/core';
|
|
4
4
|
import { DefaultContext, MutationQueryReducersMap, OperationVariables, MutationUpdaterFunction, OnQueryUpdated, InternalRefetchQueriesInclude } from './types';
|
|
5
5
|
import { ApolloCache } from '../cache';
|
|
6
|
+
import { ObservableQuery } from './ObservableQuery';
|
|
6
7
|
export declare type FetchPolicy = 'cache-first' | 'network-only' | 'cache-only' | 'no-cache' | 'standby';
|
|
7
8
|
export declare type WatchQueryFetchPolicy = FetchPolicy | 'cache-and-network';
|
|
8
9
|
export declare type MutationFetchPolicy = Extract<FetchPolicy, 'network-only' | 'no-cache'>;
|
|
@@ -22,9 +23,16 @@ export interface QueryOptions<TVariables = OperationVariables, TData = any> {
|
|
|
22
23
|
}
|
|
23
24
|
export interface WatchQueryOptions<TVariables = OperationVariables, TData = any> extends Omit<QueryOptions<TVariables, TData>, 'fetchPolicy'> {
|
|
24
25
|
fetchPolicy?: WatchQueryFetchPolicy;
|
|
25
|
-
nextFetchPolicy?: WatchQueryFetchPolicy | ((this: WatchQueryOptions<TVariables, TData>,
|
|
26
|
+
nextFetchPolicy?: WatchQueryFetchPolicy | ((this: WatchQueryOptions<TVariables, TData>, currentFetchPolicy: WatchQueryFetchPolicy, context: NextFetchPolicyContext<TData, TVariables>) => WatchQueryFetchPolicy);
|
|
27
|
+
initialFetchPolicy?: WatchQueryFetchPolicy;
|
|
26
28
|
refetchWritePolicy?: RefetchWritePolicy;
|
|
27
29
|
}
|
|
30
|
+
export interface NextFetchPolicyContext<TData, TVariables> {
|
|
31
|
+
reason: "after-fetch" | "variables-changed";
|
|
32
|
+
observable: ObservableQuery<TData, TVariables>;
|
|
33
|
+
options: WatchQueryOptions<TVariables, TData>;
|
|
34
|
+
initialFetchPolicy: WatchQueryFetchPolicy;
|
|
35
|
+
}
|
|
28
36
|
export interface FetchMoreQueryOptions<TVariables, TData = any> {
|
|
29
37
|
query?: DocumentNode | TypedDocumentNode<TData, TVariables>;
|
|
30
38
|
variables?: Partial<TVariables>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watchQueryOptions.d.ts","sourceRoot":"","sources":["../../src/core/watchQueryOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,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CAAC,IAAI,EAAE,UAAU,KAAK,KAAK,CAAC,CAAC;IAQ3D,aAAa,CAAC,EAAE,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAUhD,cAAc,CAAC,EACX,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,KAAK,6BAA6B,CAAC,GAC/D,6BAA6B,CAAC;IAUlC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAoB9B,MAAM,CAAC,EAAE,uBAAuB,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAMtE,cAAc,CAAC,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IAKrC,WAAW,CAAC,EAAE,WAAW,CAAC;IAM1B,SAAS,CAAC,EAAE,UAAU,CAAC;IAYtB,OAAO,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,WAAW,eAAe,CAC9B,KAAK,GAAG,GAAG,EACX,UAAU,GAAG,kBAAkB,EAC/B,QAAQ,GAAG,cAAc,EACzB,MAAM,SAAS,WAAW,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAClD,SAAQ,mBAAmB,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC;IAKhE,QAAQ,EAAE,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAO9D,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAWlC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watchQueryOptions.js","sourceRoot":"","sources":["../../src/core/watchQueryOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { DocumentNode } from 'graphql';\nimport { TypedDocumentNode } from '@graphql-typed-document-node/core';\n\nimport { FetchResult } from '../link/core';\nimport {\n DefaultContext,\n MutationQueryReducersMap,\n OperationVariables,\n MutationUpdaterFunction,\n OnQueryUpdated,\n InternalRefetchQueriesInclude,\n} from './types';\nimport { ApolloCache } from '../cache';\n\n/**\n * fetchPolicy determines where the client may return a result from. The options are:\n * - cache-first (default): return result from cache. Only fetch from network if cached result is not available.\n * - cache-and-network: return result from cache first (if it exists), then return network result once it's available.\n * - cache-only: return result from cache if available, fail otherwise.\n * - no-cache: return result from network, fail if network call doesn't succeed, don't save to cache\n * - network-only: return result from network, fail if network call doesn't succeed, save to cache\n * - standby: only for queries that aren't actively watched, but should be available for refetch and updateQueries.\n */\nexport type FetchPolicy =\n | 'cache-first'\n | 'network-only'\n | 'cache-only'\n | 'no-cache'\n | 'standby';\n\nexport type WatchQueryFetchPolicy = FetchPolicy | 'cache-and-network';\n\nexport type MutationFetchPolicy = Extract<\n FetchPolicy,\n | 'network-only' // default behavior (mutation results written to cache)\n | 'no-cache' // alternate behavior (results not written to cache)\n>;\n\nexport type RefetchWritePolicy = \"merge\" | \"overwrite\";\n\n/**\n * errorPolicy determines the level of events for errors in the execution result. The options are:\n * - none (default): any errors from the request are treated like runtime errors and the observable is stopped (XXX this is default to lower breaking changes going from AC 1.0 => 2.0)\n * - ignore: errors from the request do not stop the observable, but also don't call `next`\n * - all: errors are treated like data and will notify observables\n */\nexport type ErrorPolicy = 'none' | 'ignore' | 'all';\n\n/**\n * Query options.\n */\nexport interface QueryOptions<TVariables = OperationVariables, TData = any> {\n /**\n * A GraphQL document that consists of a single query to be sent down to the\n * server.\n */\n // TODO REFACTOR: rename this to document. Didn't do it yet because it's in a\n // lot of tests.\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * A map going from variable name to variable value, where the variables are used\n * within the GraphQL query.\n */\n variables?: TVariables;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this query\n */\n errorPolicy?: ErrorPolicy;\n\n /**\n * Context to be passed to link execution chain\n */\n context?: any;\n\n /**\n * Specifies the {@link FetchPolicy} to be used for this query\n */\n fetchPolicy?: FetchPolicy;\n\n /**\n * The time interval (in milliseconds) on which this query should be\n * refetched from the server.\n */\n pollInterval?: number;\n\n /**\n * Whether or not updates to the network status should trigger next on the observer of this query\n */\n notifyOnNetworkStatusChange?: boolean;\n\n /**\n * Allow returning incomplete data from the cache when a larger query cannot\n * be fully satisfied by the cache, instead of returning nothing.\n */\n returnPartialData?: boolean;\n\n /**\n * If `true`, perform a query `refetch` if the query result is marked as\n * being partial, and the returned data is reset to an empty Object by the\n * Apollo Client `QueryManager` (due to a cache miss).\n */\n partialRefetch?: boolean;\n\n /**\n * Whether to canonize cache results before returning them. Canonization\n * takes some extra time, but it speeds up future deep equality comparisons.\n * Defaults to false.\n */\n canonizeResults?: boolean;\n}\n\n/**\n * Watched query options.\n */\nexport interface WatchQueryOptions<TVariables = OperationVariables, TData = any>\n extends Omit<QueryOptions<TVariables, TData>, 'fetchPolicy'> {\n /**\n * Specifies the {@link FetchPolicy} to be used for this query.\n */\n fetchPolicy?: WatchQueryFetchPolicy;\n /**\n * Specifies the {@link FetchPolicy} to be used after this query has completed.\n */\n nextFetchPolicy?: WatchQueryFetchPolicy | ((\n this: WatchQueryOptions<TVariables, TData>,\n lastFetchPolicy: WatchQueryFetchPolicy,\n ) => WatchQueryFetchPolicy);\n /**\n * Specifies whether a {@link NetworkStatus.refetch} operation should merge\n * incoming field data with existing data, or overwrite the existing data.\n * Overwriting is probably preferable, but merging is currently the default\n * behavior, for backwards compatibility with Apollo Client 3.x.\n */\n refetchWritePolicy?: RefetchWritePolicy;\n}\n\nexport interface FetchMoreQueryOptions<TVariables, TData = any> {\n query?: DocumentNode | TypedDocumentNode<TData, TVariables>;\n variables?: Partial<TVariables>;\n context?: any;\n}\n\nexport type UpdateQueryFn<\n TData = any,\n TSubscriptionVariables = OperationVariables,\n TSubscriptionData = TData\n> = (\n previousQueryResult: TData,\n options: {\n subscriptionData: { data: TSubscriptionData };\n variables?: TSubscriptionVariables;\n },\n) => TData;\n\nexport type SubscribeToMoreOptions<\n TData = any,\n TSubscriptionVariables = OperationVariables,\n TSubscriptionData = TData\n> = {\n document: DocumentNode | TypedDocumentNode<TSubscriptionData, TSubscriptionVariables>;\n variables?: TSubscriptionVariables;\n updateQuery?: UpdateQueryFn<TData, TSubscriptionVariables, TSubscriptionData>;\n onError?: (error: Error) => void;\n context?: DefaultContext;\n};\n\nexport interface SubscriptionOptions<TVariables = OperationVariables, TData = any> {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single subscription inside of it.\n */\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * An object that maps from the name of a variable as used in the subscription\n * GraphQL document to that variable's value.\n */\n variables?: TVariables;\n\n /**\n * Specifies the {@link FetchPolicy} to be used for this subscription.\n */\n fetchPolicy?: FetchPolicy;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this operation\n */\n errorPolicy?: ErrorPolicy;\n\n /**\n * Context object to be passed through the link execution chain.\n */\n context?: DefaultContext;\n}\n\nexport interface MutationBaseOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> {\n /**\n * An object that represents the result of this mutation that will be\n * optimistically stored before the server has actually returned a result.\n * This is most often used for optimistic UI, where we want to be able to see\n * the result of a mutation immediately, and update the UI later if any errors\n * appear.\n */\n optimisticResponse?: TData | ((vars: TVariables) => TData);\n\n /**\n * A {@link MutationQueryReducersMap}, which is map from query names to\n * mutation query reducers. Briefly, this map defines how to incorporate the\n * results of the mutation into the results of queries that are currently\n * being watched by your application.\n */\n updateQueries?: MutationQueryReducersMap<TData>;\n\n /**\n * A list of query names which will be refetched once this mutation has\n * returned. This is often used if you have a set of queries which may be\n * affected by a mutation and will have to update. Rather than writing a\n * mutation query reducer (i.e. `updateQueries`) for this, you can simply\n * refetch the queries that will be affected and achieve a consistent store\n * once these queries return.\n */\n refetchQueries?:\n | ((result: FetchResult<TData>) => InternalRefetchQueriesInclude)\n | InternalRefetchQueriesInclude;\n\n /**\n * By default, `refetchQueries` does not wait for the refetched queries to\n * be completed, before resolving the mutation `Promise`. This ensures that\n * query refetching does not hold up mutation response handling (query\n * refetching is handled asynchronously). Set `awaitRefetchQueries` to\n * `true` if you would like to wait for the refetched queries to complete,\n * before the mutation can be marked as resolved.\n */\n awaitRefetchQueries?: boolean;\n\n /**\n * A function which provides an {@link ApolloCache} instance, and the result\n * of the mutation, to allow the user to update the store based on the\n * results of the mutation.\n *\n * This function will be called twice over the lifecycle of a mutation. Once\n * at the very beginning if an `optimisticResponse` was provided. The writes\n * created from the optimistic data will be rolled back before the second time\n * this function is called which is when the mutation has successfully\n * resolved. At that point `update` will be called with the *actual* mutation\n * result and those writes will not be rolled back.\n *\n * Note that since this function is intended to be used to update the\n * store, it cannot be used with a `no-cache` fetch policy. If you're\n * interested in performing some action after a mutation has completed,\n * and you don't need to update the store, use the Promise returned from\n * `client.mutate` instead.\n */\n update?: MutationUpdaterFunction<TData, TVariables, TContext, TCache>;\n\n /**\n * A function that will be called for each ObservableQuery affected by\n * this mutation, after the mutation has completed.\n */\n onQueryUpdated?: OnQueryUpdated<any>;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this operation\n */\n errorPolicy?: ErrorPolicy;\n\n /**\n * An object that maps from the name of a variable as used in the mutation\n * GraphQL document to that variable's value.\n */\n variables?: TVariables;\n\n /**\n * The context to be passed to the link execution chain. This context will\n * only be used with this mutation. It will not be used with\n * `refetchQueries`. Refetched queries use the context they were\n * initialized with (since the initial context is stored as part of the\n * `ObservableQuery` instance). If a specific context is needed when\n * refetching queries, make sure it is configured (via the\n * [query `context` option](https://www.apollographql.com/docs/react/api/apollo-client#ApolloClient.query))\n * when the query is first initialized/run.\n */\n context?: TContext;\n}\n\nexport interface MutationOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> extends MutationBaseOptions<TData, TVariables, TContext, TCache> {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single mutation inside of it.\n */\n mutation: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * Specifies the {@link MutationFetchPolicy} to be used for this query.\n * Mutations support only 'network-only' and 'no-cache' fetchPolicy strings.\n * If fetchPolicy is not provided, it defaults to 'network-only'.\n */\n fetchPolicy?: MutationFetchPolicy;\n\n /**\n * To avoid retaining sensitive information from mutation root field\n * arguments, Apollo Client v3.4+ automatically clears any `ROOT_MUTATION`\n * fields from the cache after each mutation finishes. If you need this\n * information to remain in the cache, you can prevent the removal by passing\n * `keepRootFields: true` to the mutation. `ROOT_MUTATION` result data are\n * also passed to the mutation `update` function, so we recommend obtaining\n * the results that way, rather than using this option, if possible.\n */\n keepRootFields?: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"watchQueryOptions.js","sourceRoot":"","sources":["../../src/core/watchQueryOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { DocumentNode } from 'graphql';\nimport { TypedDocumentNode } from '@graphql-typed-document-node/core';\n\nimport { FetchResult } from '../link/core';\nimport {\n DefaultContext,\n MutationQueryReducersMap,\n OperationVariables,\n MutationUpdaterFunction,\n OnQueryUpdated,\n InternalRefetchQueriesInclude,\n} from './types';\nimport { ApolloCache } from '../cache';\nimport { ObservableQuery } from './ObservableQuery';\n\n/**\n * fetchPolicy determines where the client may return a result from. The options are:\n * - cache-first (default): return result from cache. Only fetch from network if cached result is not available.\n * - cache-and-network: return result from cache first (if it exists), then return network result once it's available.\n * - cache-only: return result from cache if available, fail otherwise.\n * - no-cache: return result from network, fail if network call doesn't succeed, don't save to cache\n * - network-only: return result from network, fail if network call doesn't succeed, save to cache\n * - standby: only for queries that aren't actively watched, but should be available for refetch and updateQueries.\n */\nexport type FetchPolicy =\n | 'cache-first'\n | 'network-only'\n | 'cache-only'\n | 'no-cache'\n | 'standby';\n\nexport type WatchQueryFetchPolicy = FetchPolicy | 'cache-and-network';\n\nexport type MutationFetchPolicy = Extract<\n FetchPolicy,\n | 'network-only' // default behavior (mutation results written to cache)\n | 'no-cache' // alternate behavior (results not written to cache)\n>;\n\nexport type RefetchWritePolicy = \"merge\" | \"overwrite\";\n\n/**\n * errorPolicy determines the level of events for errors in the execution result. The options are:\n * - none (default): any errors from the request are treated like runtime errors and the observable is stopped (XXX this is default to lower breaking changes going from AC 1.0 => 2.0)\n * - ignore: errors from the request do not stop the observable, but also don't call `next`\n * - all: errors are treated like data and will notify observables\n */\nexport type ErrorPolicy = 'none' | 'ignore' | 'all';\n\n/**\n * Query options.\n */\nexport interface QueryOptions<TVariables = OperationVariables, TData = any> {\n /**\n * A GraphQL document that consists of a single query to be sent down to the\n * server.\n */\n // TODO REFACTOR: rename this to document. Didn't do it yet because it's in a\n // lot of tests.\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * A map going from variable name to variable value, where the variables are used\n * within the GraphQL query.\n */\n variables?: TVariables;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this query\n */\n errorPolicy?: ErrorPolicy;\n\n /**\n * Context to be passed to link execution chain\n */\n context?: any;\n\n /**\n * Specifies the {@link FetchPolicy} to be used for this query\n */\n fetchPolicy?: FetchPolicy;\n\n /**\n * The time interval (in milliseconds) on which this query should be\n * refetched from the server.\n */\n pollInterval?: number;\n\n /**\n * Whether or not updates to the network status should trigger next on the observer of this query\n */\n notifyOnNetworkStatusChange?: boolean;\n\n /**\n * Allow returning incomplete data from the cache when a larger query cannot\n * be fully satisfied by the cache, instead of returning nothing.\n */\n returnPartialData?: boolean;\n\n /**\n * If `true`, perform a query `refetch` if the query result is marked as\n * being partial, and the returned data is reset to an empty Object by the\n * Apollo Client `QueryManager` (due to a cache miss).\n */\n partialRefetch?: boolean;\n\n /**\n * Whether to canonize cache results before returning them. Canonization\n * takes some extra time, but it speeds up future deep equality comparisons.\n * Defaults to false.\n */\n canonizeResults?: boolean;\n}\n\n/**\n * Watched query options.\n */\nexport interface WatchQueryOptions<TVariables = OperationVariables, TData = any>\n extends Omit<QueryOptions<TVariables, TData>, 'fetchPolicy'> {\n /**\n * Specifies the {@link FetchPolicy} to be used for this query.\n */\n fetchPolicy?: WatchQueryFetchPolicy;\n\n /**\n * Specifies the {@link FetchPolicy} to be used after this query has completed.\n */\n nextFetchPolicy?: WatchQueryFetchPolicy | ((\n this: WatchQueryOptions<TVariables, TData>,\n currentFetchPolicy: WatchQueryFetchPolicy,\n context: NextFetchPolicyContext<TData, TVariables>,\n ) => WatchQueryFetchPolicy);\n\n /**\n * Defaults to the initial value of options.fetchPolicy, but can be explicitly\n * configured to specify the WatchQueryFetchPolicy to revert back to whenever\n * variables change (unless nextFetchPolicy intervenes).\n */\n initialFetchPolicy?: WatchQueryFetchPolicy;\n\n /**\n * Specifies whether a {@link NetworkStatus.refetch} operation should merge\n * incoming field data with existing data, or overwrite the existing data.\n * Overwriting is probably preferable, but merging is currently the default\n * behavior, for backwards compatibility with Apollo Client 3.x.\n */\n refetchWritePolicy?: RefetchWritePolicy;\n}\n\nexport interface NextFetchPolicyContext<TData, TVariables> {\n reason:\n | \"after-fetch\"\n | \"variables-changed\";\n observable: ObservableQuery<TData, TVariables>;\n options: WatchQueryOptions<TVariables, TData>;\n initialFetchPolicy: WatchQueryFetchPolicy;\n}\n\nexport interface FetchMoreQueryOptions<TVariables, TData = any> {\n query?: DocumentNode | TypedDocumentNode<TData, TVariables>;\n variables?: Partial<TVariables>;\n context?: any;\n}\n\nexport type UpdateQueryFn<\n TData = any,\n TSubscriptionVariables = OperationVariables,\n TSubscriptionData = TData\n> = (\n previousQueryResult: TData,\n options: {\n subscriptionData: { data: TSubscriptionData };\n variables?: TSubscriptionVariables;\n },\n) => TData;\n\nexport type SubscribeToMoreOptions<\n TData = any,\n TSubscriptionVariables = OperationVariables,\n TSubscriptionData = TData\n> = {\n document: DocumentNode | TypedDocumentNode<TSubscriptionData, TSubscriptionVariables>;\n variables?: TSubscriptionVariables;\n updateQuery?: UpdateQueryFn<TData, TSubscriptionVariables, TSubscriptionData>;\n onError?: (error: Error) => void;\n context?: DefaultContext;\n};\n\nexport interface SubscriptionOptions<TVariables = OperationVariables, TData = any> {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single subscription inside of it.\n */\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * An object that maps from the name of a variable as used in the subscription\n * GraphQL document to that variable's value.\n */\n variables?: TVariables;\n\n /**\n * Specifies the {@link FetchPolicy} to be used for this subscription.\n */\n fetchPolicy?: FetchPolicy;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this operation\n */\n errorPolicy?: ErrorPolicy;\n\n /**\n * Context object to be passed through the link execution chain.\n */\n context?: DefaultContext;\n}\n\nexport interface MutationBaseOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> {\n /**\n * An object that represents the result of this mutation that will be\n * optimistically stored before the server has actually returned a result.\n * This is most often used for optimistic UI, where we want to be able to see\n * the result of a mutation immediately, and update the UI later if any errors\n * appear.\n */\n optimisticResponse?: TData | ((vars: TVariables) => TData);\n\n /**\n * A {@link MutationQueryReducersMap}, which is map from query names to\n * mutation query reducers. Briefly, this map defines how to incorporate the\n * results of the mutation into the results of queries that are currently\n * being watched by your application.\n */\n updateQueries?: MutationQueryReducersMap<TData>;\n\n /**\n * A list of query names which will be refetched once this mutation has\n * returned. This is often used if you have a set of queries which may be\n * affected by a mutation and will have to update. Rather than writing a\n * mutation query reducer (i.e. `updateQueries`) for this, you can simply\n * refetch the queries that will be affected and achieve a consistent store\n * once these queries return.\n */\n refetchQueries?:\n | ((result: FetchResult<TData>) => InternalRefetchQueriesInclude)\n | InternalRefetchQueriesInclude;\n\n /**\n * By default, `refetchQueries` does not wait for the refetched queries to\n * be completed, before resolving the mutation `Promise`. This ensures that\n * query refetching does not hold up mutation response handling (query\n * refetching is handled asynchronously). Set `awaitRefetchQueries` to\n * `true` if you would like to wait for the refetched queries to complete,\n * before the mutation can be marked as resolved.\n */\n awaitRefetchQueries?: boolean;\n\n /**\n * A function which provides an {@link ApolloCache} instance, and the result\n * of the mutation, to allow the user to update the store based on the\n * results of the mutation.\n *\n * This function will be called twice over the lifecycle of a mutation. Once\n * at the very beginning if an `optimisticResponse` was provided. The writes\n * created from the optimistic data will be rolled back before the second time\n * this function is called which is when the mutation has successfully\n * resolved. At that point `update` will be called with the *actual* mutation\n * result and those writes will not be rolled back.\n *\n * Note that since this function is intended to be used to update the\n * store, it cannot be used with a `no-cache` fetch policy. If you're\n * interested in performing some action after a mutation has completed,\n * and you don't need to update the store, use the Promise returned from\n * `client.mutate` instead.\n */\n update?: MutationUpdaterFunction<TData, TVariables, TContext, TCache>;\n\n /**\n * A function that will be called for each ObservableQuery affected by\n * this mutation, after the mutation has completed.\n */\n onQueryUpdated?: OnQueryUpdated<any>;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this operation\n */\n errorPolicy?: ErrorPolicy;\n\n /**\n * An object that maps from the name of a variable as used in the mutation\n * GraphQL document to that variable's value.\n */\n variables?: TVariables;\n\n /**\n * The context to be passed to the link execution chain. This context will\n * only be used with this mutation. It will not be used with\n * `refetchQueries`. Refetched queries use the context they were\n * initialized with (since the initial context is stored as part of the\n * `ObservableQuery` instance). If a specific context is needed when\n * refetching queries, make sure it is configured (via the\n * [query `context` option](https://www.apollographql.com/docs/react/api/apollo-client#ApolloClient.query))\n * when the query is first initialized/run.\n */\n context?: TContext;\n}\n\nexport interface MutationOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> extends MutationBaseOptions<TData, TVariables, TContext, TCache> {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single mutation inside of it.\n */\n mutation: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * Specifies the {@link MutationFetchPolicy} to be used for this query.\n * Mutations support only 'network-only' and 'no-cache' fetchPolicy strings.\n * If fetchPolicy is not provided, it defaults to 'network-only'.\n */\n fetchPolicy?: MutationFetchPolicy;\n\n /**\n * To avoid retaining sensitive information from mutation root field\n * arguments, Apollo Client v3.4+ automatically clears any `ROOT_MUTATION`\n * fields from the cache after each mutation finishes. If you need this\n * information to remain in the cache, you can prevent the removal by passing\n * `keepRootFields: true` to the mutation. `ROOT_MUTATION` result data are\n * also passed to the mutation `update` function, so we recommend obtaining\n * the results that way, rather than using this option, if possible.\n */\n keepRootFields?: boolean;\n}\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
require('../utilities/globals');
|
|
7
|
+
var utilities = require('../utilities');
|
|
8
|
+
|
|
9
|
+
function isApolloError(err) {
|
|
10
|
+
return err.hasOwnProperty('graphQLErrors');
|
|
11
|
+
}
|
|
12
|
+
var generateErrorMessage = function (err) {
|
|
13
|
+
var message = '';
|
|
14
|
+
if (utilities.isNonEmptyArray(err.graphQLErrors) || utilities.isNonEmptyArray(err.clientErrors)) {
|
|
15
|
+
var errors = (err.graphQLErrors || [])
|
|
16
|
+
.concat(err.clientErrors || []);
|
|
17
|
+
errors.forEach(function (error) {
|
|
18
|
+
var errorMessage = error
|
|
19
|
+
? error.message
|
|
20
|
+
: 'Error message not found.';
|
|
21
|
+
message += "".concat(errorMessage, "\n");
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (err.networkError) {
|
|
25
|
+
message += "".concat(err.networkError.message, "\n");
|
|
26
|
+
}
|
|
27
|
+
message = message.replace(/\n$/, '');
|
|
28
|
+
return message;
|
|
29
|
+
};
|
|
30
|
+
var ApolloError = (function (_super) {
|
|
31
|
+
tslib.__extends(ApolloError, _super);
|
|
32
|
+
function ApolloError(_a) {
|
|
33
|
+
var graphQLErrors = _a.graphQLErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;
|
|
34
|
+
var _this = _super.call(this, errorMessage) || this;
|
|
35
|
+
_this.graphQLErrors = graphQLErrors || [];
|
|
36
|
+
_this.clientErrors = clientErrors || [];
|
|
37
|
+
_this.networkError = networkError || null;
|
|
38
|
+
_this.message = errorMessage || generateErrorMessage(_this);
|
|
39
|
+
_this.extraInfo = extraInfo;
|
|
40
|
+
_this.__proto__ = ApolloError.prototype;
|
|
41
|
+
return _this;
|
|
42
|
+
}
|
|
43
|
+
return ApolloError;
|
|
44
|
+
}(Error));
|
|
45
|
+
|
|
46
|
+
exports.ApolloError = ApolloError;
|
|
47
|
+
exports.isApolloError = isApolloError;
|
|
48
|
+
//# sourceMappingURL=errors.cjs.map
|
package/invariantErrorCodes.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// consult the @apollo/client/invariantErrorCodes.js file specific to
|
|
6
6
|
// your @apollo/client version. This file is not meant to be imported.
|
|
7
7
|
{
|
|
8
|
-
"@apollo/client version": "3.
|
|
8
|
+
"@apollo/client version": "3.6.9",
|
|
9
9
|
|
|
10
10
|
1: {
|
|
11
11
|
file: "@apollo/client/cache/inmemory/entityStore.js",
|
package/link/batch/batch.cjs
CHANGED
|
@@ -9,7 +9,7 @@ var utilities = require('../../utilities');
|
|
|
9
9
|
var OperationBatcher = (function () {
|
|
10
10
|
function OperationBatcher(_a) {
|
|
11
11
|
var batchDebounce = _a.batchDebounce, batchInterval = _a.batchInterval, batchMax = _a.batchMax, batchHandler = _a.batchHandler, batchKey = _a.batchKey;
|
|
12
|
-
this.
|
|
12
|
+
this.batchesByKey = new Map();
|
|
13
13
|
this.batchDebounce = batchDebounce;
|
|
14
14
|
this.batchInterval = batchInterval;
|
|
15
15
|
this.batchMax = batchMax || 0;
|
|
@@ -18,61 +18,74 @@ var OperationBatcher = (function () {
|
|
|
18
18
|
}
|
|
19
19
|
OperationBatcher.prototype.enqueueRequest = function (request) {
|
|
20
20
|
var _this = this;
|
|
21
|
-
var requestCopy = tslib.__assign({}, request);
|
|
22
|
-
var queued = false;
|
|
21
|
+
var requestCopy = tslib.__assign(tslib.__assign({}, request), { next: [], error: [], complete: [], subscribers: new Set() });
|
|
23
22
|
var key = this.batchKey(request.operation);
|
|
24
23
|
if (!requestCopy.observable) {
|
|
25
24
|
requestCopy.observable = new utilities.Observable(function (observer) {
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
var batch = _this.batchesByKey.get(key);
|
|
26
|
+
if (!batch)
|
|
27
|
+
_this.batchesByKey.set(key, batch = new Set());
|
|
28
|
+
var isFirstEnqueuedRequest = batch.size === 0;
|
|
29
|
+
var isFirstSubscriber = requestCopy.subscribers.size === 0;
|
|
30
|
+
requestCopy.subscribers.add(observer);
|
|
31
|
+
if (isFirstSubscriber) {
|
|
32
|
+
batch.add(requestCopy);
|
|
28
33
|
}
|
|
29
|
-
if (
|
|
30
|
-
_this.queuedRequests.get(key).push(requestCopy);
|
|
31
|
-
queued = true;
|
|
32
|
-
}
|
|
33
|
-
requestCopy.next = requestCopy.next || [];
|
|
34
|
-
if (observer.next)
|
|
34
|
+
if (observer.next) {
|
|
35
35
|
requestCopy.next.push(observer.next.bind(observer));
|
|
36
|
-
|
|
37
|
-
if (observer.error)
|
|
36
|
+
}
|
|
37
|
+
if (observer.error) {
|
|
38
38
|
requestCopy.error.push(observer.error.bind(observer));
|
|
39
|
-
|
|
40
|
-
if (observer.complete)
|
|
39
|
+
}
|
|
40
|
+
if (observer.complete) {
|
|
41
41
|
requestCopy.complete.push(observer.complete.bind(observer));
|
|
42
|
-
|
|
42
|
+
}
|
|
43
|
+
if (isFirstEnqueuedRequest) {
|
|
43
44
|
_this.scheduleQueueConsumption(key);
|
|
44
45
|
}
|
|
45
46
|
else if (_this.batchDebounce) {
|
|
46
47
|
clearTimeout(_this.scheduledBatchTimer);
|
|
47
48
|
_this.scheduleQueueConsumption(key);
|
|
48
49
|
}
|
|
49
|
-
if (
|
|
50
|
+
if (batch.size === _this.batchMax) {
|
|
50
51
|
_this.consumeQueue(key);
|
|
51
52
|
}
|
|
53
|
+
return function () {
|
|
54
|
+
var _a;
|
|
55
|
+
if (requestCopy.subscribers.delete(observer) &&
|
|
56
|
+
requestCopy.subscribers.size < 1) {
|
|
57
|
+
if (batch.delete(requestCopy) && batch.size < 1) {
|
|
58
|
+
_this.consumeQueue(key);
|
|
59
|
+
(_a = batch.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
52
63
|
});
|
|
53
64
|
}
|
|
54
65
|
return requestCopy.observable;
|
|
55
66
|
};
|
|
56
67
|
OperationBatcher.prototype.consumeQueue = function (key) {
|
|
57
|
-
|
|
58
|
-
var
|
|
59
|
-
|
|
68
|
+
if (key === void 0) { key = ''; }
|
|
69
|
+
var batch = this.batchesByKey.get(key);
|
|
70
|
+
this.batchesByKey.delete(key);
|
|
71
|
+
if (!batch || !batch.size) {
|
|
60
72
|
return;
|
|
61
73
|
}
|
|
62
|
-
|
|
63
|
-
var
|
|
64
|
-
var forwards = queuedRequests.map(function (queuedRequest) { return queuedRequest.forward; });
|
|
74
|
+
var operations = [];
|
|
75
|
+
var forwards = [];
|
|
65
76
|
var observables = [];
|
|
66
77
|
var nexts = [];
|
|
67
78
|
var errors = [];
|
|
68
79
|
var completes = [];
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
batch.forEach(function (request) {
|
|
81
|
+
operations.push(request.operation);
|
|
82
|
+
forwards.push(request.forward);
|
|
83
|
+
observables.push(request.observable);
|
|
84
|
+
nexts.push(request.next);
|
|
85
|
+
errors.push(request.error);
|
|
86
|
+
completes.push(request.complete);
|
|
74
87
|
});
|
|
75
|
-
var batchedObservable = this.batchHandler(
|
|
88
|
+
var batchedObservable = this.batchHandler(operations, forwards) || utilities.Observable.of();
|
|
76
89
|
var onError = function (error) {
|
|
77
90
|
errors.forEach(function (rejecters) {
|
|
78
91
|
if (rejecters) {
|
|
@@ -80,7 +93,7 @@ var OperationBatcher = (function () {
|
|
|
80
93
|
}
|
|
81
94
|
});
|
|
82
95
|
};
|
|
83
|
-
batchedObservable.subscribe({
|
|
96
|
+
batch.subscription = batchedObservable.subscribe({
|
|
84
97
|
next: function (results) {
|
|
85
98
|
if (!Array.isArray(results)) {
|
|
86
99
|
results = [results];
|
|
@@ -109,13 +122,9 @@ var OperationBatcher = (function () {
|
|
|
109
122
|
};
|
|
110
123
|
OperationBatcher.prototype.scheduleQueueConsumption = function (key) {
|
|
111
124
|
var _this = this;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
_this.queuedRequests.get(requestKey).length) {
|
|
116
|
-
_this.consumeQueue(requestKey);
|
|
117
|
-
}
|
|
118
|
-
}, this.batchInterval));
|
|
125
|
+
this.scheduledBatchTimer = setTimeout(function () {
|
|
126
|
+
_this.consumeQueue(key);
|
|
127
|
+
}, this.batchInterval);
|
|
119
128
|
};
|
|
120
129
|
return OperationBatcher;
|
|
121
130
|
}());
|
package/link/batch/batch.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch.cjs","sources":["batching.js","batchLink.js"],"sourcesContent":["import { __assign } from \"tslib\";\nimport { Observable } from '../../utilities';\nvar OperationBatcher = (function () {\n function OperationBatcher(_a) {\n var batchDebounce = _a.batchDebounce, batchInterval = _a.batchInterval, batchMax = _a.batchMax, batchHandler = _a.batchHandler, batchKey = _a.batchKey;\n this.queuedRequests = new Map();\n this.batchDebounce = batchDebounce;\n this.batchInterval = batchInterval;\n this.batchMax = batchMax || 0;\n this.batchHandler = batchHandler;\n this.batchKey = batchKey || (function () { return ''; });\n }\n OperationBatcher.prototype.enqueueRequest = function (request) {\n var _this = this;\n var requestCopy = __assign({}, request);\n var queued = false;\n var key = this.batchKey(request.operation);\n if (!requestCopy.observable) {\n requestCopy.observable = new Observable(function (observer) {\n if (!_this.queuedRequests.has(key)) {\n _this.queuedRequests.set(key, []);\n }\n if (!queued) {\n _this.queuedRequests.get(key).push(requestCopy);\n queued = true;\n }\n requestCopy.next = requestCopy.next || [];\n if (observer.next)\n requestCopy.next.push(observer.next.bind(observer));\n requestCopy.error = requestCopy.error || [];\n if (observer.error)\n requestCopy.error.push(observer.error.bind(observer));\n requestCopy.complete = requestCopy.complete || [];\n if (observer.complete)\n requestCopy.complete.push(observer.complete.bind(observer));\n if (_this.queuedRequests.get(key).length === 1) {\n _this.scheduleQueueConsumption(key);\n }\n else if (_this.batchDebounce) {\n clearTimeout(_this.scheduledBatchTimer);\n _this.scheduleQueueConsumption(key);\n }\n if (_this.queuedRequests.get(key).length === _this.batchMax) {\n _this.consumeQueue(key);\n }\n });\n }\n return requestCopy.observable;\n };\n OperationBatcher.prototype.consumeQueue = function (key) {\n var requestKey = key || '';\n var queuedRequests = this.queuedRequests.get(requestKey);\n if (!queuedRequests) {\n return;\n }\n this.queuedRequests.delete(requestKey);\n var requests = queuedRequests.map(function (queuedRequest) { return queuedRequest.operation; });\n var forwards = queuedRequests.map(function (queuedRequest) { return queuedRequest.forward; });\n var observables = [];\n var nexts = [];\n var errors = [];\n var completes = [];\n queuedRequests.forEach(function (batchableRequest, index) {\n observables.push(batchableRequest.observable);\n nexts.push(batchableRequest.next);\n errors.push(batchableRequest.error);\n completes.push(batchableRequest.complete);\n });\n var batchedObservable = this.batchHandler(requests, forwards) || Observable.of();\n var onError = function (error) {\n errors.forEach(function (rejecters) {\n if (rejecters) {\n rejecters.forEach(function (e) { return e(error); });\n }\n });\n };\n batchedObservable.subscribe({\n next: function (results) {\n if (!Array.isArray(results)) {\n results = [results];\n }\n if (nexts.length !== results.length) {\n var error = new Error(\"server returned results with length \".concat(results.length, \", expected length of \").concat(nexts.length));\n error.result = results;\n return onError(error);\n }\n results.forEach(function (result, index) {\n if (nexts[index]) {\n nexts[index].forEach(function (next) { return next(result); });\n }\n });\n },\n error: onError,\n complete: function () {\n completes.forEach(function (complete) {\n if (complete) {\n complete.forEach(function (c) { return c(); });\n }\n });\n },\n });\n return observables;\n };\n OperationBatcher.prototype.scheduleQueueConsumption = function (key) {\n var _this = this;\n var requestKey = key || '';\n this.scheduledBatchTimer = (setTimeout(function () {\n if (_this.queuedRequests.get(requestKey) &&\n _this.queuedRequests.get(requestKey).length) {\n _this.consumeQueue(requestKey);\n }\n }, this.batchInterval));\n };\n return OperationBatcher;\n}());\nexport { OperationBatcher };\n//# sourceMappingURL=batching.js.map","import { __extends } from \"tslib\";\nimport { ApolloLink } from '../core';\nimport { OperationBatcher } from './batching';\nexport { OperationBatcher } from './batching';\nvar BatchLink = (function (_super) {\n __extends(BatchLink, _super);\n function BatchLink(fetchParams) {\n var _this = _super.call(this) || this;\n var _a = fetchParams || {}, batchDebounce = _a.batchDebounce, _b = _a.batchInterval, batchInterval = _b === void 0 ? 10 : _b, _c = _a.batchMax, batchMax = _c === void 0 ? 0 : _c, _d = _a.batchHandler, batchHandler = _d === void 0 ? function () { return null; } : _d, _e = _a.batchKey, batchKey = _e === void 0 ? function () { return ''; } : _e;\n _this.batcher = new OperationBatcher({\n batchDebounce: batchDebounce,\n batchInterval: batchInterval,\n batchMax: batchMax,\n batchHandler: batchHandler,\n batchKey: batchKey,\n });\n if (fetchParams.batchHandler.length <= 1) {\n _this.request = function (operation) { return _this.batcher.enqueueRequest({ operation: operation }); };\n }\n return _this;\n }\n BatchLink.prototype.request = function (operation, forward) {\n return this.batcher.enqueueRequest({\n operation: operation,\n forward: forward,\n });\n };\n return BatchLink;\n}(ApolloLink));\nexport { BatchLink };\n//# sourceMappingURL=batchLink.js.map"],"names":["__assign","Observable","__extends","ApolloLink"],"mappings":";;;;;;;;AAEG,IAAC,gBAAgB,IAAI,YAAY;AACpC,IAAI,SAAS,gBAAgB,CAAC,EAAE,EAAE;AAClC,QAAQ,IAAI,aAAa,GAAG,EAAE,CAAC,aAAa,EAAE,aAAa,GAAG,EAAE,CAAC,aAAa,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,YAAY,GAAG,EAAE,CAA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,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;AAC3C,YAAY,SAAS,EAAE,SAAS;AAChC,YAAY,OAAO,EAAE,OAAO;AAC5B,SAAS,CAAC,CAAC;AACX,KAAK,CAAC;AACN,IAAI,OAAO,SAAS,CAAC;AACrB,CAAC,CAACC,eAAU,CAAC;;;;;"}
|
|
1
|
+
{"version":3,"file":"batch.cjs","sources":["batching.js","batchLink.js"],"sourcesContent":["import { __assign } from \"tslib\";\nimport { Observable } from '../../utilities';\nvar OperationBatcher = (function () {\n function OperationBatcher(_a) {\n var batchDebounce = _a.batchDebounce, batchInterval = _a.batchInterval, batchMax = _a.batchMax, batchHandler = _a.batchHandler, batchKey = _a.batchKey;\n this.batchesByKey = new Map();\n this.batchDebounce = batchDebounce;\n this.batchInterval = batchInterval;\n this.batchMax = batchMax || 0;\n this.batchHandler = batchHandler;\n this.batchKey = batchKey || (function () { return ''; });\n }\n OperationBatcher.prototype.enqueueRequest = function (request) {\n var _this = this;\n var requestCopy = __assign(__assign({}, request), { next: [], error: [], complete: [], subscribers: new Set() });\n var key = this.batchKey(request.operation);\n if (!requestCopy.observable) {\n requestCopy.observable = new Observable(function (observer) {\n var batch = _this.batchesByKey.get(key);\n if (!batch)\n _this.batchesByKey.set(key, batch = new Set());\n var isFirstEnqueuedRequest = batch.size === 0;\n var isFirstSubscriber = requestCopy.subscribers.size === 0;\n requestCopy.subscribers.add(observer);\n if (isFirstSubscriber) {\n batch.add(requestCopy);\n }\n if (observer.next) {\n requestCopy.next.push(observer.next.bind(observer));\n }\n if (observer.error) {\n requestCopy.error.push(observer.error.bind(observer));\n }\n if (observer.complete) {\n requestCopy.complete.push(observer.complete.bind(observer));\n }\n if (isFirstEnqueuedRequest) {\n _this.scheduleQueueConsumption(key);\n }\n else if (_this.batchDebounce) {\n clearTimeout(_this.scheduledBatchTimer);\n _this.scheduleQueueConsumption(key);\n }\n if (batch.size === _this.batchMax) {\n _this.consumeQueue(key);\n }\n return function () {\n var _a;\n if (requestCopy.subscribers.delete(observer) &&\n requestCopy.subscribers.size < 1) {\n if (batch.delete(requestCopy) && batch.size < 1) {\n _this.consumeQueue(key);\n (_a = batch.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();\n }\n }\n };\n });\n }\n return requestCopy.observable;\n };\n OperationBatcher.prototype.consumeQueue = function (key) {\n if (key === void 0) { key = ''; }\n var batch = this.batchesByKey.get(key);\n this.batchesByKey.delete(key);\n if (!batch || !batch.size) {\n return;\n }\n var operations = [];\n var forwards = [];\n var observables = [];\n var nexts = [];\n var errors = [];\n var completes = [];\n batch.forEach(function (request) {\n operations.push(request.operation);\n forwards.push(request.forward);\n observables.push(request.observable);\n nexts.push(request.next);\n errors.push(request.error);\n completes.push(request.complete);\n });\n var batchedObservable = this.batchHandler(operations, forwards) || Observable.of();\n var onError = function (error) {\n errors.forEach(function (rejecters) {\n if (rejecters) {\n rejecters.forEach(function (e) { return e(error); });\n }\n });\n };\n batch.subscription = batchedObservable.subscribe({\n next: function (results) {\n if (!Array.isArray(results)) {\n results = [results];\n }\n if (nexts.length !== results.length) {\n var error = new Error(\"server returned results with length \".concat(results.length, \", expected length of \").concat(nexts.length));\n error.result = results;\n return onError(error);\n }\n results.forEach(function (result, index) {\n if (nexts[index]) {\n nexts[index].forEach(function (next) { return next(result); });\n }\n });\n },\n error: onError,\n complete: function () {\n completes.forEach(function (complete) {\n if (complete) {\n complete.forEach(function (c) { return c(); });\n }\n });\n },\n });\n return observables;\n };\n OperationBatcher.prototype.scheduleQueueConsumption = function (key) {\n var _this = this;\n this.scheduledBatchTimer = setTimeout(function () {\n _this.consumeQueue(key);\n }, this.batchInterval);\n };\n return OperationBatcher;\n}());\nexport { OperationBatcher };\n//# sourceMappingURL=batching.js.map","import { __extends } from \"tslib\";\nimport { ApolloLink } from '../core';\nimport { OperationBatcher } from './batching';\nexport { OperationBatcher } from './batching';\nvar BatchLink = (function (_super) {\n __extends(BatchLink, _super);\n function BatchLink(fetchParams) {\n var _this = _super.call(this) || this;\n var _a = fetchParams || {}, batchDebounce = _a.batchDebounce, _b = _a.batchInterval, batchInterval = _b === void 0 ? 10 : _b, _c = _a.batchMax, batchMax = _c === void 0 ? 0 : _c, _d = _a.batchHandler, batchHandler = _d === void 0 ? function () { return null; } : _d, _e = _a.batchKey, batchKey = _e === void 0 ? function () { return ''; } : _e;\n _this.batcher = new OperationBatcher({\n batchDebounce: batchDebounce,\n batchInterval: batchInterval,\n batchMax: batchMax,\n batchHandler: batchHandler,\n batchKey: batchKey,\n });\n if (fetchParams.batchHandler.length <= 1) {\n _this.request = function (operation) { return _this.batcher.enqueueRequest({ operation: operation }); };\n }\n return _this;\n }\n BatchLink.prototype.request = function (operation, forward) {\n return this.batcher.enqueueRequest({\n operation: operation,\n forward: forward,\n });\n };\n return BatchLink;\n}(ApolloLink));\nexport { BatchLink };\n//# sourceMappingURL=batchLink.js.map"],"names":["__assign","Observable","__extends","ApolloLink"],"mappings":";;;;;;;;AAEG,IAAC,gBAAgB,IAAI,YAAY;AACpC,IAAI,SAAS,gBAAgB,CAAC,EAAE,EAAE;AAClC,QAAQ,IAAI,aAAa,GAAG,EAAE,CAAC,aAAa,EAAE,aAAa,GAAG,EAAE,CAAC,aAAa,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,YAAY,GAAG,EAAE,CAAC,YAAY,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC;AAC/J,QAAQ,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;AACtC,QAAQ,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;AAC3C,QAAQ,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;AAC3C,QAAQ,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,CAAC,CAAC;AACtC,QAAQ,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;AACzC,QAAQ,IAAI,CAAC,QAAQ,GAAG,QAAQ,KAAK,YAAY,EAAE,OAAO,EAAE,CAA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YAAY,SAAS,EAAE,SAAS;AAChC,YAAY,OAAO,EAAE,OAAO;AAC5B,SAAS,CAAC,CAAC;AACX,KAAK,CAAC;AACN,IAAI,OAAO,SAAS,CAAC;AACrB,CAAC,CAACC,eAAU,CAAC;;;;;"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var core = require('../core');
|
|
7
|
+
var utilities = require('../../utilities');
|
|
8
|
+
|
|
9
|
+
var OperationBatcher = (function () {
|
|
10
|
+
function OperationBatcher(_a) {
|
|
11
|
+
var batchDebounce = _a.batchDebounce, batchInterval = _a.batchInterval, batchMax = _a.batchMax, batchHandler = _a.batchHandler, batchKey = _a.batchKey;
|
|
12
|
+
this.batchesByKey = new Map();
|
|
13
|
+
this.batchDebounce = batchDebounce;
|
|
14
|
+
this.batchInterval = batchInterval;
|
|
15
|
+
this.batchMax = batchMax || 0;
|
|
16
|
+
this.batchHandler = batchHandler;
|
|
17
|
+
this.batchKey = batchKey || (function () { return ''; });
|
|
18
|
+
}
|
|
19
|
+
OperationBatcher.prototype.enqueueRequest = function (request) {
|
|
20
|
+
var _this = this;
|
|
21
|
+
var requestCopy = tslib.__assign(tslib.__assign({}, request), { next: [], error: [], complete: [], subscribers: new Set() });
|
|
22
|
+
var key = this.batchKey(request.operation);
|
|
23
|
+
if (!requestCopy.observable) {
|
|
24
|
+
requestCopy.observable = new utilities.Observable(function (observer) {
|
|
25
|
+
var batch = _this.batchesByKey.get(key);
|
|
26
|
+
if (!batch)
|
|
27
|
+
_this.batchesByKey.set(key, batch = new Set());
|
|
28
|
+
var isFirstEnqueuedRequest = batch.size === 0;
|
|
29
|
+
var isFirstSubscriber = requestCopy.subscribers.size === 0;
|
|
30
|
+
requestCopy.subscribers.add(observer);
|
|
31
|
+
if (isFirstSubscriber) {
|
|
32
|
+
batch.add(requestCopy);
|
|
33
|
+
}
|
|
34
|
+
if (observer.next) {
|
|
35
|
+
requestCopy.next.push(observer.next.bind(observer));
|
|
36
|
+
}
|
|
37
|
+
if (observer.error) {
|
|
38
|
+
requestCopy.error.push(observer.error.bind(observer));
|
|
39
|
+
}
|
|
40
|
+
if (observer.complete) {
|
|
41
|
+
requestCopy.complete.push(observer.complete.bind(observer));
|
|
42
|
+
}
|
|
43
|
+
if (isFirstEnqueuedRequest) {
|
|
44
|
+
_this.scheduleQueueConsumption(key);
|
|
45
|
+
}
|
|
46
|
+
else if (_this.batchDebounce) {
|
|
47
|
+
clearTimeout(_this.scheduledBatchTimer);
|
|
48
|
+
_this.scheduleQueueConsumption(key);
|
|
49
|
+
}
|
|
50
|
+
if (batch.size === _this.batchMax) {
|
|
51
|
+
_this.consumeQueue(key);
|
|
52
|
+
}
|
|
53
|
+
return function () {
|
|
54
|
+
var _a;
|
|
55
|
+
if (requestCopy.subscribers.delete(observer) &&
|
|
56
|
+
requestCopy.subscribers.size < 1) {
|
|
57
|
+
if (batch.delete(requestCopy) && batch.size < 1) {
|
|
58
|
+
_this.consumeQueue(key);
|
|
59
|
+
(_a = batch.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return requestCopy.observable;
|
|
66
|
+
};
|
|
67
|
+
OperationBatcher.prototype.consumeQueue = function (key) {
|
|
68
|
+
if (key === void 0) { key = ''; }
|
|
69
|
+
var batch = this.batchesByKey.get(key);
|
|
70
|
+
this.batchesByKey.delete(key);
|
|
71
|
+
if (!batch || !batch.size) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
var operations = [];
|
|
75
|
+
var forwards = [];
|
|
76
|
+
var observables = [];
|
|
77
|
+
var nexts = [];
|
|
78
|
+
var errors = [];
|
|
79
|
+
var completes = [];
|
|
80
|
+
batch.forEach(function (request) {
|
|
81
|
+
operations.push(request.operation);
|
|
82
|
+
forwards.push(request.forward);
|
|
83
|
+
observables.push(request.observable);
|
|
84
|
+
nexts.push(request.next);
|
|
85
|
+
errors.push(request.error);
|
|
86
|
+
completes.push(request.complete);
|
|
87
|
+
});
|
|
88
|
+
var batchedObservable = this.batchHandler(operations, forwards) || utilities.Observable.of();
|
|
89
|
+
var onError = function (error) {
|
|
90
|
+
errors.forEach(function (rejecters) {
|
|
91
|
+
if (rejecters) {
|
|
92
|
+
rejecters.forEach(function (e) { return e(error); });
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
batch.subscription = batchedObservable.subscribe({
|
|
97
|
+
next: function (results) {
|
|
98
|
+
if (!Array.isArray(results)) {
|
|
99
|
+
results = [results];
|
|
100
|
+
}
|
|
101
|
+
if (nexts.length !== results.length) {
|
|
102
|
+
var error = new Error("server returned results with length ".concat(results.length, ", expected length of ").concat(nexts.length));
|
|
103
|
+
error.result = results;
|
|
104
|
+
return onError(error);
|
|
105
|
+
}
|
|
106
|
+
results.forEach(function (result, index) {
|
|
107
|
+
if (nexts[index]) {
|
|
108
|
+
nexts[index].forEach(function (next) { return next(result); });
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
error: onError,
|
|
113
|
+
complete: function () {
|
|
114
|
+
completes.forEach(function (complete) {
|
|
115
|
+
if (complete) {
|
|
116
|
+
complete.forEach(function (c) { return c(); });
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
return observables;
|
|
122
|
+
};
|
|
123
|
+
OperationBatcher.prototype.scheduleQueueConsumption = function (key) {
|
|
124
|
+
var _this = this;
|
|
125
|
+
this.scheduledBatchTimer = setTimeout(function () {
|
|
126
|
+
_this.consumeQueue(key);
|
|
127
|
+
}, this.batchInterval);
|
|
128
|
+
};
|
|
129
|
+
return OperationBatcher;
|
|
130
|
+
}());
|
|
131
|
+
|
|
132
|
+
var BatchLink = (function (_super) {
|
|
133
|
+
tslib.__extends(BatchLink, _super);
|
|
134
|
+
function BatchLink(fetchParams) {
|
|
135
|
+
var _this = _super.call(this) || this;
|
|
136
|
+
var _a = fetchParams || {}, batchDebounce = _a.batchDebounce, _b = _a.batchInterval, batchInterval = _b === void 0 ? 10 : _b, _c = _a.batchMax, batchMax = _c === void 0 ? 0 : _c, _d = _a.batchHandler, batchHandler = _d === void 0 ? function () { return null; } : _d, _e = _a.batchKey, batchKey = _e === void 0 ? function () { return ''; } : _e;
|
|
137
|
+
_this.batcher = new OperationBatcher({
|
|
138
|
+
batchDebounce: batchDebounce,
|
|
139
|
+
batchInterval: batchInterval,
|
|
140
|
+
batchMax: batchMax,
|
|
141
|
+
batchHandler: batchHandler,
|
|
142
|
+
batchKey: batchKey,
|
|
143
|
+
});
|
|
144
|
+
if (fetchParams.batchHandler.length <= 1) {
|
|
145
|
+
_this.request = function (operation) { return _this.batcher.enqueueRequest({ operation: operation }); };
|
|
146
|
+
}
|
|
147
|
+
return _this;
|
|
148
|
+
}
|
|
149
|
+
BatchLink.prototype.request = function (operation, forward) {
|
|
150
|
+
return this.batcher.enqueueRequest({
|
|
151
|
+
operation: operation,
|
|
152
|
+
forward: forward,
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
return BatchLink;
|
|
156
|
+
}(core.ApolloLink));
|
|
157
|
+
|
|
158
|
+
exports.BatchLink = BatchLink;
|
|
159
|
+
exports.OperationBatcher = OperationBatcher;
|
|
160
|
+
//# sourceMappingURL=batch.cjs.map
|
package/link/batch/batching.d.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FetchResult, NextLink, Operation } from '../core';
|
|
2
2
|
import { Observable } from '../../utilities';
|
|
3
3
|
export declare type BatchHandler = (operations: Operation[], forward?: (NextLink | undefined)[]) => Observable<FetchResult[]> | null;
|
|
4
4
|
export interface BatchableRequest {
|
|
5
5
|
operation: Operation;
|
|
6
6
|
forward?: NextLink;
|
|
7
|
-
observable?: Observable<FetchResult>;
|
|
8
|
-
next?: Array<(result: FetchResult) => void>;
|
|
9
|
-
error?: Array<(error: Error) => void>;
|
|
10
|
-
complete?: Array<() => void>;
|
|
11
7
|
}
|
|
12
8
|
export declare class OperationBatcher {
|
|
13
|
-
|
|
9
|
+
private batchesByKey;
|
|
14
10
|
private scheduledBatchTimer;
|
|
15
11
|
private batchDebounce?;
|
|
16
12
|
private batchInterval?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batching.d.ts","sourceRoot":"","sources":["../../../src/link/batch/batching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"batching.d.ts","sourceRoot":"","sources":["../../../src/link/batch/batching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AAErE,oBAAY,YAAY,GAAG,CACzB,UAAU,EAAE,SAAS,EAAE,EACvB,OAAO,CAAC,EAAE,CAAC,QAAQ,GAAG,SAAS,CAAC,EAAE,KAC/B,UAAU,CAAC,WAAW,EAAE,CAAC,GAAG,IAAI,CAAC;AAEtC,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB;AAmBD,qBAAa,gBAAgB;IAE3B,OAAO,CAAC,YAAY,CAAmC;IAEvD,OAAO,CAAC,mBAAmB,CAAgC;IAC3D,OAAO,CAAC,aAAa,CAAC,CAAU;IAChC,OAAO,CAAC,aAAa,CAAC,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAS;IAGzB,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAmC;gBAEvC,EACV,aAAa,EACb,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,QAAQ,GACT,EAAE;Q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