@apollo/client 3.8.0-alpha.1 → 3.8.0-alpha.10
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/README.md +3 -1
- package/apollo-client.cjs +471 -291
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +54 -44
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +54 -44
- package/cache/core/cache.d.ts +1 -1
- package/cache/core/cache.d.ts.map +1 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +3 -2
- package/cache/core/types/DataProxy.d.ts.map +1 -1
- package/cache/core/types/DataProxy.js.map +1 -1
- package/cache/core/types/common.d.ts +7 -7
- package/cache/core/types/common.d.ts.map +1 -1
- package/cache/inmemory/entityStore.d.ts +1 -1
- package/cache/inmemory/entityStore.d.ts.map +1 -1
- package/cache/inmemory/entityStore.js +1 -1
- package/cache/inmemory/helpers.d.ts +2 -2
- package/cache/inmemory/helpers.d.ts.map +1 -1
- package/cache/inmemory/helpers.js +2 -2
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +3 -2
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js +1 -1
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/object-canon.d.ts +0 -1
- package/cache/inmemory/object-canon.d.ts.map +1 -1
- package/cache/inmemory/object-canon.js +1 -1
- package/cache/inmemory/object-canon.js.map +1 -1
- package/cache/inmemory/policies.d.ts +12 -12
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +15 -4
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/reactiveVars.d.ts +1 -1
- package/cache/inmemory/reactiveVars.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +2 -2
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +1 -1
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +4 -4
- package/cache/inmemory/types.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +1 -1
- package/cache/inmemory/writeToStore.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.js +1 -1
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts +10 -9
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +11 -5
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.d.ts +12 -7
- package/core/LocalState.d.ts.map +1 -1
- package/core/LocalState.js +71 -17
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts +5 -5
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +2 -2
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +1 -1
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js +1 -1
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +7 -7
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +22 -12
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +132 -69
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +132 -69
- package/core/index.js +2 -2
- package/core/index.js.map +1 -1
- package/core/types.d.ts +21 -17
- package/core/types.d.ts.map +1 -1
- package/core/types.js +1 -0
- package/core/types.js.map +1 -1
- package/core/watchQueryOptions.d.ts +11 -11
- package/core/watchQueryOptions.d.ts.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/errors/index.d.ts +2 -2
- package/errors/index.d.ts.map +1 -1
- package/invariantErrorCodes.js +36 -35
- package/link/batch/batch.cjs +5 -3
- package/link/batch/batch.cjs.map +1 -1
- package/link/batch/batch.cjs.native.js +5 -3
- package/link/batch/batching.d.ts +2 -2
- package/link/batch/batching.d.ts.map +1 -1
- package/link/batch/batching.js +5 -3
- package/link/batch/batching.js.map +1 -1
- package/link/batch-http/batch-http.cjs +12 -2
- package/link/batch-http/batch-http.cjs.map +1 -1
- package/link/batch-http/batch-http.cjs.native.js +12 -2
- package/link/batch-http/batchHttpLink.d.ts.map +1 -1
- package/link/batch-http/batchHttpLink.js +13 -3
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/context/index.d.ts +2 -1
- package/link/context/index.d.ts.map +1 -1
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.js +2 -2
- package/link/core/core.cjs +2 -2
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +2 -2
- package/link/core/types.d.ts +15 -15
- package/link/core/types.d.ts.map +1 -1
- package/link/core/types.js.map +1 -1
- package/link/http/checkFetcher.js +2 -2
- package/link/http/createHttpLink.d.ts +0 -1
- package/link/http/createHttpLink.d.ts.map +1 -1
- package/link/http/createHttpLink.js +10 -2
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/http.cjs +20 -38
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +20 -38
- package/link/http/iterators/async.js.map +1 -1
- package/link/http/iterators/nodeStream.js.map +1 -1
- package/link/http/iterators/promise.js.map +1 -1
- package/link/http/iterators/reader.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.d.ts +2 -2
- package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/responseIterator.js +1 -1
- package/link/http/responseIterator.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +2 -2
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
- package/link/http/selectHttpOptionsAndBody.js +3 -1
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/serializeFetchParameter.d.ts +1 -1
- package/link/http/serializeFetchParameter.d.ts.map +1 -1
- package/link/http/serializeFetchParameter.js +2 -2
- package/link/persisted-queries/index.d.ts +2 -2
- package/link/persisted-queries/index.d.ts.map +1 -1
- package/link/persisted-queries/index.js +3 -3
- package/link/persisted-queries/persisted-queries.cjs +3 -3
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +3 -3
- package/link/utils/throwServerError.d.ts +1 -1
- package/link/utils/throwServerError.d.ts.map +1 -1
- package/link/utils/toPromise.js +1 -1
- package/link/utils/utils.cjs +2 -2
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +2 -2
- package/link/utils/validateOperation.js +2 -2
- package/package.json +25 -23
- package/react/cache/SuspenseCache.d.ts +1 -1
- package/react/cache/SuspenseCache.d.ts.map +1 -1
- package/react/cache/SuspenseCache.js.map +1 -1
- package/react/components/Query.d.ts +2 -2
- package/react/components/Query.d.ts.map +1 -1
- package/react/components/Query.js.map +1 -1
- package/react/components/Subscription.d.ts +2 -2
- package/react/components/Subscription.d.ts.map +1 -1
- package/react/components/Subscription.js.map +1 -1
- package/react/components/types.d.ts +2 -2
- package/react/components/types.d.ts.map +1 -1
- package/react/components/types.js.map +1 -1
- 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 +4 -4
- package/react/hoc/graphql.d.ts +2 -1
- package/react/hoc/graphql.d.ts.map +1 -1
- package/react/hoc/graphql.js.map +1 -1
- package/react/hoc/hoc-utils.d.ts +1 -1
- package/react/hoc/hoc-utils.d.ts.map +1 -1
- package/react/hoc/hoc-utils.js +2 -2
- package/react/hoc/hoc.cjs +4 -4
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +4 -4
- package/react/hoc/mutation-hoc.d.ts +2 -2
- package/react/hoc/mutation-hoc.d.ts.map +1 -1
- package/react/hoc/mutation-hoc.js.map +1 -1
- package/react/hoc/query-hoc.d.ts +1 -1
- package/react/hoc/query-hoc.d.ts.map +1 -1
- package/react/hoc/query-hoc.js.map +1 -1
- package/react/hoc/subscription-hoc.d.ts +1 -1
- package/react/hoc/subscription-hoc.d.ts.map +1 -1
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/hoc/types.d.ts +6 -6
- package/react/hoc/types.d.ts.map +1 -1
- package/react/hoc/types.js.map +1 -1
- package/react/hoc/withApollo.js +2 -2
- package/react/hooks/hooks.cjs +129 -69
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +129 -69
- package/react/hooks/internal/index.d.ts +1 -0
- package/react/hooks/internal/index.d.ts.map +1 -1
- package/react/hooks/internal/index.js +1 -0
- package/react/hooks/internal/index.js.map +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts +3 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +1 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.js +6 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -0
- package/react/hooks/useApolloClient.js +2 -2
- package/react/hooks/useFragment.d.ts +4 -2
- package/react/hooks/useFragment.d.ts.map +1 -1
- package/react/hooks/useFragment.js +9 -8
- package/react/hooks/useFragment.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 +22 -8
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +2 -2
- package/react/hooks/useMutation.d.ts.map +1 -1
- package/react/hooks/useMutation.js +9 -8
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +6 -5
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +21 -7
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +2 -3
- package/react/hooks/useSubscription.d.ts.map +1 -1
- package/react/hooks/useSubscription.js +1 -2
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseCache.d.ts +2 -1
- package/react/hooks/useSuspenseCache.d.ts.map +1 -1
- package/react/hooks/useSuspenseCache.js +7 -5
- package/react/hooks/useSuspenseCache.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +11 -4
- package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
- package/react/hooks/useSuspenseQuery.js +54 -30
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.d.ts +1 -1
- package/react/hooks/useSyncExternalStore.d.ts.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/hooks/useSyncExternalStore.js.map +1 -1
- package/react/parser/index.js +6 -6
- package/react/parser/parser.cjs +10 -10
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +10 -10
- package/react/ssr/RenderPromises.d.ts +4 -4
- package/react/ssr/RenderPromises.d.ts.map +1 -1
- package/react/ssr/RenderPromises.js.map +1 -1
- package/react/ssr/getDataFromTree.d.ts +1 -1
- package/react/ssr/getDataFromTree.d.ts.map +1 -1
- package/react/types/types.d.ts +26 -23
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +30 -3
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +30 -3
- package/testing/core/index.d.ts +2 -1
- package/testing/core/index.d.ts.map +1 -1
- package/testing/core/index.js +1 -0
- package/testing/core/index.js.map +1 -1
- package/testing/core/itAsync.js.map +1 -1
- package/testing/core/mocking/mockFetch.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +8 -4
- package/testing/core/mocking/mockLink.d.ts.map +1 -1
- package/testing/core/mocking/mockLink.js +14 -4
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/mocking/mockQueryManager.d.ts +1 -1
- package/testing/core/mocking/mockQueryManager.d.ts.map +1 -1
- package/testing/core/mocking/mockQueryManager.js +3 -3
- package/testing/core/mocking/mockQueryManager.js.map +1 -1
- package/testing/core/mocking/mockWatchQuery.d.ts +1 -1
- package/testing/core/mocking/mockWatchQuery.d.ts.map +1 -1
- package/testing/core/mocking/mockWatchQuery.js +4 -5
- package/testing/core/mocking/mockWatchQuery.js.map +1 -1
- package/testing/core/observableToPromise.d.ts +2 -2
- package/testing/core/observableToPromise.d.ts.map +1 -1
- package/testing/core/observableToPromise.js.map +1 -1
- package/testing/core/wait.d.ts +3 -0
- package/testing/core/wait.d.ts.map +1 -0
- package/testing/core/wait.js +16 -0
- package/testing/core/wait.js.map +1 -0
- package/testing/react/MockedProvider.d.ts +1 -0
- package/testing/react/MockedProvider.d.ts.map +1 -1
- package/testing/react/MockedProvider.js +2 -2
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +2 -2
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +2 -2
- package/utilities/common/arrays.d.ts +1 -0
- package/utilities/common/arrays.d.ts.map +1 -1
- package/utilities/common/arrays.js +1 -0
- package/utilities/common/arrays.js.map +1 -1
- package/utilities/common/cloneDeep.js.map +1 -1
- package/utilities/common/errorHandling.d.ts +2 -2
- package/utilities/common/errorHandling.d.ts.map +1 -1
- package/utilities/common/errorHandling.js.map +1 -1
- package/utilities/common/incrementalResult.d.ts +4 -4
- package/utilities/common/incrementalResult.d.ts.map +1 -1
- package/utilities/common/incrementalResult.js.map +1 -1
- package/utilities/common/maybeDeepFreeze.d.ts +0 -1
- package/utilities/common/maybeDeepFreeze.d.ts.map +1 -1
- package/utilities/common/maybeDeepFreeze.js +1 -1
- package/utilities/common/maybeDeepFreeze.js.map +1 -1
- package/utilities/common/mergeDeep.d.ts +2 -2
- package/utilities/common/mergeDeep.d.ts.map +1 -1
- package/utilities/common/mergeOptions.d.ts +3 -3
- package/utilities/common/mergeOptions.d.ts.map +1 -1
- package/utilities/common/mergeOptions.js.map +1 -1
- package/utilities/globals/DEV.d.ts +1 -1
- package/utilities/globals/DEV.d.ts.map +1 -1
- package/utilities/globals/DEV.js +1 -17
- package/utilities/globals/DEV.js.map +1 -1
- package/utilities/globals/global.d.ts +5 -2
- package/utilities/globals/global.d.ts.map +1 -1
- package/utilities/globals/global.js.map +1 -1
- package/utilities/globals/globals.cjs +5 -22
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +5 -22
- package/utilities/globals/index.d.ts +1 -1
- package/utilities/globals/index.d.ts.map +1 -1
- package/utilities/globals/index.js +1 -4
- package/utilities/globals/index.js.map +1 -1
- package/utilities/graphql/directives.d.ts +2 -2
- package/utilities/graphql/directives.d.ts.map +1 -1
- package/utilities/graphql/directives.js +1 -1
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/fragments.d.ts +1 -1
- package/utilities/graphql/fragments.d.ts.map +1 -1
- package/utilities/graphql/fragments.js +1 -1
- package/utilities/graphql/getFromAST.d.ts.map +1 -1
- package/utilities/graphql/getFromAST.js +8 -4
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/graphql/storeUtils.d.ts +3 -3
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.d.ts +9 -9
- package/utilities/graphql/transform.d.ts.map +1 -1
- package/utilities/graphql/transform.js +168 -91
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +2 -0
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +2 -0
- package/utilities/index.js.map +1 -1
- package/utilities/observables/Concast.d.ts +5 -5
- package/utilities/observables/Concast.d.ts.map +1 -1
- package/utilities/observables/Concast.js +2 -2
- package/utilities/observables/Concast.js.map +1 -1
- package/utilities/observables/asyncMap.js.map +1 -1
- package/utilities/policies/pagination.d.ts +7 -7
- package/utilities/policies/pagination.d.ts.map +1 -1
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/types/IsStrictlyAny.d.ts +3 -3
- package/utilities/types/IsStrictlyAny.d.ts.map +1 -1
- package/utilities/utilities.cjs +252 -124
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +252 -124
- package/version.js +1 -1
package/apollo-client.cjs
CHANGED
|
@@ -4,10 +4,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var tsInvariant = require('ts-invariant');
|
|
7
|
+
var process$1 = require('ts-invariant/process');
|
|
8
|
+
var graphql = require('graphql');
|
|
7
9
|
var equality = require('@wry/equality');
|
|
8
10
|
var zenObservableTs = require('zen-observable-ts');
|
|
9
11
|
require('symbol-observable');
|
|
10
|
-
var graphql = require('graphql');
|
|
11
12
|
var optimism = require('optimism');
|
|
12
13
|
var context = require('@wry/context');
|
|
13
14
|
var trie = require('@wry/trie');
|
|
@@ -35,6 +36,23 @@ function maybe(thunk) {
|
|
|
35
36
|
catch (_a) { }
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
var global$1 = (maybe(function () { return globalThis; }) ||
|
|
40
|
+
maybe(function () { return window; }) ||
|
|
41
|
+
maybe(function () { return self; }) ||
|
|
42
|
+
maybe(function () { return global; }) ||
|
|
43
|
+
maybe(function () { return maybe.constructor("return this")(); }));
|
|
44
|
+
|
|
45
|
+
var DEV = ("__DEV__" in global$1
|
|
46
|
+
? Boolean(global$1.__DEV__)
|
|
47
|
+
: maybe(function () { return process.env.NODE_ENV; }) !== "production");
|
|
48
|
+
|
|
49
|
+
function removeTemporaryGlobals() {
|
|
50
|
+
return typeof graphql.Source === "function" ? process$1.remove() : process$1.remove();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
var __DEV__ = DEV;
|
|
54
|
+
removeTemporaryGlobals();
|
|
55
|
+
|
|
38
56
|
function shouldInclude(_a, variables) {
|
|
39
57
|
var directives = _a.directives;
|
|
40
58
|
if (!directives || !directives.length) {
|
|
@@ -380,17 +398,21 @@ function checkDocument(doc) {
|
|
|
380
398
|
}
|
|
381
399
|
function getOperationDefinition(doc) {
|
|
382
400
|
checkDocument(doc);
|
|
383
|
-
return doc.definitions.filter(function (definition) {
|
|
401
|
+
return doc.definitions.filter(function (definition) {
|
|
402
|
+
return definition.kind === 'OperationDefinition';
|
|
403
|
+
})[0];
|
|
384
404
|
}
|
|
385
405
|
function getOperationName(doc) {
|
|
386
406
|
return (doc.definitions
|
|
387
407
|
.filter(function (definition) {
|
|
388
|
-
return definition.kind === 'OperationDefinition' && definition.name;
|
|
408
|
+
return definition.kind === 'OperationDefinition' && !!definition.name;
|
|
389
409
|
})
|
|
390
410
|
.map(function (x) { return x.name.value; })[0] || null);
|
|
391
411
|
}
|
|
392
412
|
function getFragmentDefinitions(doc) {
|
|
393
|
-
return doc.definitions.filter(function (definition) {
|
|
413
|
+
return doc.definitions.filter(function (definition) {
|
|
414
|
+
return definition.kind === 'FragmentDefinition';
|
|
415
|
+
});
|
|
394
416
|
}
|
|
395
417
|
function getQueryDefinition(doc) {
|
|
396
418
|
var queryDef = getOperationDefinition(doc);
|
|
@@ -439,26 +461,20 @@ function getDefaultValues(definition) {
|
|
|
439
461
|
return defaultValues;
|
|
440
462
|
}
|
|
441
463
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
if (test.call(this, elem, i, array)) {
|
|
446
|
-
array[target++] = elem;
|
|
447
|
-
}
|
|
448
|
-
}, context);
|
|
449
|
-
array.length = target;
|
|
450
|
-
return array;
|
|
464
|
+
var isArray = Array.isArray;
|
|
465
|
+
function isNonEmptyArray(value) {
|
|
466
|
+
return Array.isArray(value) && value.length > 0;
|
|
451
467
|
}
|
|
452
468
|
|
|
453
469
|
var TYPENAME_FIELD = {
|
|
454
|
-
kind:
|
|
470
|
+
kind: graphql.Kind.FIELD,
|
|
455
471
|
name: {
|
|
456
|
-
kind:
|
|
472
|
+
kind: graphql.Kind.NAME,
|
|
457
473
|
value: '__typename',
|
|
458
474
|
},
|
|
459
475
|
};
|
|
460
476
|
function isEmpty(op, fragmentMap) {
|
|
461
|
-
return !op || op.selectionSet.selections.every(function (selection) { return selection.kind ===
|
|
477
|
+
return !op || op.selectionSet.selections.every(function (selection) { return selection.kind === graphql.Kind.FRAGMENT_SPREAD &&
|
|
462
478
|
isEmpty(fragmentMap[selection.name.value], fragmentMap); });
|
|
463
479
|
}
|
|
464
480
|
function nullIfDocIsEmpty(doc) {
|
|
@@ -467,84 +483,190 @@ function nullIfDocIsEmpty(doc) {
|
|
|
467
483
|
: doc;
|
|
468
484
|
}
|
|
469
485
|
function getDirectiveMatcher(directives) {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
486
|
+
var nameSet = new Set();
|
|
487
|
+
var tests = [];
|
|
488
|
+
directives.forEach(function (directive) {
|
|
489
|
+
if (directive.name) {
|
|
490
|
+
nameSet.add(directive.name);
|
|
491
|
+
}
|
|
492
|
+
else if (directive.test) {
|
|
493
|
+
tests.push(directive.test);
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
return function (directive) { return (nameSet.has(directive.name.value) ||
|
|
497
|
+
tests.some(function (test) { return test(directive); })); };
|
|
498
|
+
}
|
|
499
|
+
function makeInUseGetterFunction(defaultKey) {
|
|
500
|
+
var map = new Map();
|
|
501
|
+
return function inUseGetterFunction(key) {
|
|
502
|
+
if (key === void 0) { key = defaultKey; }
|
|
503
|
+
var inUse = map.get(key);
|
|
504
|
+
if (!inUse) {
|
|
505
|
+
map.set(key, inUse = {
|
|
506
|
+
variables: new Set,
|
|
507
|
+
fragmentSpreads: new Set,
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
return inUse;
|
|
475
511
|
};
|
|
476
512
|
}
|
|
477
513
|
function removeDirectivesFromDocument(directives, doc) {
|
|
478
|
-
var
|
|
479
|
-
var
|
|
480
|
-
var
|
|
481
|
-
|
|
482
|
-
|
|
514
|
+
var getInUseByOperationName = makeInUseGetterFunction("");
|
|
515
|
+
var getInUseByFragmentName = makeInUseGetterFunction("");
|
|
516
|
+
var getInUse = function (ancestors) {
|
|
517
|
+
for (var p = 0, ancestor = void 0; p < ancestors.length && (ancestor = ancestors[p]); ++p) {
|
|
518
|
+
if (isArray(ancestor))
|
|
519
|
+
continue;
|
|
520
|
+
if (ancestor.kind === graphql.Kind.OPERATION_DEFINITION) {
|
|
521
|
+
return getInUseByOperationName(ancestor.name && ancestor.name.value);
|
|
522
|
+
}
|
|
523
|
+
if (ancestor.kind === graphql.Kind.FRAGMENT_DEFINITION) {
|
|
524
|
+
return getInUseByFragmentName(ancestor.name.value);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
__DEV__ && tsInvariant.invariant.error("Could not find operation or fragment");
|
|
528
|
+
return null;
|
|
529
|
+
};
|
|
530
|
+
var operationCount = 0;
|
|
531
|
+
for (var i = doc.definitions.length - 1; i >= 0; --i) {
|
|
532
|
+
if (doc.definitions[i].kind === graphql.Kind.OPERATION_DEFINITION) {
|
|
533
|
+
++operationCount;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
var directiveMatcher = getDirectiveMatcher(directives);
|
|
537
|
+
var hasRemoveDirective = directives.some(function (directive) { return directive.remove; });
|
|
538
|
+
var shouldRemoveField = function (nodeDirectives) { return (hasRemoveDirective &&
|
|
539
|
+
nodeDirectives &&
|
|
540
|
+
nodeDirectives.some(directiveMatcher)); };
|
|
541
|
+
var originalFragmentDefsByPath = new Map();
|
|
542
|
+
var firstVisitMadeChanges = false;
|
|
543
|
+
var fieldOrInlineFragmentVisitor = {
|
|
544
|
+
enter: function (node) {
|
|
545
|
+
if (shouldRemoveField(node.directives)) {
|
|
546
|
+
firstVisitMadeChanges = true;
|
|
547
|
+
return null;
|
|
548
|
+
}
|
|
549
|
+
},
|
|
550
|
+
};
|
|
551
|
+
var docWithoutDirectiveSubtrees = graphql.visit(doc, {
|
|
552
|
+
Field: fieldOrInlineFragmentVisitor,
|
|
553
|
+
InlineFragment: fieldOrInlineFragmentVisitor,
|
|
554
|
+
VariableDefinition: {
|
|
555
|
+
enter: function () {
|
|
556
|
+
return false;
|
|
557
|
+
},
|
|
558
|
+
},
|
|
483
559
|
Variable: {
|
|
484
|
-
enter: function (node, _key,
|
|
485
|
-
|
|
486
|
-
|
|
560
|
+
enter: function (node, _key, _parent, _path, ancestors) {
|
|
561
|
+
var inUse = getInUse(ancestors);
|
|
562
|
+
if (inUse) {
|
|
563
|
+
inUse.variables.add(node.name.value);
|
|
487
564
|
}
|
|
488
565
|
},
|
|
489
566
|
},
|
|
490
|
-
|
|
491
|
-
enter: function (node) {
|
|
492
|
-
if (
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
if (arg.value.kind === 'Variable') {
|
|
500
|
-
variablesToRemove.push({
|
|
501
|
-
name: arg.value.name.value,
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
if (node.selectionSet) {
|
|
507
|
-
getAllFragmentSpreadsFromSelectionSet(node.selectionSet).forEach(function (frag) {
|
|
508
|
-
fragmentSpreadsToRemove.push({
|
|
509
|
-
name: frag.name.value,
|
|
510
|
-
});
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
return null;
|
|
514
|
-
}
|
|
567
|
+
FragmentSpread: {
|
|
568
|
+
enter: function (node, _key, _parent, _path, ancestors) {
|
|
569
|
+
if (shouldRemoveField(node.directives)) {
|
|
570
|
+
firstVisitMadeChanges = true;
|
|
571
|
+
return null;
|
|
572
|
+
}
|
|
573
|
+
var inUse = getInUse(ancestors);
|
|
574
|
+
if (inUse) {
|
|
575
|
+
inUse.fragmentSpreads.add(node.name.value);
|
|
515
576
|
}
|
|
516
577
|
},
|
|
517
578
|
},
|
|
518
|
-
|
|
519
|
-
enter: function (node) {
|
|
520
|
-
|
|
579
|
+
FragmentDefinition: {
|
|
580
|
+
enter: function (node, _key, _parent, path) {
|
|
581
|
+
originalFragmentDefsByPath.set(JSON.stringify(path), node);
|
|
582
|
+
},
|
|
583
|
+
leave: function (node, _key, _parent, path) {
|
|
584
|
+
var originalNode = originalFragmentDefsByPath.get(JSON.stringify(path));
|
|
585
|
+
if (node === originalNode) {
|
|
586
|
+
return node;
|
|
587
|
+
}
|
|
588
|
+
if (operationCount > 0 &&
|
|
589
|
+
node.selectionSet.selections.every(function (selection) { return (selection.kind === graphql.Kind.FIELD &&
|
|
590
|
+
selection.name.value === '__typename'); })) {
|
|
591
|
+
getInUseByFragmentName(node.name.value).removed = true;
|
|
592
|
+
firstVisitMadeChanges = true;
|
|
593
|
+
return null;
|
|
594
|
+
}
|
|
521
595
|
},
|
|
522
596
|
},
|
|
523
597
|
Directive: {
|
|
524
|
-
|
|
525
|
-
if (
|
|
598
|
+
leave: function (node) {
|
|
599
|
+
if (directiveMatcher(node)) {
|
|
600
|
+
firstVisitMadeChanges = true;
|
|
526
601
|
return null;
|
|
527
602
|
}
|
|
528
603
|
},
|
|
529
604
|
},
|
|
605
|
+
});
|
|
606
|
+
if (!firstVisitMadeChanges) {
|
|
607
|
+
return doc;
|
|
608
|
+
}
|
|
609
|
+
var populateTransitiveVars = function (inUse) {
|
|
610
|
+
if (!inUse.transitiveVars) {
|
|
611
|
+
inUse.transitiveVars = new Set(inUse.variables);
|
|
612
|
+
if (!inUse.removed) {
|
|
613
|
+
inUse.fragmentSpreads.forEach(function (childFragmentName) {
|
|
614
|
+
populateTransitiveVars(getInUseByFragmentName(childFragmentName)).transitiveVars.forEach(function (varName) {
|
|
615
|
+
inUse.transitiveVars.add(varName);
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return inUse;
|
|
621
|
+
};
|
|
622
|
+
var allFragmentNamesUsed = new Set();
|
|
623
|
+
docWithoutDirectiveSubtrees.definitions.forEach(function (def) {
|
|
624
|
+
if (def.kind === graphql.Kind.OPERATION_DEFINITION) {
|
|
625
|
+
populateTransitiveVars(getInUseByOperationName(def.name && def.name.value)).fragmentSpreads.forEach(function (childFragmentName) {
|
|
626
|
+
allFragmentNamesUsed.add(childFragmentName);
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
else if (def.kind === graphql.Kind.FRAGMENT_DEFINITION &&
|
|
630
|
+
operationCount === 0 &&
|
|
631
|
+
!getInUseByFragmentName(def.name.value).removed) {
|
|
632
|
+
allFragmentNamesUsed.add(def.name.value);
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
allFragmentNamesUsed.forEach(function (fragmentName) {
|
|
636
|
+
populateTransitiveVars(getInUseByFragmentName(fragmentName)).fragmentSpreads.forEach(function (childFragmentName) {
|
|
637
|
+
allFragmentNamesUsed.add(childFragmentName);
|
|
638
|
+
});
|
|
639
|
+
});
|
|
640
|
+
var fragmentWillBeRemoved = function (fragmentName) { return !!(!allFragmentNamesUsed.has(fragmentName) ||
|
|
641
|
+
getInUseByFragmentName(fragmentName).removed); };
|
|
642
|
+
var enterVisitor = {
|
|
643
|
+
enter: function (node) {
|
|
644
|
+
if (fragmentWillBeRemoved(node.name.value)) {
|
|
645
|
+
return null;
|
|
646
|
+
}
|
|
647
|
+
},
|
|
648
|
+
};
|
|
649
|
+
return nullIfDocIsEmpty(graphql.visit(docWithoutDirectiveSubtrees, {
|
|
650
|
+
FragmentSpread: enterVisitor,
|
|
651
|
+
FragmentDefinition: enterVisitor,
|
|
652
|
+
OperationDefinition: {
|
|
653
|
+
leave: function (node) {
|
|
654
|
+
if (node.variableDefinitions) {
|
|
655
|
+
var usedVariableNames_1 = populateTransitiveVars(getInUseByOperationName(node.name && node.name.value)).transitiveVars;
|
|
656
|
+
if (usedVariableNames_1.size < node.variableDefinitions.length) {
|
|
657
|
+
return tslib.__assign(tslib.__assign({}, node), { variableDefinitions: node.variableDefinitions.filter(function (varDef) { return usedVariableNames_1.has(varDef.variable.name.value); }) });
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
},
|
|
530
662
|
}));
|
|
531
|
-
if (modifiedDoc &&
|
|
532
|
-
filterInPlace(variablesToRemove, function (v) { return !!v.name && !variablesInUse[v.name]; }).length) {
|
|
533
|
-
modifiedDoc = removeArgumentsFromDocument(variablesToRemove, modifiedDoc);
|
|
534
|
-
}
|
|
535
|
-
if (modifiedDoc &&
|
|
536
|
-
filterInPlace(fragmentSpreadsToRemove, function (fs) { return !!fs.name && !fragmentSpreadsInUse[fs.name]; })
|
|
537
|
-
.length) {
|
|
538
|
-
modifiedDoc = removeFragmentSpreadFromDocument(fragmentSpreadsToRemove, modifiedDoc);
|
|
539
|
-
}
|
|
540
|
-
return modifiedDoc;
|
|
541
663
|
}
|
|
542
664
|
var addTypenameToDocument = Object.assign(function (doc) {
|
|
543
665
|
return graphql.visit(doc, {
|
|
544
666
|
SelectionSet: {
|
|
545
667
|
enter: function (node, _key, parent) {
|
|
546
668
|
if (parent &&
|
|
547
|
-
parent.kind ===
|
|
669
|
+
parent.kind === graphql.Kind.OPERATION_DEFINITION) {
|
|
548
670
|
return;
|
|
549
671
|
}
|
|
550
672
|
var selections = node.selections;
|
|
@@ -590,78 +712,6 @@ var connectionRemoveConfig = {
|
|
|
590
712
|
function removeConnectionDirectiveFromDocument(doc) {
|
|
591
713
|
return removeDirectivesFromDocument([connectionRemoveConfig], checkDocument(doc));
|
|
592
714
|
}
|
|
593
|
-
function getArgumentMatcher(config) {
|
|
594
|
-
return function argumentMatcher(argument) {
|
|
595
|
-
return config.some(function (aConfig) {
|
|
596
|
-
return argument.value &&
|
|
597
|
-
argument.value.kind === 'Variable' &&
|
|
598
|
-
argument.value.name &&
|
|
599
|
-
(aConfig.name === argument.value.name.value ||
|
|
600
|
-
(aConfig.test && aConfig.test(argument)));
|
|
601
|
-
});
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
function removeArgumentsFromDocument(config, doc) {
|
|
605
|
-
var argMatcher = getArgumentMatcher(config);
|
|
606
|
-
return nullIfDocIsEmpty(graphql.visit(doc, {
|
|
607
|
-
OperationDefinition: {
|
|
608
|
-
enter: function (node) {
|
|
609
|
-
return tslib.__assign(tslib.__assign({}, node), { variableDefinitions: node.variableDefinitions ? node.variableDefinitions.filter(function (varDef) {
|
|
610
|
-
return !config.some(function (arg) { return arg.name === varDef.variable.name.value; });
|
|
611
|
-
}) : [] });
|
|
612
|
-
},
|
|
613
|
-
},
|
|
614
|
-
Field: {
|
|
615
|
-
enter: function (node) {
|
|
616
|
-
var shouldRemoveField = config.some(function (argConfig) { return argConfig.remove; });
|
|
617
|
-
if (shouldRemoveField) {
|
|
618
|
-
var argMatchCount_1 = 0;
|
|
619
|
-
if (node.arguments) {
|
|
620
|
-
node.arguments.forEach(function (arg) {
|
|
621
|
-
if (argMatcher(arg)) {
|
|
622
|
-
argMatchCount_1 += 1;
|
|
623
|
-
}
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
if (argMatchCount_1 === 1) {
|
|
627
|
-
return null;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
},
|
|
631
|
-
},
|
|
632
|
-
Argument: {
|
|
633
|
-
enter: function (node) {
|
|
634
|
-
if (argMatcher(node)) {
|
|
635
|
-
return null;
|
|
636
|
-
}
|
|
637
|
-
},
|
|
638
|
-
},
|
|
639
|
-
}));
|
|
640
|
-
}
|
|
641
|
-
function removeFragmentSpreadFromDocument(config, doc) {
|
|
642
|
-
function enter(node) {
|
|
643
|
-
if (config.some(function (def) { return def.name === node.name.value; })) {
|
|
644
|
-
return null;
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
return nullIfDocIsEmpty(graphql.visit(doc, {
|
|
648
|
-
FragmentSpread: { enter: enter },
|
|
649
|
-
FragmentDefinition: { enter: enter },
|
|
650
|
-
}));
|
|
651
|
-
}
|
|
652
|
-
function getAllFragmentSpreadsFromSelectionSet(selectionSet) {
|
|
653
|
-
var allFragments = [];
|
|
654
|
-
selectionSet.selections.forEach(function (selection) {
|
|
655
|
-
if ((isField(selection) || isInlineFragment(selection)) &&
|
|
656
|
-
selection.selectionSet) {
|
|
657
|
-
getAllFragmentSpreadsFromSelectionSet(selection.selectionSet).forEach(function (frag) { return allFragments.push(frag); });
|
|
658
|
-
}
|
|
659
|
-
else if (selection.kind === 'FragmentSpread') {
|
|
660
|
-
allFragments.push(selection);
|
|
661
|
-
}
|
|
662
|
-
});
|
|
663
|
-
return allFragments;
|
|
664
|
-
}
|
|
665
715
|
function buildQueryFromSelectionSet(document) {
|
|
666
716
|
var definition = getMainDefinition(document);
|
|
667
717
|
var definitionOperation = definition.operation;
|
|
@@ -685,22 +735,6 @@ function removeClientSetsFromDocument(document) {
|
|
|
685
735
|
remove: true,
|
|
686
736
|
},
|
|
687
737
|
], document);
|
|
688
|
-
if (modifiedDoc) {
|
|
689
|
-
modifiedDoc = graphql.visit(modifiedDoc, {
|
|
690
|
-
FragmentDefinition: {
|
|
691
|
-
enter: function (node) {
|
|
692
|
-
if (node.selectionSet) {
|
|
693
|
-
var isTypenameOnly = node.selectionSet.selections.every(function (selection) {
|
|
694
|
-
return isField(selection) && selection.name.value === '__typename';
|
|
695
|
-
});
|
|
696
|
-
if (isTypenameOnly) {
|
|
697
|
-
return null;
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
},
|
|
701
|
-
},
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
738
|
return modifiedDoc;
|
|
705
739
|
}
|
|
706
740
|
|
|
@@ -953,9 +987,9 @@ var Concast = (function (_super) {
|
|
|
953
987
|
}
|
|
954
988
|
},
|
|
955
989
|
complete: function () {
|
|
956
|
-
var sub =
|
|
990
|
+
var _a = _this, sub = _a.sub, _b = _a.sources, sources = _b === void 0 ? [] : _b;
|
|
957
991
|
if (sub !== null) {
|
|
958
|
-
var value =
|
|
992
|
+
var value = sources.shift();
|
|
959
993
|
if (!value) {
|
|
960
994
|
if (sub)
|
|
961
995
|
setTimeout(function () { return sub.unsubscribe(); });
|
|
@@ -1049,10 +1083,6 @@ var Concast = (function (_super) {
|
|
|
1049
1083
|
}(zenObservableTs.Observable));
|
|
1050
1084
|
fixObservableSubclass(Concast);
|
|
1051
1085
|
|
|
1052
|
-
function isNonEmptyArray(value) {
|
|
1053
|
-
return Array.isArray(value) && value.length > 0;
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
1086
|
function isExecutionPatchIncrementalResult(value) {
|
|
1057
1087
|
return "incremental" in value;
|
|
1058
1088
|
}
|
|
@@ -1141,6 +1171,26 @@ function mergeOptions(defaults, options) {
|
|
|
1141
1171
|
});
|
|
1142
1172
|
}
|
|
1143
1173
|
|
|
1174
|
+
function isNodeResponse(value) {
|
|
1175
|
+
return !!value.body;
|
|
1176
|
+
}
|
|
1177
|
+
function isReadableStream(value) {
|
|
1178
|
+
return !!value.getReader;
|
|
1179
|
+
}
|
|
1180
|
+
function isAsyncIterableIterator(value) {
|
|
1181
|
+
return !!(canUseAsyncIteratorSymbol &&
|
|
1182
|
+
value[Symbol.asyncIterator]);
|
|
1183
|
+
}
|
|
1184
|
+
function isStreamableBlob(value) {
|
|
1185
|
+
return !!value.stream;
|
|
1186
|
+
}
|
|
1187
|
+
function isBlob(value) {
|
|
1188
|
+
return !!value.arrayBuffer;
|
|
1189
|
+
}
|
|
1190
|
+
function isNodeReadableStream(value) {
|
|
1191
|
+
return !!value.pipe;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1144
1194
|
function fromError(errorValue) {
|
|
1145
1195
|
return new zenObservableTs.Observable(function (observer) {
|
|
1146
1196
|
observer.error(errorValue);
|
|
@@ -1196,7 +1246,7 @@ function validateOperation(operation) {
|
|
|
1196
1246
|
for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
|
|
1197
1247
|
var key = _a[_i];
|
|
1198
1248
|
if (OPERATION_FIELDS.indexOf(key) < 0) {
|
|
1199
|
-
throw __DEV__ ? new tsInvariant.InvariantError("illegal argument: ".concat(key)) : new tsInvariant.InvariantError(
|
|
1249
|
+
throw __DEV__ ? new tsInvariant.InvariantError("illegal argument: ".concat(key)) : new tsInvariant.InvariantError(27);
|
|
1200
1250
|
}
|
|
1201
1251
|
}
|
|
1202
1252
|
return operation;
|
|
@@ -1319,7 +1369,7 @@ var ApolloLink = (function () {
|
|
|
1319
1369
|
return ApolloLink.concat(this, next);
|
|
1320
1370
|
};
|
|
1321
1371
|
ApolloLink.prototype.request = function (operation, forward) {
|
|
1322
|
-
throw __DEV__ ? new tsInvariant.InvariantError('request is not implemented') : new tsInvariant.InvariantError(
|
|
1372
|
+
throw __DEV__ ? new tsInvariant.InvariantError('request is not implemented') : new tsInvariant.InvariantError(22);
|
|
1323
1373
|
};
|
|
1324
1374
|
ApolloLink.prototype.onError = function (error, observer) {
|
|
1325
1375
|
if (observer && observer.error) {
|
|
@@ -1345,27 +1395,7 @@ var concat = ApolloLink.concat;
|
|
|
1345
1395
|
|
|
1346
1396
|
var execute = ApolloLink.execute;
|
|
1347
1397
|
|
|
1348
|
-
var version = '3.8.0-alpha.
|
|
1349
|
-
|
|
1350
|
-
function isNodeResponse(value) {
|
|
1351
|
-
return !!value.body;
|
|
1352
|
-
}
|
|
1353
|
-
function isReadableStream(value) {
|
|
1354
|
-
return !!value.getReader;
|
|
1355
|
-
}
|
|
1356
|
-
function isAsyncIterableIterator(value) {
|
|
1357
|
-
return !!(canUseAsyncIteratorSymbol &&
|
|
1358
|
-
value[Symbol.asyncIterator]);
|
|
1359
|
-
}
|
|
1360
|
-
function isStreamableBlob(value) {
|
|
1361
|
-
return !!value.stream;
|
|
1362
|
-
}
|
|
1363
|
-
function isBlob(value) {
|
|
1364
|
-
return !!value.arrayBuffer;
|
|
1365
|
-
}
|
|
1366
|
-
function isNodeReadableStream(value) {
|
|
1367
|
-
return !!value.pipe;
|
|
1368
|
-
}
|
|
1398
|
+
var version = '3.8.0-alpha.10';
|
|
1369
1399
|
|
|
1370
1400
|
function asyncIterator(source) {
|
|
1371
1401
|
var _a;
|
|
@@ -1661,7 +1691,7 @@ var serializeFetchParameter = function (p, label) {
|
|
|
1661
1691
|
serialized = JSON.stringify(p);
|
|
1662
1692
|
}
|
|
1663
1693
|
catch (e) {
|
|
1664
|
-
var parseError = __DEV__ ? new tsInvariant.InvariantError("Network request failed. ".concat(label, " is not serializable: ").concat(e.message)) : new tsInvariant.InvariantError(
|
|
1694
|
+
var parseError = __DEV__ ? new tsInvariant.InvariantError("Network request failed. ".concat(label, " is not serializable: ").concat(e.message)) : new tsInvariant.InvariantError(24);
|
|
1665
1695
|
parseError.parseError = e;
|
|
1666
1696
|
throw parseError;
|
|
1667
1697
|
}
|
|
@@ -1709,7 +1739,9 @@ function selectHttpOptionsAndBodyInternal(operation, printer) {
|
|
|
1709
1739
|
}
|
|
1710
1740
|
http = tslib.__assign(tslib.__assign({}, http), config.http);
|
|
1711
1741
|
});
|
|
1712
|
-
|
|
1742
|
+
if (options.headers) {
|
|
1743
|
+
options.headers = removeDuplicateHeaders(options.headers, http.preserveHeaderCase);
|
|
1744
|
+
}
|
|
1713
1745
|
var operationName = operation.operationName, extensions = operation.extensions, variables = operation.variables, query = operation.query;
|
|
1714
1746
|
var body = { operationName: operationName, variables: variables };
|
|
1715
1747
|
if (http.includeExtensions)
|
|
@@ -1742,7 +1774,7 @@ function removeDuplicateHeaders(headers, preserveHeaderCase) {
|
|
|
1742
1774
|
|
|
1743
1775
|
var checkFetcher = function (fetcher) {
|
|
1744
1776
|
if (!fetcher && typeof fetch === 'undefined') {
|
|
1745
|
-
throw __DEV__ ? new tsInvariant.InvariantError("\n\"fetch\" has not been found globally and no fetcher has been configured. To fix this, install a fetch package (like https://www.npmjs.com/package/cross-fetch), instantiate the fetcher, and pass it into your HttpLink constructor. For example:\n\nimport fetch from 'cross-fetch';\nimport { ApolloClient, HttpLink } from '@apollo/client';\nconst client = new ApolloClient({\n link: new HttpLink({ uri: '/graphql', fetch })\n});\n ") : new tsInvariant.InvariantError(
|
|
1777
|
+
throw __DEV__ ? new tsInvariant.InvariantError("\n\"fetch\" has not been found globally and no fetcher has been configured. To fix this, install a fetch package (like https://www.npmjs.com/package/cross-fetch), instantiate the fetcher, and pass it into your HttpLink constructor. For example:\n\nimport fetch from 'cross-fetch';\nimport { ApolloClient, HttpLink } from '@apollo/client';\nconst client = new ApolloClient({\n link: new HttpLink({ uri: '/graphql', fetch })\n});\n ") : new tsInvariant.InvariantError(23);
|
|
1746
1778
|
}
|
|
1747
1779
|
};
|
|
1748
1780
|
|
|
@@ -1843,6 +1875,13 @@ var createHttpLink = function (linkOptions) {
|
|
|
1843
1875
|
credentials: context.credentials,
|
|
1844
1876
|
headers: contextHeaders,
|
|
1845
1877
|
};
|
|
1878
|
+
if (hasDirectives(['client'], operation.query)) {
|
|
1879
|
+
var transformedQuery = removeClientSetsFromDocument(operation.query);
|
|
1880
|
+
if (!transformedQuery) {
|
|
1881
|
+
return fromError(new Error('HttpLink: Trying to send a client-only query to the server. To send to the server, ensure a non-client field is added to the query or set the `transformOptions.removeClientFields` option to `true`.'));
|
|
1882
|
+
}
|
|
1883
|
+
operation.query = transformedQuery;
|
|
1884
|
+
}
|
|
1846
1885
|
var _b = selectHttpOptionsAndBodyInternal(operation, print, fallbackHttpConfig, linkConfig, contextConfig), options = _b.options, body = _b.body;
|
|
1847
1886
|
if (body.variables && !includeUnusedVariables) {
|
|
1848
1887
|
var unusedNames_1 = new Set(Object.keys(body.variables));
|
|
@@ -1875,6 +1914,7 @@ var createHttpLink = function (linkOptions) {
|
|
|
1875
1914
|
options.method = 'GET';
|
|
1876
1915
|
}
|
|
1877
1916
|
if (hasDirectives(['defer'], operation.query)) {
|
|
1917
|
+
options.headers = options.headers || {};
|
|
1878
1918
|
options.headers.accept = "multipart/mixed; deferSpec=20220824, application/json";
|
|
1879
1919
|
}
|
|
1880
1920
|
if (options.method === 'GET') {
|
|
@@ -2038,7 +2078,6 @@ var hasOwn = Object.prototype.hasOwnProperty;
|
|
|
2038
2078
|
function isNullish(value) {
|
|
2039
2079
|
return value === null || value === void 0;
|
|
2040
2080
|
}
|
|
2041
|
-
var isArray = Array.isArray;
|
|
2042
2081
|
function defaultDataIdFromObject(_a, context) {
|
|
2043
2082
|
var __typename = _a.__typename, id = _a.id, _id = _a._id;
|
|
2044
2083
|
if (typeof __typename === "string") {
|
|
@@ -3282,9 +3321,20 @@ var Policies = (function () {
|
|
|
3282
3321
|
if (!hasOwn.call(this.typePolicies, typename)) {
|
|
3283
3322
|
var policy_1 = this.typePolicies[typename] = Object.create(null);
|
|
3284
3323
|
policy_1.fields = Object.create(null);
|
|
3285
|
-
var
|
|
3286
|
-
if (
|
|
3287
|
-
|
|
3324
|
+
var supertypes_1 = this.supertypeMap.get(typename);
|
|
3325
|
+
if (!supertypes_1 && this.fuzzySubtypes.size) {
|
|
3326
|
+
supertypes_1 = this.getSupertypeSet(typename, true);
|
|
3327
|
+
this.fuzzySubtypes.forEach(function (regExp, fuzzy) {
|
|
3328
|
+
if (regExp.test(typename)) {
|
|
3329
|
+
var fuzzySupertypes = _this.supertypeMap.get(fuzzy);
|
|
3330
|
+
if (fuzzySupertypes) {
|
|
3331
|
+
fuzzySupertypes.forEach(function (supertype) { return supertypes_1.add(supertype); });
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
});
|
|
3335
|
+
}
|
|
3336
|
+
if (supertypes_1 && supertypes_1.size) {
|
|
3337
|
+
supertypes_1.forEach(function (supertype) {
|
|
3288
3338
|
var _a = _this.getTypePolicy(supertype), fields = _a.fields, rest = tslib.__rest(_a, ["fields"]);
|
|
3289
3339
|
Object.assign(policy_1, rest);
|
|
3290
3340
|
Object.assign(policy_1.fields, fields);
|
|
@@ -4620,7 +4670,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4620
4670
|
pollingInfo.interval === pollInterval) {
|
|
4621
4671
|
return;
|
|
4622
4672
|
}
|
|
4623
|
-
__DEV__ ? tsInvariant.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : tsInvariant.invariant(pollInterval,
|
|
4673
|
+
__DEV__ ? tsInvariant.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : tsInvariant.invariant(pollInterval, 13);
|
|
4624
4674
|
var info = pollingInfo || (this.pollingInfo = {});
|
|
4625
4675
|
info.interval = pollInterval;
|
|
4626
4676
|
var maybeFetch = function () {
|
|
@@ -4769,6 +4819,7 @@ function logMissingFieldErrors(missing) {
|
|
|
4769
4819
|
var LocalState = (function () {
|
|
4770
4820
|
function LocalState(_a) {
|
|
4771
4821
|
var cache = _a.cache, client = _a.client, resolvers = _a.resolvers, fragmentMatcher = _a.fragmentMatcher;
|
|
4822
|
+
this.selectionsToResolveCache = new WeakMap();
|
|
4772
4823
|
this.cache = cache;
|
|
4773
4824
|
if (client) {
|
|
4774
4825
|
this.client = client;
|
|
@@ -4824,8 +4875,12 @@ var LocalState = (function () {
|
|
|
4824
4875
|
}
|
|
4825
4876
|
return null;
|
|
4826
4877
|
};
|
|
4827
|
-
LocalState.prototype.serverQuery = function (document) {
|
|
4828
|
-
|
|
4878
|
+
LocalState.prototype.serverQuery = function (document, options) {
|
|
4879
|
+
if (options === void 0) { options = Object.create(null); }
|
|
4880
|
+
var _a = options.removeClientFields, removeClientFields = _a === void 0 ? true : _a;
|
|
4881
|
+
return removeClientFields
|
|
4882
|
+
? removeClientSetsFromDocument(document)
|
|
4883
|
+
: document;
|
|
4829
4884
|
};
|
|
4830
4885
|
LocalState.prototype.prepareContext = function (context) {
|
|
4831
4886
|
var cache = this.cache;
|
|
@@ -4879,13 +4934,13 @@ var LocalState = (function () {
|
|
|
4879
4934
|
if (fragmentMatcher === void 0) { fragmentMatcher = function () { return true; }; }
|
|
4880
4935
|
if (onlyRunForcedResolvers === void 0) { onlyRunForcedResolvers = false; }
|
|
4881
4936
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
4882
|
-
var mainDefinition, fragments, fragmentMap, definitionOperation, defaultOperationType, _a, cache, client, execContext;
|
|
4937
|
+
var mainDefinition, fragments, fragmentMap, selectionsToResolve, definitionOperation, defaultOperationType, _a, cache, client, execContext, isClientFieldDescendant;
|
|
4883
4938
|
return tslib.__generator(this, function (_b) {
|
|
4884
4939
|
mainDefinition = getMainDefinition(document);
|
|
4885
4940
|
fragments = getFragmentDefinitions(document);
|
|
4886
4941
|
fragmentMap = createFragmentMap(fragments);
|
|
4887
|
-
|
|
4888
|
-
|
|
4942
|
+
selectionsToResolve = this.collectSelectionsToResolve(mainDefinition, fragmentMap);
|
|
4943
|
+
definitionOperation = mainDefinition.operation;
|
|
4889
4944
|
defaultOperationType = definitionOperation
|
|
4890
4945
|
? definitionOperation.charAt(0).toUpperCase() +
|
|
4891
4946
|
definitionOperation.slice(1)
|
|
@@ -4898,16 +4953,18 @@ var LocalState = (function () {
|
|
|
4898
4953
|
fragmentMatcher: fragmentMatcher,
|
|
4899
4954
|
defaultOperationType: defaultOperationType,
|
|
4900
4955
|
exportedVariables: {},
|
|
4956
|
+
selectionsToResolve: selectionsToResolve,
|
|
4901
4957
|
onlyRunForcedResolvers: onlyRunForcedResolvers,
|
|
4902
4958
|
};
|
|
4903
|
-
|
|
4959
|
+
isClientFieldDescendant = false;
|
|
4960
|
+
return [2, this.resolveSelectionSet(mainDefinition.selectionSet, isClientFieldDescendant, rootValue, execContext).then(function (result) { return ({
|
|
4904
4961
|
result: result,
|
|
4905
4962
|
exportedVariables: execContext.exportedVariables,
|
|
4906
4963
|
}); })];
|
|
4907
4964
|
});
|
|
4908
4965
|
});
|
|
4909
4966
|
};
|
|
4910
|
-
LocalState.prototype.resolveSelectionSet = function (selectionSet, rootValue, execContext) {
|
|
4967
|
+
LocalState.prototype.resolveSelectionSet = function (selectionSet, isClientFieldDescendant, rootValue, execContext) {
|
|
4911
4968
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
4912
4969
|
var fragmentMap, context, variables, resultsToMerge, execute;
|
|
4913
4970
|
var _this = this;
|
|
@@ -4917,11 +4974,14 @@ var LocalState = (function () {
|
|
|
4917
4974
|
execute = function (selection) { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
4918
4975
|
var fragment, typeCondition;
|
|
4919
4976
|
return tslib.__generator(this, function (_a) {
|
|
4977
|
+
if (!isClientFieldDescendant && !execContext.selectionsToResolve.has(selection)) {
|
|
4978
|
+
return [2];
|
|
4979
|
+
}
|
|
4920
4980
|
if (!shouldInclude(selection, variables)) {
|
|
4921
4981
|
return [2];
|
|
4922
4982
|
}
|
|
4923
4983
|
if (isField(selection)) {
|
|
4924
|
-
return [2, this.resolveField(selection, rootValue, execContext).then(function (fieldResult) {
|
|
4984
|
+
return [2, this.resolveField(selection, isClientFieldDescendant, rootValue, execContext).then(function (fieldResult) {
|
|
4925
4985
|
var _a;
|
|
4926
4986
|
if (typeof fieldResult !== 'undefined') {
|
|
4927
4987
|
resultsToMerge.push((_a = {},
|
|
@@ -4940,7 +5000,7 @@ var LocalState = (function () {
|
|
|
4940
5000
|
if (fragment && fragment.typeCondition) {
|
|
4941
5001
|
typeCondition = fragment.typeCondition.name.value;
|
|
4942
5002
|
if (execContext.fragmentMatcher(rootValue, typeCondition, context)) {
|
|
4943
|
-
return [2, this.resolveSelectionSet(fragment.selectionSet, rootValue, execContext).then(function (fragmentResult) {
|
|
5003
|
+
return [2, this.resolveSelectionSet(fragment.selectionSet, isClientFieldDescendant, rootValue, execContext).then(function (fragmentResult) {
|
|
4944
5004
|
resultsToMerge.push(fragmentResult);
|
|
4945
5005
|
})];
|
|
4946
5006
|
}
|
|
@@ -4954,11 +5014,14 @@ var LocalState = (function () {
|
|
|
4954
5014
|
});
|
|
4955
5015
|
});
|
|
4956
5016
|
};
|
|
4957
|
-
LocalState.prototype.resolveField = function (field, rootValue, execContext) {
|
|
5017
|
+
LocalState.prototype.resolveField = function (field, isClientFieldDescendant, rootValue, execContext) {
|
|
4958
5018
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
4959
5019
|
var variables, fieldName, aliasedFieldName, aliasUsed, defaultResult, resultPromise, resolverType, resolverMap, resolve;
|
|
4960
5020
|
var _this = this;
|
|
4961
5021
|
return tslib.__generator(this, function (_a) {
|
|
5022
|
+
if (!rootValue) {
|
|
5023
|
+
return [2, null];
|
|
5024
|
+
}
|
|
4962
5025
|
variables = execContext.variables;
|
|
4963
5026
|
fieldName = field.name.value;
|
|
4964
5027
|
aliasedFieldName = resultKeyNameFromField(field);
|
|
@@ -4982,6 +5045,7 @@ var LocalState = (function () {
|
|
|
4982
5045
|
}
|
|
4983
5046
|
}
|
|
4984
5047
|
return [2, resultPromise.then(function (result) {
|
|
5048
|
+
var _a, _b;
|
|
4985
5049
|
if (result === void 0) { result = defaultResult; }
|
|
4986
5050
|
if (field.directives) {
|
|
4987
5051
|
field.directives.forEach(function (directive) {
|
|
@@ -5000,30 +5064,70 @@ var LocalState = (function () {
|
|
|
5000
5064
|
if (result == null) {
|
|
5001
5065
|
return result;
|
|
5002
5066
|
}
|
|
5067
|
+
var isClientField = (_b = (_a = field.directives) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.name.value === 'client'; })) !== null && _b !== void 0 ? _b : false;
|
|
5003
5068
|
if (Array.isArray(result)) {
|
|
5004
|
-
return _this.resolveSubSelectedArray(field, result, execContext);
|
|
5069
|
+
return _this.resolveSubSelectedArray(field, isClientFieldDescendant || isClientField, result, execContext);
|
|
5005
5070
|
}
|
|
5006
5071
|
if (field.selectionSet) {
|
|
5007
|
-
return _this.resolveSelectionSet(field.selectionSet, result, execContext);
|
|
5072
|
+
return _this.resolveSelectionSet(field.selectionSet, isClientFieldDescendant || isClientField, result, execContext);
|
|
5008
5073
|
}
|
|
5009
5074
|
})];
|
|
5010
5075
|
});
|
|
5011
5076
|
});
|
|
5012
5077
|
};
|
|
5013
|
-
LocalState.prototype.resolveSubSelectedArray = function (field, result, execContext) {
|
|
5078
|
+
LocalState.prototype.resolveSubSelectedArray = function (field, isClientFieldDescendant, result, execContext) {
|
|
5014
5079
|
var _this = this;
|
|
5015
5080
|
return Promise.all(result.map(function (item) {
|
|
5016
5081
|
if (item === null) {
|
|
5017
5082
|
return null;
|
|
5018
5083
|
}
|
|
5019
5084
|
if (Array.isArray(item)) {
|
|
5020
|
-
return _this.resolveSubSelectedArray(field, item, execContext);
|
|
5085
|
+
return _this.resolveSubSelectedArray(field, isClientFieldDescendant, item, execContext);
|
|
5021
5086
|
}
|
|
5022
5087
|
if (field.selectionSet) {
|
|
5023
|
-
return _this.resolveSelectionSet(field.selectionSet, item, execContext);
|
|
5088
|
+
return _this.resolveSelectionSet(field.selectionSet, isClientFieldDescendant, item, execContext);
|
|
5024
5089
|
}
|
|
5025
5090
|
}));
|
|
5026
5091
|
};
|
|
5092
|
+
LocalState.prototype.collectSelectionsToResolve = function (mainDefinition, fragmentMap) {
|
|
5093
|
+
var isSingleASTNode = function (node) { return !Array.isArray(node); };
|
|
5094
|
+
var selectionsToResolveCache = this.selectionsToResolveCache;
|
|
5095
|
+
function collectByDefinition(definitionNode) {
|
|
5096
|
+
if (!selectionsToResolveCache.has(definitionNode)) {
|
|
5097
|
+
var matches_1 = new Set();
|
|
5098
|
+
selectionsToResolveCache.set(definitionNode, matches_1);
|
|
5099
|
+
graphql.visit(definitionNode, {
|
|
5100
|
+
Directive: function (node, _, __, ___, ancestors) {
|
|
5101
|
+
if (node.name.value === 'client') {
|
|
5102
|
+
ancestors.forEach(function (node) {
|
|
5103
|
+
if (isSingleASTNode(node) && graphql.isSelectionNode(node)) {
|
|
5104
|
+
matches_1.add(node);
|
|
5105
|
+
}
|
|
5106
|
+
});
|
|
5107
|
+
}
|
|
5108
|
+
},
|
|
5109
|
+
FragmentSpread: function (spread, _, __, ___, ancestors) {
|
|
5110
|
+
var fragment = fragmentMap[spread.name.value];
|
|
5111
|
+
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named ".concat(spread.name.value)) : tsInvariant.invariant(fragment, 12);
|
|
5112
|
+
var fragmentSelections = collectByDefinition(fragment);
|
|
5113
|
+
if (fragmentSelections.size > 0) {
|
|
5114
|
+
ancestors.forEach(function (node) {
|
|
5115
|
+
if (isSingleASTNode(node) && graphql.isSelectionNode(node)) {
|
|
5116
|
+
matches_1.add(node);
|
|
5117
|
+
}
|
|
5118
|
+
});
|
|
5119
|
+
matches_1.add(spread);
|
|
5120
|
+
fragmentSelections.forEach(function (selection) {
|
|
5121
|
+
matches_1.add(selection);
|
|
5122
|
+
});
|
|
5123
|
+
}
|
|
5124
|
+
}
|
|
5125
|
+
});
|
|
5126
|
+
}
|
|
5127
|
+
return selectionsToResolveCache.get(definitionNode);
|
|
5128
|
+
}
|
|
5129
|
+
return collectByDefinition(mainDefinition);
|
|
5130
|
+
};
|
|
5027
5131
|
return LocalState;
|
|
5028
5132
|
}());
|
|
5029
5133
|
|
|
@@ -5334,7 +5438,7 @@ var QueryManager = (function () {
|
|
|
5334
5438
|
this.queries.forEach(function (_info, queryId) {
|
|
5335
5439
|
_this.stopQueryNoBroadcast(queryId);
|
|
5336
5440
|
});
|
|
5337
|
-
this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('QueryManager stopped while query was in flight') : new tsInvariant.InvariantError(
|
|
5441
|
+
this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('QueryManager stopped while query was in flight') : new tsInvariant.InvariantError(14));
|
|
5338
5442
|
};
|
|
5339
5443
|
QueryManager.prototype.cancelPendingFetches = function (error) {
|
|
5340
5444
|
this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
|
|
@@ -5348,10 +5452,10 @@ var QueryManager = (function () {
|
|
|
5348
5452
|
return tslib.__generator(this, function (_j) {
|
|
5349
5453
|
switch (_j.label) {
|
|
5350
5454
|
case 0:
|
|
5351
|
-
__DEV__ ? tsInvariant.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : tsInvariant.invariant(mutation,
|
|
5455
|
+
__DEV__ ? tsInvariant.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : tsInvariant.invariant(mutation, 15);
|
|
5352
5456
|
__DEV__ ? tsInvariant.invariant(fetchPolicy === 'network-only' ||
|
|
5353
5457
|
fetchPolicy === 'no-cache', "Mutations support only 'network-only' or 'no-cache' fetchPolicy strings. The default `network-only` behavior automatically writes mutation results to the cache. Passing `no-cache` skips the cache write.") : tsInvariant.invariant(fetchPolicy === 'network-only' ||
|
|
5354
|
-
fetchPolicy === 'no-cache',
|
|
5458
|
+
fetchPolicy === 'no-cache', 16);
|
|
5355
5459
|
mutationId = this.generateMutationId();
|
|
5356
5460
|
_h = this.transform(mutation), document = _h.document, hasClientExports = _h.hasClientExports;
|
|
5357
5461
|
mutation = this.cache.transformForLink(document);
|
|
@@ -5468,7 +5572,10 @@ var QueryManager = (function () {
|
|
|
5468
5572
|
optimistic: false,
|
|
5469
5573
|
returnPartialData: true,
|
|
5470
5574
|
});
|
|
5471
|
-
var mergedData =
|
|
5575
|
+
var mergedData = void 0;
|
|
5576
|
+
if (diff.result) {
|
|
5577
|
+
mergedData = mergeIncrementalData(diff.result, result);
|
|
5578
|
+
}
|
|
5472
5579
|
if (typeof mergedData !== 'undefined') {
|
|
5473
5580
|
result.data = mergedData;
|
|
5474
5581
|
cacheWrites.push({
|
|
@@ -5612,11 +5719,13 @@ var QueryManager = (function () {
|
|
|
5612
5719
|
};
|
|
5613
5720
|
QueryManager.prototype.transform = function (document) {
|
|
5614
5721
|
var transformCache = this.transformCache;
|
|
5722
|
+
var _a = (this.defaultOptions.transformQuery || Object.create(null)).removeClientFields, removeClientFields = _a === void 0 ? true : _a;
|
|
5615
5723
|
if (!transformCache.has(document)) {
|
|
5616
5724
|
var transformed = this.cache.transformDocument(document);
|
|
5617
5725
|
var noConnection = removeConnectionDirectiveFromDocument(transformed);
|
|
5618
5726
|
var clientQuery = this.localState.clientQuery(transformed);
|
|
5619
|
-
var serverQuery = noConnection &&
|
|
5727
|
+
var serverQuery = noConnection &&
|
|
5728
|
+
this.localState.serverQuery(noConnection, { removeClientFields: removeClientFields });
|
|
5620
5729
|
var cacheEntry_1 = {
|
|
5621
5730
|
document: transformed,
|
|
5622
5731
|
hasClientExports: hasClientExports(transformed),
|
|
@@ -5670,10 +5779,10 @@ var QueryManager = (function () {
|
|
|
5670
5779
|
var _this = this;
|
|
5671
5780
|
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
5672
5781
|
__DEV__ ? tsInvariant.invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
|
|
5673
|
-
'in the query option.') : tsInvariant.invariant(options.query,
|
|
5674
|
-
__DEV__ ? tsInvariant.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : tsInvariant.invariant(options.query.kind === 'Document',
|
|
5675
|
-
__DEV__ ? tsInvariant.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : tsInvariant.invariant(!options.returnPartialData,
|
|
5676
|
-
__DEV__ ? tsInvariant.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : tsInvariant.invariant(!options.pollInterval,
|
|
5782
|
+
'in the query option.') : tsInvariant.invariant(options.query, 17);
|
|
5783
|
+
__DEV__ ? tsInvariant.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : tsInvariant.invariant(options.query.kind === 'Document', 18);
|
|
5784
|
+
__DEV__ ? tsInvariant.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : tsInvariant.invariant(!options.returnPartialData, 19);
|
|
5785
|
+
__DEV__ ? tsInvariant.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : tsInvariant.invariant(!options.pollInterval, 20);
|
|
5677
5786
|
return this.fetchQuery(queryId, options).finally(function () { return _this.stopQuery(queryId); });
|
|
5678
5787
|
};
|
|
5679
5788
|
QueryManager.prototype.generateQueryId = function () {
|
|
@@ -5698,7 +5807,7 @@ var QueryManager = (function () {
|
|
|
5698
5807
|
if (options === void 0) { options = {
|
|
5699
5808
|
discardWatches: true,
|
|
5700
5809
|
}; }
|
|
5701
|
-
this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('Store reset while query was in flight (not completed in link chain)') : new tsInvariant.InvariantError(
|
|
5810
|
+
this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('Store reset while query was in flight (not completed in link chain)') : new tsInvariant.InvariantError(21));
|
|
5702
5811
|
this.queries.forEach(function (queryInfo) {
|
|
5703
5812
|
if (queryInfo.observableQuery) {
|
|
5704
5813
|
queryInfo.networkStatus = exports.NetworkStatus.loading;
|
|
@@ -6086,6 +6195,11 @@ var QueryManager = (function () {
|
|
|
6086
6195
|
onlyRunForcedResolvers: true,
|
|
6087
6196
|
}).then(function (resolved) { return fromData(resolved.data || void 0); });
|
|
6088
6197
|
}
|
|
6198
|
+
if (errorPolicy === 'none' &&
|
|
6199
|
+
networkStatus === exports.NetworkStatus.refetch &&
|
|
6200
|
+
Array.isArray(diff.missing)) {
|
|
6201
|
+
return fromData(void 0);
|
|
6202
|
+
}
|
|
6089
6203
|
return fromData(data);
|
|
6090
6204
|
};
|
|
6091
6205
|
var cacheWriteBehavior = fetchPolicy === "no-cache" ? 0 :
|
|
@@ -6310,12 +6424,18 @@ var ApolloClient = (function () {
|
|
|
6310
6424
|
return this.cache.readFragment(options, optimistic);
|
|
6311
6425
|
};
|
|
6312
6426
|
ApolloClient.prototype.writeQuery = function (options) {
|
|
6313
|
-
this.cache.writeQuery(options);
|
|
6314
|
-
|
|
6427
|
+
var ref = this.cache.writeQuery(options);
|
|
6428
|
+
if (options.broadcast !== false) {
|
|
6429
|
+
this.queryManager.broadcastQueries();
|
|
6430
|
+
}
|
|
6431
|
+
return ref;
|
|
6315
6432
|
};
|
|
6316
6433
|
ApolloClient.prototype.writeFragment = function (options) {
|
|
6317
|
-
this.cache.writeFragment(options);
|
|
6318
|
-
|
|
6434
|
+
var ref = this.cache.writeFragment(options);
|
|
6435
|
+
if (options.broadcast !== false) {
|
|
6436
|
+
this.queryManager.broadcastQueries();
|
|
6437
|
+
}
|
|
6438
|
+
return ref;
|
|
6319
6439
|
};
|
|
6320
6440
|
ApolloClient.prototype.__actionHookForDevTools = function (cb) {
|
|
6321
6441
|
this.devToolsHookCb = cb;
|
|
@@ -6422,7 +6542,7 @@ var ApolloConsumer = function (props) {
|
|
|
6422
6542
|
var ApolloContext = getApolloContext();
|
|
6423
6543
|
return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
|
|
6424
6544
|
__DEV__ ? tsInvariant.invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
|
|
6425
|
-
'Wrap the root component in an <ApolloProvider>.') : tsInvariant.invariant(context && context.client,
|
|
6545
|
+
'Wrap the root component in an <ApolloProvider>.') : tsInvariant.invariant(context && context.client, 28);
|
|
6426
6546
|
return props.children(context.client);
|
|
6427
6547
|
}));
|
|
6428
6548
|
};
|
|
@@ -6439,7 +6559,7 @@ var ApolloProvider = function (_a) {
|
|
|
6439
6559
|
context = Object.assign({}, context, { suspenseCache: suspenseCache });
|
|
6440
6560
|
}
|
|
6441
6561
|
__DEV__ ? tsInvariant.invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
|
|
6442
|
-
'sure you pass in your client via the "client" prop.') : tsInvariant.invariant(context.client,
|
|
6562
|
+
'sure you pass in your client via the "client" prop.') : tsInvariant.invariant(context.client, 29);
|
|
6443
6563
|
return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
|
|
6444
6564
|
}));
|
|
6445
6565
|
};
|
|
@@ -6449,7 +6569,7 @@ function useApolloClient(override) {
|
|
|
6449
6569
|
var client = override || context.client;
|
|
6450
6570
|
__DEV__ ? tsInvariant.invariant(!!client, 'Could not find "client" in the context or passed in as an option. ' +
|
|
6451
6571
|
'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient ' +
|
|
6452
|
-
'instance in via options.') : tsInvariant.invariant(!!client,
|
|
6572
|
+
'instance in via options.') : tsInvariant.invariant(!!client, 32);
|
|
6453
6573
|
return client;
|
|
6454
6574
|
}
|
|
6455
6575
|
|
|
@@ -6527,7 +6647,7 @@ function parser(document) {
|
|
|
6527
6647
|
var variables, type, name;
|
|
6528
6648
|
__DEV__ ? tsInvariant.invariant(!!document && !!document.kind, "Argument of ".concat(document, " passed to parser was not a valid GraphQL ") +
|
|
6529
6649
|
"DocumentNode. You may need to use 'graphql-tag' or another method " +
|
|
6530
|
-
"to convert your operation into a document") : tsInvariant.invariant(!!document && !!document.kind,
|
|
6650
|
+
"to convert your operation into a document") : tsInvariant.invariant(!!document && !!document.kind, 35);
|
|
6531
6651
|
var fragments = [];
|
|
6532
6652
|
var queries = [];
|
|
6533
6653
|
var mutations = [];
|
|
@@ -6555,11 +6675,11 @@ function parser(document) {
|
|
|
6555
6675
|
__DEV__ ? tsInvariant.invariant(!fragments.length ||
|
|
6556
6676
|
(queries.length || mutations.length || subscriptions.length), "Passing only a fragment to 'graphql' is not yet supported. " +
|
|
6557
6677
|
"You must include a query, subscription or mutation as well") : tsInvariant.invariant(!fragments.length ||
|
|
6558
|
-
(queries.length || mutations.length || subscriptions.length),
|
|
6678
|
+
(queries.length || mutations.length || subscriptions.length), 36);
|
|
6559
6679
|
__DEV__ ? tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1, "react-apollo only supports a query, subscription, or a mutation per HOC. " +
|
|
6560
6680
|
"".concat(document, " had ").concat(queries.length, " queries, ").concat(subscriptions.length, " ") +
|
|
6561
6681
|
"subscriptions and ".concat(mutations.length, " mutations. ") +
|
|
6562
|
-
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1,
|
|
6682
|
+
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1, 37);
|
|
6563
6683
|
type = queries.length ? exports.DocumentType.Query : exports.DocumentType.Mutation;
|
|
6564
6684
|
if (!queries.length && !mutations.length)
|
|
6565
6685
|
type = exports.DocumentType.Subscription;
|
|
@@ -6570,7 +6690,7 @@ function parser(document) {
|
|
|
6570
6690
|
: subscriptions;
|
|
6571
6691
|
__DEV__ ? tsInvariant.invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. ".concat(document, " had ") +
|
|
6572
6692
|
"".concat(definitions.length, " definitions. ") +
|
|
6573
|
-
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(definitions.length === 1,
|
|
6693
|
+
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(definitions.length === 1, 38);
|
|
6574
6694
|
var definition = definitions[0];
|
|
6575
6695
|
variables = definition.variableDefinitions || [];
|
|
6576
6696
|
if (definition.name && definition.name.kind === 'Name') {
|
|
@@ -6588,7 +6708,7 @@ function verifyDocumentType(document, type) {
|
|
|
6588
6708
|
var requiredOperationName = operationName(type);
|
|
6589
6709
|
var usedOperationName = operationName(operation.type);
|
|
6590
6710
|
__DEV__ ? tsInvariant.invariant(operation.type === type, "Running a ".concat(requiredOperationName, " requires a graphql ") +
|
|
6591
|
-
"".concat(requiredOperationName, ", but a ").concat(usedOperationName, " was used instead.")) : tsInvariant.invariant(operation.type === type,
|
|
6711
|
+
"".concat(requiredOperationName, ", but a ").concat(usedOperationName, " was used instead.")) : tsInvariant.invariant(operation.type === type, 39);
|
|
6592
6712
|
}
|
|
6593
6713
|
|
|
6594
6714
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
@@ -6639,11 +6759,19 @@ var InternalState = (function () {
|
|
|
6639
6759
|
InternalState.prototype.forceUpdate = function () {
|
|
6640
6760
|
__DEV__ && tsInvariant.invariant.warn("Calling default no-op implementation of InternalState#forceUpdate");
|
|
6641
6761
|
};
|
|
6642
|
-
InternalState.prototype.asyncUpdate = function () {
|
|
6762
|
+
InternalState.prototype.asyncUpdate = function (signal) {
|
|
6643
6763
|
var _this = this;
|
|
6644
|
-
return new Promise(function (resolve) {
|
|
6764
|
+
return new Promise(function (resolve, reject) {
|
|
6765
|
+
var watchQueryOptions = _this.watchQueryOptions;
|
|
6766
|
+
var handleAborted = function () {
|
|
6767
|
+
_this.asyncResolveFns.delete(resolve);
|
|
6768
|
+
_this.optionsToIgnoreOnce.delete(watchQueryOptions);
|
|
6769
|
+
signal.removeEventListener('abort', handleAborted);
|
|
6770
|
+
reject(signal.reason);
|
|
6771
|
+
};
|
|
6645
6772
|
_this.asyncResolveFns.add(resolve);
|
|
6646
|
-
_this.optionsToIgnoreOnce.add(
|
|
6773
|
+
_this.optionsToIgnoreOnce.add(watchQueryOptions);
|
|
6774
|
+
signal.addEventListener('abort', handleAborted);
|
|
6647
6775
|
_this.forceUpdate();
|
|
6648
6776
|
});
|
|
6649
6777
|
};
|
|
@@ -6693,7 +6821,7 @@ var InternalState = (function () {
|
|
|
6693
6821
|
}
|
|
6694
6822
|
};
|
|
6695
6823
|
var subscription = obsQuery.subscribe(onNext, onError);
|
|
6696
|
-
return function () { return subscription.unsubscribe(); };
|
|
6824
|
+
return function () { return setTimeout(function () { return subscription.unsubscribe(); }); };
|
|
6697
6825
|
}, [
|
|
6698
6826
|
obsQuery,
|
|
6699
6827
|
this.renderPromises,
|
|
@@ -6820,9 +6948,10 @@ var InternalState = (function () {
|
|
|
6820
6948
|
InternalState.prototype.handleErrorOrCompleted = function (result, previousResult) {
|
|
6821
6949
|
var _this = this;
|
|
6822
6950
|
if (!result.loading) {
|
|
6951
|
+
var error_1 = this.toApolloError(result);
|
|
6823
6952
|
Promise.resolve().then(function () {
|
|
6824
|
-
if (
|
|
6825
|
-
_this.onError(
|
|
6953
|
+
if (error_1) {
|
|
6954
|
+
_this.onError(error_1);
|
|
6826
6955
|
}
|
|
6827
6956
|
else if (result.data &&
|
|
6828
6957
|
(previousResult === null || previousResult === void 0 ? void 0 : previousResult.networkStatus) !== result.networkStatus &&
|
|
@@ -6834,6 +6963,11 @@ var InternalState = (function () {
|
|
|
6834
6963
|
});
|
|
6835
6964
|
}
|
|
6836
6965
|
};
|
|
6966
|
+
InternalState.prototype.toApolloError = function (result) {
|
|
6967
|
+
return isNonEmptyArray(result.errors)
|
|
6968
|
+
? new ApolloError({ graphQLErrors: result.errors })
|
|
6969
|
+
: result.error;
|
|
6970
|
+
};
|
|
6837
6971
|
InternalState.prototype.getCurrentResult = function () {
|
|
6838
6972
|
if (!this.result) {
|
|
6839
6973
|
this.handleErrorOrCompleted(this.result = this.observable.getCurrentResult());
|
|
@@ -6876,11 +7010,11 @@ var EAGER_METHODS = [
|
|
|
6876
7010
|
'subscribeToMore',
|
|
6877
7011
|
];
|
|
6878
7012
|
function useLazyQuery(query, options) {
|
|
6879
|
-
var
|
|
7013
|
+
var _a, _b;
|
|
7014
|
+
var abortControllersRef = React.useRef(new Set());
|
|
6880
7015
|
var execOptionsRef = React.useRef();
|
|
6881
|
-
var merged = execOptionsRef.current
|
|
6882
|
-
|
|
6883
|
-
: options;
|
|
7016
|
+
var merged = execOptionsRef.current ? mergeOptions(options, execOptionsRef.current) : options;
|
|
7017
|
+
var internalState = useInternalState(useApolloClient(options && options.client), (_b = (_a = execOptionsRef.current) === null || _a === void 0 ? void 0 : _a.query) !== null && _b !== void 0 ? _b : query);
|
|
6884
7018
|
var useQueryResult = internalState.useQuery(tslib.__assign(tslib.__assign({}, merged), { skip: !execOptionsRef.current }));
|
|
6885
7019
|
var initialFetchPolicy = useQueryResult.observable.options.initialFetchPolicy ||
|
|
6886
7020
|
internalState.getDefaultFetchPolicy();
|
|
@@ -6906,14 +7040,28 @@ function useLazyQuery(query, options) {
|
|
|
6906
7040
|
return eagerMethods;
|
|
6907
7041
|
}, []);
|
|
6908
7042
|
Object.assign(result, eagerMethods);
|
|
7043
|
+
React.useEffect(function () {
|
|
7044
|
+
return function () {
|
|
7045
|
+
abortControllersRef.current.forEach(function (controller) {
|
|
7046
|
+
controller.abort();
|
|
7047
|
+
});
|
|
7048
|
+
};
|
|
7049
|
+
}, []);
|
|
6909
7050
|
var execute = React.useCallback(function (executeOptions) {
|
|
7051
|
+
var controller = new AbortController();
|
|
7052
|
+
abortControllersRef.current.add(controller);
|
|
6910
7053
|
execOptionsRef.current = executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
|
|
6911
7054
|
fetchPolicy: initialFetchPolicy,
|
|
6912
7055
|
};
|
|
6913
7056
|
var promise = internalState
|
|
6914
|
-
.asyncUpdate()
|
|
6915
|
-
.then(function (queryResult) {
|
|
6916
|
-
|
|
7057
|
+
.asyncUpdate(controller.signal)
|
|
7058
|
+
.then(function (queryResult) {
|
|
7059
|
+
abortControllersRef.current.delete(controller);
|
|
7060
|
+
return Object.assign(queryResult, eagerMethods);
|
|
7061
|
+
});
|
|
7062
|
+
promise.catch(function () {
|
|
7063
|
+
abortControllersRef.current.delete(controller);
|
|
7064
|
+
});
|
|
6917
7065
|
return promise;
|
|
6918
7066
|
}, []);
|
|
6919
7067
|
return [execute, result];
|
|
@@ -6940,8 +7088,9 @@ function useMutation(mutation, options) {
|
|
|
6940
7088
|
}
|
|
6941
7089
|
var execute = React.useCallback(function (executeOptions) {
|
|
6942
7090
|
if (executeOptions === void 0) { executeOptions = {}; }
|
|
6943
|
-
var _a = ref.current,
|
|
7091
|
+
var _a = ref.current, options = _a.options, mutation = _a.mutation;
|
|
6944
7092
|
var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
|
|
7093
|
+
var client = executeOptions.client || ref.current.client;
|
|
6945
7094
|
if (!ref.current.result.loading && !baseOptions.ignoreResults && ref.current.isMounted) {
|
|
6946
7095
|
setResult(ref.current.result = {
|
|
6947
7096
|
loading: true,
|
|
@@ -6954,7 +7103,7 @@ function useMutation(mutation, options) {
|
|
|
6954
7103
|
var mutationId = ++ref.current.mutationId;
|
|
6955
7104
|
var clientOptions = mergeOptions(baseOptions, executeOptions);
|
|
6956
7105
|
return client.mutate(clientOptions).then(function (response) {
|
|
6957
|
-
var _a
|
|
7106
|
+
var _a;
|
|
6958
7107
|
var data = response.data, errors = response.errors;
|
|
6959
7108
|
var error = errors && errors.length > 0
|
|
6960
7109
|
? new ApolloError({ graphQLErrors: errors })
|
|
@@ -6972,11 +7121,11 @@ function useMutation(mutation, options) {
|
|
|
6972
7121
|
setResult(ref.current.result = result_1);
|
|
6973
7122
|
}
|
|
6974
7123
|
}
|
|
6975
|
-
|
|
6976
|
-
|
|
7124
|
+
var onCompleted = executeOptions.onCompleted || ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onCompleted);
|
|
7125
|
+
onCompleted === null || onCompleted === void 0 ? void 0 : onCompleted(response.data, clientOptions);
|
|
6977
7126
|
return response;
|
|
6978
7127
|
}).catch(function (error) {
|
|
6979
|
-
var _a
|
|
7128
|
+
var _a;
|
|
6980
7129
|
if (mutationId === ref.current.mutationId &&
|
|
6981
7130
|
ref.current.isMounted) {
|
|
6982
7131
|
var result_2 = {
|
|
@@ -6990,9 +7139,9 @@ function useMutation(mutation, options) {
|
|
|
6990
7139
|
setResult(ref.current.result = result_2);
|
|
6991
7140
|
}
|
|
6992
7141
|
}
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
7142
|
+
var onError = executeOptions.onError || ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError);
|
|
7143
|
+
if (onError) {
|
|
7144
|
+
onError(error, clientOptions);
|
|
6996
7145
|
return { data: void 0, errors: error };
|
|
6997
7146
|
}
|
|
6998
7147
|
throw error;
|
|
@@ -7169,20 +7318,21 @@ function useFragment_experimental(options) {
|
|
|
7169
7318
|
var diffOptions = tslib.__assign(tslib.__assign({}, rest), { id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
|
|
7170
7319
|
var resultRef = React.useRef();
|
|
7171
7320
|
var latestDiff = cache.diff(diffOptions);
|
|
7321
|
+
var getSnapshot = function () {
|
|
7322
|
+
var latestDiffToResult = diffToResult(latestDiff);
|
|
7323
|
+
return resultRef.current &&
|
|
7324
|
+
equality.equal(resultRef.current.data, latestDiffToResult.data)
|
|
7325
|
+
? resultRef.current
|
|
7326
|
+
: (resultRef.current = latestDiffToResult);
|
|
7327
|
+
};
|
|
7172
7328
|
return useSyncExternalStore(function (forceUpdate) {
|
|
7173
7329
|
return cache.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: true, callback: function (diff) {
|
|
7174
7330
|
if (!equality.equal(diff, latestDiff)) {
|
|
7175
|
-
resultRef.current = diffToResult(latestDiff = diff);
|
|
7331
|
+
resultRef.current = diffToResult((latestDiff = diff));
|
|
7176
7332
|
forceUpdate();
|
|
7177
7333
|
}
|
|
7178
7334
|
} }));
|
|
7179
|
-
},
|
|
7180
|
-
var latestDiffToResult = diffToResult(latestDiff);
|
|
7181
|
-
return resultRef.current &&
|
|
7182
|
-
equality.equal(resultRef.current.data, latestDiffToResult.data)
|
|
7183
|
-
? resultRef.current
|
|
7184
|
-
: (resultRef.current = latestDiffToResult);
|
|
7185
|
-
});
|
|
7335
|
+
}, getSnapshot, getSnapshot);
|
|
7186
7336
|
}
|
|
7187
7337
|
function diffToResult(diff) {
|
|
7188
7338
|
var result = {
|
|
@@ -7203,10 +7353,16 @@ function useDeepMemo(memoFn, deps) {
|
|
|
7203
7353
|
return ref.current.value;
|
|
7204
7354
|
}
|
|
7205
7355
|
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7356
|
+
var useIsomorphicLayoutEffect = canUseLayoutEffect
|
|
7357
|
+
? React.useLayoutEffect
|
|
7358
|
+
: React.useEffect;
|
|
7359
|
+
|
|
7360
|
+
function useSuspenseCache(override) {
|
|
7361
|
+
var context = React.useContext(getApolloContext());
|
|
7362
|
+
var suspenseCache = override || context.suspenseCache;
|
|
7363
|
+
__DEV__ ? tsInvariant.invariant(suspenseCache, 'Could not find a "suspenseCache" in the context or passed in as an option. ' +
|
|
7364
|
+
'Wrap the root component in an <ApolloProvider> and provide a suspenseCache, ' +
|
|
7365
|
+
'or pass a SuspenseCache instance in via options.') : tsInvariant.invariant(suspenseCache, 33);
|
|
7210
7366
|
return suspenseCache;
|
|
7211
7367
|
}
|
|
7212
7368
|
|
|
@@ -7221,7 +7377,7 @@ var DEFAULT_SUSPENSE_POLICY = 'always';
|
|
|
7221
7377
|
var DEFAULT_ERROR_POLICY = 'none';
|
|
7222
7378
|
function useSuspenseQuery_experimental(query, options) {
|
|
7223
7379
|
if (options === void 0) { options = Object.create(null); }
|
|
7224
|
-
var suspenseCache = useSuspenseCache();
|
|
7380
|
+
var suspenseCache = useSuspenseCache(options.suspenseCache);
|
|
7225
7381
|
var client = useApolloClient(options.client);
|
|
7226
7382
|
var watchQueryOptions = useWatchQueryOptions({ query: query, options: options, client: client });
|
|
7227
7383
|
var previousWatchQueryOptionsRef = React.useRef(watchQueryOptions);
|
|
@@ -7235,9 +7391,9 @@ function useSuspenseQuery_experimental(query, options) {
|
|
|
7235
7391
|
var hasFullResult = result.data && !result.partial;
|
|
7236
7392
|
var hasPartialResult = result.data && result.partial;
|
|
7237
7393
|
var usePartialResult = returnPartialData && hasPartialResult;
|
|
7394
|
+
var allowsThrownErrors = errorPolicy === 'none' && (!deferred || !hasPartialResult);
|
|
7238
7395
|
if (result.error &&
|
|
7239
|
-
|
|
7240
|
-
(!deferred || !hasPartialResult)) {
|
|
7396
|
+
(result.error.networkError || allowsThrownErrors)) {
|
|
7241
7397
|
throw result.error;
|
|
7242
7398
|
}
|
|
7243
7399
|
if (result.loading) {
|
|
@@ -7270,28 +7426,42 @@ function useSuspenseQuery_experimental(query, options) {
|
|
|
7270
7426
|
suspenseCache.remove(query, variables);
|
|
7271
7427
|
};
|
|
7272
7428
|
}, []);
|
|
7429
|
+
var fetchMore = React.useCallback(function (options) {
|
|
7430
|
+
var promise = observable.fetchMore(options);
|
|
7431
|
+
suspenseCache.add(query, watchQueryOptions.variables, {
|
|
7432
|
+
promise: promise,
|
|
7433
|
+
observable: observable,
|
|
7434
|
+
});
|
|
7435
|
+
return promise;
|
|
7436
|
+
}, [observable]);
|
|
7437
|
+
var refetch = React.useCallback(function (variables) {
|
|
7438
|
+
var promise = observable.refetch(variables);
|
|
7439
|
+
suspenseCache.add(query, watchQueryOptions.variables, {
|
|
7440
|
+
promise: promise,
|
|
7441
|
+
observable: observable,
|
|
7442
|
+
});
|
|
7443
|
+
return promise;
|
|
7444
|
+
}, [observable]);
|
|
7445
|
+
var subscribeToMore = React.useCallback(function (options) { return observable.subscribeToMore(options); }, [observable]);
|
|
7273
7446
|
return React.useMemo(function () {
|
|
7274
7447
|
return {
|
|
7448
|
+
client: client,
|
|
7275
7449
|
data: result.data,
|
|
7276
7450
|
error: errorPolicy === 'ignore' ? void 0 : toApolloError(result),
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
observable: observable,
|
|
7282
|
-
});
|
|
7283
|
-
return promise;
|
|
7284
|
-
},
|
|
7285
|
-
refetch: function (variables) {
|
|
7286
|
-
var promise = observable.refetch(variables);
|
|
7287
|
-
suspenseCache.add(query, watchQueryOptions.variables, {
|
|
7288
|
-
promise: promise,
|
|
7289
|
-
observable: observable,
|
|
7290
|
-
});
|
|
7291
|
-
return promise;
|
|
7292
|
-
},
|
|
7451
|
+
networkStatus: result.networkStatus,
|
|
7452
|
+
fetchMore: fetchMore,
|
|
7453
|
+
refetch: refetch,
|
|
7454
|
+
subscribeToMore: subscribeToMore,
|
|
7293
7455
|
};
|
|
7294
|
-
}, [
|
|
7456
|
+
}, [
|
|
7457
|
+
client,
|
|
7458
|
+
fetchMore,
|
|
7459
|
+
refetch,
|
|
7460
|
+
result,
|
|
7461
|
+
observable,
|
|
7462
|
+
errorPolicy,
|
|
7463
|
+
subscribeToMore,
|
|
7464
|
+
]);
|
|
7295
7465
|
}
|
|
7296
7466
|
function validateOptions(options) {
|
|
7297
7467
|
var query = options.query, _a = options.fetchPolicy, fetchPolicy = _a === void 0 ? DEFAULT_FETCH_POLICY : _a, returnPartialData = options.returnPartialData;
|
|
@@ -7300,7 +7470,7 @@ function validateOptions(options) {
|
|
|
7300
7470
|
validatePartialDataReturn(fetchPolicy, returnPartialData);
|
|
7301
7471
|
}
|
|
7302
7472
|
function validateFetchPolicy(fetchPolicy) {
|
|
7303
|
-
__DEV__ ? tsInvariant.invariant(SUPPORTED_FETCH_POLICIES.includes(fetchPolicy), "The fetch policy `".concat(fetchPolicy, "` is not supported with suspense.")) : tsInvariant.invariant(SUPPORTED_FETCH_POLICIES.includes(fetchPolicy),
|
|
7473
|
+
__DEV__ ? tsInvariant.invariant(SUPPORTED_FETCH_POLICIES.includes(fetchPolicy), "The fetch policy `".concat(fetchPolicy, "` is not supported with suspense.")) : tsInvariant.invariant(SUPPORTED_FETCH_POLICIES.includes(fetchPolicy), 34);
|
|
7304
7474
|
}
|
|
7305
7475
|
function validatePartialDataReturn(fetchPolicy, returnPartialData) {
|
|
7306
7476
|
if (fetchPolicy === 'no-cache' && returnPartialData) {
|
|
@@ -7345,16 +7515,18 @@ function useIsDeferred(query) {
|
|
|
7345
7515
|
function useObservableQueryResult(observable) {
|
|
7346
7516
|
var resultRef = React.useRef();
|
|
7347
7517
|
var isMountedRef = React.useRef(false);
|
|
7518
|
+
var subscribeTimeoutRef = React.useRef();
|
|
7348
7519
|
if (!resultRef.current) {
|
|
7349
7520
|
resultRef.current = observable.getCurrentResult();
|
|
7350
7521
|
}
|
|
7351
|
-
|
|
7522
|
+
useIsomorphicLayoutEffect(function () {
|
|
7352
7523
|
isMountedRef.current = true;
|
|
7353
7524
|
return function () {
|
|
7354
7525
|
isMountedRef.current = false;
|
|
7355
7526
|
};
|
|
7356
7527
|
}, []);
|
|
7357
7528
|
return useSyncExternalStore(React.useCallback(function (forceUpdate) {
|
|
7529
|
+
clearTimeout(subscribeTimeoutRef.current);
|
|
7358
7530
|
function handleUpdate() {
|
|
7359
7531
|
var previousResult = resultRef.current;
|
|
7360
7532
|
var result = observable.getCurrentResult();
|
|
@@ -7368,12 +7540,20 @@ function useObservableQueryResult(observable) {
|
|
|
7368
7540
|
forceUpdate();
|
|
7369
7541
|
}
|
|
7370
7542
|
}
|
|
7371
|
-
var subscription
|
|
7372
|
-
|
|
7373
|
-
|
|
7543
|
+
var subscription;
|
|
7544
|
+
subscribeTimeoutRef.current = setTimeout(function () {
|
|
7545
|
+
subscription = observable.subscribe({
|
|
7546
|
+
next: handleUpdate,
|
|
7547
|
+
error: handleUpdate,
|
|
7548
|
+
});
|
|
7549
|
+
var result = resultRef.current;
|
|
7550
|
+
if (result.networkStatus !== observable['queryInfo'].networkStatus &&
|
|
7551
|
+
result.networkStatus === exports.NetworkStatus.ready) {
|
|
7552
|
+
observable['queryInfo'].markReady();
|
|
7553
|
+
}
|
|
7374
7554
|
});
|
|
7375
7555
|
return function () {
|
|
7376
|
-
subscription.unsubscribe();
|
|
7556
|
+
subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
|
|
7377
7557
|
};
|
|
7378
7558
|
}, [observable]), function () { return resultRef.current; }, function () { return resultRef.current; });
|
|
7379
7559
|
}
|