@apollo/client 3.4.0-rc.7 → 3.4.1
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/apollo-client.cjs.js +300 -263
- package/apollo-client.cjs.js.map +1 -1
- package/apollo-client.cjs.min.js +1 -1
- package/cache/cache.cjs.js +105 -41
- package/cache/cache.cjs.js.map +1 -1
- package/cache/core/types/DataProxy.js +1 -0
- package/cache/index.d.ts +0 -1
- package/cache/index.d.ts.map +1 -1
- package/cache/index.js +3 -1
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +3 -2
- package/cache/inmemory/entityStore.d.ts.map +1 -1
- package/cache/inmemory/entityStore.js +22 -10
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/fixPolyfills.native.js +1 -0
- package/cache/inmemory/helpers.d.ts +1 -1
- package/cache/inmemory/helpers.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +5 -1
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js +24 -3
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/object-canon.d.ts +3 -1
- package/cache/inmemory/object-canon.d.ts.map +1 -1
- package/cache/inmemory/object-canon.js +12 -7
- package/cache/inmemory/object-canon.js.map +1 -1
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +23 -10
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +5 -2
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +9 -6
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.js +1 -0
- package/cache/inmemory/writeToStore.d.ts +1 -0
- package/cache/inmemory/writeToStore.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.js +16 -7
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +3 -0
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.js +2 -4
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts +7 -6
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +116 -78
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +0 -1
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js +3 -6
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +3 -3
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +13 -10
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs.js +137 -181
- package/core/core.cjs.js.map +1 -1
- package/core/index.d.ts +0 -1
- package/core/index.d.ts.map +1 -1
- package/core/index.js +2 -2
- package/core/index.js.map +1 -1
- package/core/types.d.ts +4 -1
- package/core/types.d.ts.map +1 -1
- package/core/types.js +1 -0
- package/core/types.js.map +1 -1
- package/core/watchQueryOptions.js +1 -0
- package/errors/errors.cjs.js +2 -0
- package/errors/errors.cjs.js.map +1 -1
- package/errors/index.d.ts.map +1 -1
- package/errors/index.js +3 -0
- package/errors/index.js.map +1 -1
- package/invariantErrorCodes.js +82 -57
- package/link/context/context.cjs.js +4 -0
- package/link/context/context.cjs.js.map +1 -1
- package/link/context/index.d.ts.map +1 -1
- package/link/context/index.js +4 -0
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.js +1 -1
- package/link/core/core.cjs.js +4 -2
- package/link/core/core.cjs.js.map +1 -1
- package/link/core/index.d.ts.map +1 -1
- package/link/core/index.js +3 -0
- package/link/core/index.js.map +1 -1
- package/link/core/types.js +1 -0
- package/link/http/checkFetcher.js +1 -1
- package/link/http/http.cjs.js +13 -3
- package/link/http/http.cjs.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
- package/link/http/selectHttpOptionsAndBody.js +11 -1
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.d.ts.map +1 -1
- package/link/persisted-queries/index.js +2 -2
- package/link/persisted-queries/persisted-queries.cjs.js +2 -2
- package/link/persisted-queries/persisted-queries.cjs.js.map +1 -1
- package/link/utils/utils.cjs.js +1 -1
- package/link/utils/utils.cjs.js.map +1 -1
- package/link/utils/validateOperation.js +1 -1
- package/package.json +20 -20
- package/react/components/Mutation.d.ts +1 -1
- package/react/components/Query.js +1 -1
- package/react/components/Query.js.map +1 -1
- package/react/components/components.cjs.js +45 -31
- package/react/components/components.cjs.js.map +1 -1
- package/react/components/types.js +1 -0
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/context.cjs.js +22 -8
- package/react/context/context.cjs.js.map +1 -1
- package/react/data/OperationData.js +2 -2
- package/react/data/QueryData.d.ts +1 -2
- package/react/data/QueryData.d.ts.map +1 -1
- package/react/data/QueryData.js +65 -72
- package/react/data/QueryData.js.map +1 -1
- package/react/data/data.cjs.js +65 -71
- package/react/data/data.cjs.js.map +1 -1
- package/react/hoc/hoc-utils.d.ts +2 -1
- package/react/hoc/hoc-utils.d.ts.map +1 -1
- package/react/hoc/hoc-utils.js +1 -1
- package/react/hoc/hoc.cjs.js +35 -18
- package/react/hoc/hoc.cjs.js.map +1 -1
- package/react/hoc/mutation-hoc.d.ts.map +1 -1
- package/react/hoc/query-hoc.d.ts.map +1 -1
- package/react/hoc/subscription-hoc.d.ts.map +1 -1
- package/react/hoc/types.js +1 -0
- package/react/hoc/withApollo.js +1 -1
- package/react/hooks/hooks.cjs.js +56 -10
- package/react/hooks/hooks.cjs.js.map +1 -1
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useSubscription.d.ts.map +1 -1
- package/react/hooks/useSubscription.js +16 -6
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/utils/useAfterFastRefresh.d.ts +2 -0
- package/react/hooks/utils/useAfterFastRefresh.d.ts.map +1 -0
- package/react/hooks/utils/useAfterFastRefresh.js +18 -0
- package/react/hooks/utils/useAfterFastRefresh.js.map +1 -0
- package/react/hooks/utils/useBaseQuery.d.ts.map +1 -1
- package/react/hooks/utils/useBaseQuery.js +10 -3
- package/react/hooks/utils/useBaseQuery.js.map +1 -1
- package/react/index.d.ts +0 -1
- package/react/index.d.ts.map +1 -1
- package/react/index.js +3 -1
- package/react/index.js.map +1 -1
- package/react/parser/index.js +4 -4
- package/react/parser/parser.cjs.js +4 -4
- package/react/parser/parser.cjs.js.map +1 -1
- package/react/react.cjs.js +2 -2
- package/react/react.cjs.js.map +1 -1
- package/react/ssr/ssr.cjs.js +15 -1
- package/react/ssr/ssr.cjs.js.map +1 -1
- package/react/types/types.d.ts +9 -3
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js +1 -0
- package/react/types/types.js.map +1 -1
- package/testing/index.d.ts.map +1 -1
- package/testing/index.js +3 -0
- package/testing/index.js.map +1 -1
- package/testing/testing.cjs.js +68 -17
- package/testing/testing.cjs.js.map +1 -1
- package/utilities/common/canUse.d.ts +1 -0
- package/utilities/common/canUse.d.ts.map +1 -1
- package/utilities/common/canUse.js +1 -0
- package/utilities/common/canUse.js.map +1 -1
- package/utilities/common/global.d.ts.map +1 -1
- package/utilities/common/mergeDeep.js +2 -2
- package/utilities/common/mergeDeep.js.map +1 -1
- package/utilities/common/stringifyForDisplay.d.ts +2 -0
- package/utilities/common/stringifyForDisplay.d.ts.map +1 -0
- package/utilities/common/stringifyForDisplay.js +8 -0
- package/utilities/common/stringifyForDisplay.js.map +1 -0
- package/utilities/globals/DEV.d.ts +3 -0
- package/utilities/globals/DEV.d.ts.map +1 -0
- package/utilities/globals/DEV.js +20 -0
- package/utilities/globals/DEV.js.map +1 -0
- package/utilities/globals/graphql.d.ts +1 -1
- package/utilities/globals/graphql.d.ts.map +1 -1
- package/utilities/globals/graphql.js +3 -3
- package/utilities/globals/graphql.js.map +1 -1
- package/utilities/globals/index.d.ts +4 -2
- package/utilities/globals/index.d.ts.map +1 -1
- package/utilities/globals/index.js +5 -4
- package/utilities/globals/index.js.map +1 -1
- package/utilities/graphql/directives.js +4 -4
- package/utilities/graphql/fragments.js +5 -5
- package/utilities/graphql/getFromAST.js +8 -8
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/graphql/transform.js +2 -2
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +3 -1
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +5 -1
- package/utilities/index.js.map +1 -1
- package/utilities/package.json +3 -1
- package/utilities/policies/pagination.d.ts.map +1 -1
- package/utilities/policies/pagination.js +10 -11
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/testing/index.d.ts +1 -0
- package/utilities/testing/index.d.ts.map +1 -1
- package/utilities/testing/index.js +1 -0
- package/utilities/testing/index.js.map +1 -1
- package/utilities/testing/itAsync.d.ts +5 -8
- package/utilities/testing/itAsync.d.ts.map +1 -1
- package/utilities/testing/itAsync.js +6 -7
- package/utilities/testing/itAsync.js.map +1 -1
- package/utilities/testing/mocking/mockFetch.js +2 -2
- package/utilities/testing/mocking/mockFetch.js.map +1 -1
- package/utilities/testing/mocking/mockLink.d.ts.map +1 -1
- package/utilities/testing/mocking/mockLink.js +2 -8
- package/utilities/testing/mocking/mockLink.js.map +1 -1
- package/utilities/testing/mocking/mockWatchQuery.d.ts.map +1 -1
- package/utilities/testing/mocking/mockWatchQuery.js +2 -2
- package/utilities/testing/mocking/mockWatchQuery.js.map +1 -1
- package/utilities/testing/observableToPromise.js +2 -2
- package/utilities/testing/observableToPromise.js.map +1 -1
- package/utilities/testing/withConsoleSpy.d.ts +4 -0
- package/utilities/testing/withConsoleSpy.d.ts.map +1 -0
- package/utilities/testing/withConsoleSpy.js +39 -0
- package/utilities/testing/withConsoleSpy.js.map +1 -0
- package/utilities/types/IsStrictlyAny.js +1 -0
- package/utilities/utilities.cjs.js +56 -48
- package/utilities/utilities.cjs.js.map +1 -1
- package/version.js +1 -1
- package/core/Reobserver.d.ts +0 -18
- package/core/Reobserver.d.ts.map +0 -1
- package/core/Reobserver.js +0 -87
- package/core/Reobserver.js.map +0 -1
- package/utilities/globals/__DEV__.d.ts +0 -3
- package/utilities/globals/__DEV__.d.ts.map +0 -1
- package/utilities/globals/__DEV__.js +0 -32
- package/utilities/globals/__DEV__.js.map +0 -1
- package/utilities/globals/process.d.ts +0 -2
- package/utilities/globals/process.d.ts.map +0 -1
- package/utilities/globals/process.js +0 -31
- package/utilities/globals/process.js.map +0 -1
package/apollo-client.cjs.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var tslib = require('tslib');
|
|
6
5
|
var tsInvariant = require('ts-invariant');
|
|
6
|
+
var process$1 = require('ts-invariant/process');
|
|
7
|
+
var graphql = require('graphql');
|
|
8
|
+
var tslib = require('tslib');
|
|
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');
|
|
@@ -26,34 +27,30 @@ var global$1 = (maybe(function () { return globalThis; }) ||
|
|
|
26
27
|
maybe(function () { return global; }) ||
|
|
27
28
|
maybe(function () { return Function("return this")(); }));
|
|
28
29
|
|
|
30
|
+
var __ = "__";
|
|
31
|
+
var GLOBAL_KEY = [__, __].join("DEV");
|
|
29
32
|
function getDEV() {
|
|
30
33
|
try {
|
|
31
34
|
return Boolean(__DEV__);
|
|
32
35
|
}
|
|
33
36
|
catch (_a) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Object.defineProperty(global$1, "__DEV__", {
|
|
37
|
-
value: maybeNodeEnv !== "production",
|
|
37
|
+
Object.defineProperty(global$1, GLOBAL_KEY, {
|
|
38
|
+
value: maybe(function () { return process.env.NODE_ENV; }) !== "production",
|
|
38
39
|
enumerable: false,
|
|
39
40
|
configurable: true,
|
|
40
41
|
writable: true,
|
|
41
42
|
});
|
|
42
|
-
|
|
43
|
-
__DEV__ && tsInvariant.invariant.log([
|
|
44
|
-
"Apollo Client has provided a default value for the __DEV__ constant " +
|
|
45
|
-
("(" + global$1.__DEV__ + "), but you may be able to reduce production bundle ") +
|
|
46
|
-
"sizes by configuring your JavaScript minifier to replace __DEV__ with " +
|
|
47
|
-
"false, allowing development-only code to be stripped from the bundle.",
|
|
48
|
-
"",
|
|
49
|
-
"For more information about the switch to __DEV__, see " +
|
|
50
|
-
"https://github.com/apollographql/apollo-client/pull/8347.",
|
|
51
|
-
].join("\n"));
|
|
52
|
-
}
|
|
53
|
-
return global$1.__DEV__;
|
|
43
|
+
return global$1[GLOBAL_KEY];
|
|
54
44
|
}
|
|
55
45
|
}
|
|
56
|
-
var
|
|
46
|
+
var DEV = getDEV();
|
|
47
|
+
|
|
48
|
+
function removeTemporaryGlobals() {
|
|
49
|
+
graphql.isType(null);
|
|
50
|
+
return process$1.remove();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
removeTemporaryGlobals();
|
|
57
54
|
|
|
58
55
|
function shouldInclude(_a, variables) {
|
|
59
56
|
var directives = _a.directives;
|
|
@@ -65,7 +62,7 @@ function shouldInclude(_a, variables) {
|
|
|
65
62
|
var evaledValue = false;
|
|
66
63
|
if (ifArgument.value.kind === 'Variable') {
|
|
67
64
|
evaledValue = variables && variables[ifArgument.value.name.value];
|
|
68
|
-
__DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.") : tsInvariant.invariant(evaledValue !== void 0,
|
|
65
|
+
__DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.") : tsInvariant.invariant(evaledValue !== void 0, 43);
|
|
69
66
|
}
|
|
70
67
|
else {
|
|
71
68
|
evaledValue = ifArgument.value.value;
|
|
@@ -102,13 +99,13 @@ function getInclusionDirectives(directives) {
|
|
|
102
99
|
return;
|
|
103
100
|
var directiveArguments = directive.arguments;
|
|
104
101
|
var directiveName = directive.name.value;
|
|
105
|
-
__DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.") : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1,
|
|
102
|
+
__DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.") : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, 44);
|
|
106
103
|
var ifArgument = directiveArguments[0];
|
|
107
|
-
__DEV__ ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive.") : tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if',
|
|
104
|
+
__DEV__ ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive.") : tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', 45);
|
|
108
105
|
var ifValue = ifArgument.value;
|
|
109
106
|
__DEV__ ? tsInvariant.invariant(ifValue &&
|
|
110
107
|
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @" + directiveName + " directive must be a variable or a boolean value.") : tsInvariant.invariant(ifValue &&
|
|
111
|
-
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'),
|
|
108
|
+
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 46);
|
|
112
109
|
result.push({ directive: directive, ifArgument: ifArgument });
|
|
113
110
|
});
|
|
114
111
|
}
|
|
@@ -121,17 +118,17 @@ function getFragmentQueryDocument(document, fragmentName) {
|
|
|
121
118
|
document.definitions.forEach(function (definition) {
|
|
122
119
|
if (definition.kind === 'OperationDefinition') {
|
|
123
120
|
throw __DEV__ ? new tsInvariant.InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " +
|
|
124
|
-
'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new tsInvariant.InvariantError(
|
|
121
|
+
'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new tsInvariant.InvariantError(47);
|
|
125
122
|
}
|
|
126
123
|
if (definition.kind === 'FragmentDefinition') {
|
|
127
124
|
fragments.push(definition);
|
|
128
125
|
}
|
|
129
126
|
});
|
|
130
127
|
if (typeof actualFragmentName === 'undefined') {
|
|
131
|
-
__DEV__ ? tsInvariant.invariant(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.") : tsInvariant.invariant(fragments.length === 1,
|
|
128
|
+
__DEV__ ? tsInvariant.invariant(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.") : tsInvariant.invariant(fragments.length === 1, 48);
|
|
132
129
|
actualFragmentName = fragments[0].name.value;
|
|
133
130
|
}
|
|
134
|
-
var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.
|
|
131
|
+
var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
|
|
135
132
|
{
|
|
136
133
|
kind: 'OperationDefinition',
|
|
137
134
|
operation: 'query',
|
|
@@ -165,7 +162,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
165
162
|
return selection;
|
|
166
163
|
case 'FragmentSpread': {
|
|
167
164
|
var fragment = fragmentMap && fragmentMap[selection.name.value];
|
|
168
|
-
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value + ".") : tsInvariant.invariant(fragment,
|
|
165
|
+
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value + ".") : tsInvariant.invariant(fragment, 49);
|
|
169
166
|
return fragment;
|
|
170
167
|
}
|
|
171
168
|
default:
|
|
@@ -249,7 +246,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
|
|
|
249
246
|
else {
|
|
250
247
|
throw __DEV__ ? new tsInvariant.InvariantError("The inline argument \"" + name.value + "\" of kind \"" + value.kind + "\"" +
|
|
251
248
|
'is not supported. Use variables instead of inline arguments to ' +
|
|
252
|
-
'overcome this limitation.') : new tsInvariant.InvariantError(
|
|
249
|
+
'overcome this limitation.') : new tsInvariant.InvariantError(58);
|
|
253
250
|
}
|
|
254
251
|
}
|
|
255
252
|
function storeKeyNameFromField(field, variables) {
|
|
@@ -383,16 +380,16 @@ function isInlineFragment(selection) {
|
|
|
383
380
|
}
|
|
384
381
|
|
|
385
382
|
function checkDocument(doc) {
|
|
386
|
-
__DEV__ ? tsInvariant.invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : tsInvariant.invariant(doc && doc.kind === 'Document',
|
|
383
|
+
__DEV__ ? tsInvariant.invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : tsInvariant.invariant(doc && doc.kind === 'Document', 50);
|
|
387
384
|
var operations = doc.definitions
|
|
388
385
|
.filter(function (d) { return d.kind !== 'FragmentDefinition'; })
|
|
389
386
|
.map(function (definition) {
|
|
390
387
|
if (definition.kind !== 'OperationDefinition') {
|
|
391
|
-
throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"") : new tsInvariant.InvariantError(
|
|
388
|
+
throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"") : new tsInvariant.InvariantError(51);
|
|
392
389
|
}
|
|
393
390
|
return definition;
|
|
394
391
|
});
|
|
395
|
-
__DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations") : tsInvariant.invariant(operations.length <= 1,
|
|
392
|
+
__DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations") : tsInvariant.invariant(operations.length <= 1, 52);
|
|
396
393
|
return doc;
|
|
397
394
|
}
|
|
398
395
|
function getOperationDefinition(doc) {
|
|
@@ -411,14 +408,14 @@ function getFragmentDefinitions(doc) {
|
|
|
411
408
|
}
|
|
412
409
|
function getQueryDefinition(doc) {
|
|
413
410
|
var queryDef = getOperationDefinition(doc);
|
|
414
|
-
__DEV__ ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : tsInvariant.invariant(queryDef && queryDef.operation === 'query',
|
|
411
|
+
__DEV__ ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : tsInvariant.invariant(queryDef && queryDef.operation === 'query', 53);
|
|
415
412
|
return queryDef;
|
|
416
413
|
}
|
|
417
414
|
function getFragmentDefinition(doc) {
|
|
418
|
-
__DEV__ ? tsInvariant.invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : tsInvariant.invariant(doc.kind === 'Document',
|
|
419
|
-
__DEV__ ? tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : tsInvariant.invariant(doc.definitions.length <= 1,
|
|
415
|
+
__DEV__ ? tsInvariant.invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : tsInvariant.invariant(doc.kind === 'Document', 54);
|
|
416
|
+
__DEV__ ? tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : tsInvariant.invariant(doc.definitions.length <= 1, 55);
|
|
420
417
|
var fragmentDef = doc.definitions[0];
|
|
421
|
-
__DEV__ ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition',
|
|
418
|
+
__DEV__ ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 56);
|
|
422
419
|
return fragmentDef;
|
|
423
420
|
}
|
|
424
421
|
function getMainDefinition(queryDoc) {
|
|
@@ -441,7 +438,7 @@ function getMainDefinition(queryDoc) {
|
|
|
441
438
|
if (fragmentDefinition) {
|
|
442
439
|
return fragmentDefinition;
|
|
443
440
|
}
|
|
444
|
-
throw __DEV__ ? new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new tsInvariant.InvariantError(
|
|
441
|
+
throw __DEV__ ? new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new tsInvariant.InvariantError(57);
|
|
445
442
|
}
|
|
446
443
|
function getDefaultValues(definition) {
|
|
447
444
|
var defaultValues = Object.create(null);
|
|
@@ -584,7 +581,7 @@ var addTypenameToDocument = Object.assign(function (doc) {
|
|
|
584
581
|
field.directives.some(function (d) { return d.name.value === 'export'; })) {
|
|
585
582
|
return;
|
|
586
583
|
}
|
|
587
|
-
return tslib.__assign(tslib.__assign({}, node), { selections: tslib.
|
|
584
|
+
return tslib.__assign(tslib.__assign({}, node), { selections: tslib.__spreadArray(tslib.__spreadArray([], selections), [TYPENAME_FIELD]) });
|
|
588
585
|
},
|
|
589
586
|
},
|
|
590
587
|
});
|
|
@@ -763,7 +760,7 @@ var DeepMerger = (function () {
|
|
|
763
760
|
if (hasOwnProperty$2.call(target, sourceKey)) {
|
|
764
761
|
var targetValue = target[sourceKey];
|
|
765
762
|
if (source[sourceKey] !== targetValue) {
|
|
766
|
-
var result = _this.reconciler.apply(_this, tslib.
|
|
763
|
+
var result = _this.reconciler.apply(_this, tslib.__spreadArray([target, source, sourceKey], context));
|
|
767
764
|
if (result !== targetValue) {
|
|
768
765
|
target = _this.shallowCopyForMerge(target);
|
|
769
766
|
target[sourceKey] = result;
|
|
@@ -1054,6 +1051,7 @@ function graphQLResultHasError(result) {
|
|
|
1054
1051
|
|
|
1055
1052
|
var canUseWeakMap = typeof WeakMap === 'function' && !(typeof navigator === 'object' &&
|
|
1056
1053
|
navigator.product === 'ReactNative');
|
|
1054
|
+
var canUseWeakSet = typeof WeakSet === 'function';
|
|
1057
1055
|
|
|
1058
1056
|
function compact() {
|
|
1059
1057
|
var objects = [];
|
|
@@ -1081,6 +1079,15 @@ function makeUniqueId(prefix) {
|
|
|
1081
1079
|
return prefix + ":" + count + ":" + Math.random().toString(36).slice(2);
|
|
1082
1080
|
}
|
|
1083
1081
|
|
|
1082
|
+
function stringifyForDisplay(value) {
|
|
1083
|
+
var undefId = makeUniqueId("stringifyForDisplay");
|
|
1084
|
+
return JSON.stringify(value, function (key, value) {
|
|
1085
|
+
return value === void 0 ? undefId : value;
|
|
1086
|
+
}).split(JSON.stringify(undefId)).join("<undefined>");
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
__DEV__ ? tsInvariant.invariant("boolean" === typeof DEV, DEV) : tsInvariant.invariant("boolean" === typeof DEV, 59);
|
|
1090
|
+
|
|
1084
1091
|
function fromError(errorValue) {
|
|
1085
1092
|
return new zenObservableTs.Observable(function (observer) {
|
|
1086
1093
|
observer.error(errorValue);
|
|
@@ -1136,7 +1143,7 @@ function validateOperation(operation) {
|
|
|
1136
1143
|
for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
|
|
1137
1144
|
var key = _a[_i];
|
|
1138
1145
|
if (OPERATION_FIELDS.indexOf(key) < 0) {
|
|
1139
|
-
throw __DEV__ ? new tsInvariant.InvariantError("illegal argument: " + key) : new tsInvariant.InvariantError(
|
|
1146
|
+
throw __DEV__ ? new tsInvariant.InvariantError("illegal argument: " + key) : new tsInvariant.InvariantError(29);
|
|
1140
1147
|
}
|
|
1141
1148
|
}
|
|
1142
1149
|
return operation;
|
|
@@ -1259,7 +1266,7 @@ var ApolloLink = (function () {
|
|
|
1259
1266
|
return ApolloLink.concat(this, next);
|
|
1260
1267
|
};
|
|
1261
1268
|
ApolloLink.prototype.request = function (operation, forward) {
|
|
1262
|
-
throw __DEV__ ? new tsInvariant.InvariantError('request is not implemented') : new tsInvariant.InvariantError(
|
|
1269
|
+
throw __DEV__ ? new tsInvariant.InvariantError('request is not implemented') : new tsInvariant.InvariantError(23);
|
|
1263
1270
|
};
|
|
1264
1271
|
ApolloLink.prototype.onError = function (error, observer) {
|
|
1265
1272
|
if (observer && observer.error) {
|
|
@@ -1285,7 +1292,7 @@ var concat = ApolloLink.concat;
|
|
|
1285
1292
|
|
|
1286
1293
|
var execute = ApolloLink.execute;
|
|
1287
1294
|
|
|
1288
|
-
var version = '3.4.
|
|
1295
|
+
var version = '3.4.1';
|
|
1289
1296
|
|
|
1290
1297
|
var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
1291
1298
|
function parseAndCheckHttpResponse(operations) {
|
|
@@ -1325,7 +1332,7 @@ var serializeFetchParameter = function (p, label) {
|
|
|
1325
1332
|
serialized = JSON.stringify(p);
|
|
1326
1333
|
}
|
|
1327
1334
|
catch (e) {
|
|
1328
|
-
var parseError = __DEV__ ? new tsInvariant.InvariantError("Network request failed. " + label + " is not serializable: " + e.message) : new tsInvariant.InvariantError(
|
|
1335
|
+
var parseError = __DEV__ ? new tsInvariant.InvariantError("Network request failed. " + label + " is not serializable: " + e.message) : new tsInvariant.InvariantError(26);
|
|
1329
1336
|
parseError.parseError = e;
|
|
1330
1337
|
throw parseError;
|
|
1331
1338
|
}
|
|
@@ -1356,7 +1363,7 @@ var selectHttpOptionsAndBody = function (operation, fallbackConfig) {
|
|
|
1356
1363
|
var options = tslib.__assign(tslib.__assign({}, fallbackConfig.options), { headers: fallbackConfig.headers, credentials: fallbackConfig.credentials });
|
|
1357
1364
|
var http = fallbackConfig.http || {};
|
|
1358
1365
|
configs.forEach(function (config) {
|
|
1359
|
-
options = tslib.__assign(tslib.__assign(tslib.__assign({}, options), config.options), { headers: tslib.__assign(tslib.__assign({}, options.headers), config.headers) });
|
|
1366
|
+
options = tslib.__assign(tslib.__assign(tslib.__assign({}, options), config.options), { headers: tslib.__assign(tslib.__assign({}, options.headers), headersToLowerCase(config.headers)) });
|
|
1360
1367
|
if (config.credentials)
|
|
1361
1368
|
options.credentials = config.credentials;
|
|
1362
1369
|
http = tslib.__assign(tslib.__assign({}, http), config.http);
|
|
@@ -1372,10 +1379,20 @@ var selectHttpOptionsAndBody = function (operation, fallbackConfig) {
|
|
|
1372
1379
|
body: body,
|
|
1373
1380
|
};
|
|
1374
1381
|
};
|
|
1382
|
+
function headersToLowerCase(headers) {
|
|
1383
|
+
if (headers) {
|
|
1384
|
+
var normalized_1 = Object.create(null);
|
|
1385
|
+
Object.keys(Object(headers)).forEach(function (name) {
|
|
1386
|
+
normalized_1[name.toLowerCase()] = headers[name];
|
|
1387
|
+
});
|
|
1388
|
+
return normalized_1;
|
|
1389
|
+
}
|
|
1390
|
+
return headers;
|
|
1391
|
+
}
|
|
1375
1392
|
|
|
1376
1393
|
var checkFetcher = function (fetcher) {
|
|
1377
1394
|
if (!fetcher && typeof fetch === 'undefined') {
|
|
1378
|
-
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(
|
|
1395
|
+
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(25);
|
|
1379
1396
|
}
|
|
1380
1397
|
};
|
|
1381
1398
|
|
|
@@ -1742,6 +1759,10 @@ var EntityStore = (function () {
|
|
|
1742
1759
|
EntityStore.prototype.merge = function (older, newer) {
|
|
1743
1760
|
var _this = this;
|
|
1744
1761
|
var dataId;
|
|
1762
|
+
if (isReference(older))
|
|
1763
|
+
older = older.__ref;
|
|
1764
|
+
if (isReference(newer))
|
|
1765
|
+
newer = newer.__ref;
|
|
1745
1766
|
var existing = typeof older === "string"
|
|
1746
1767
|
? this.lookup(dataId = older)
|
|
1747
1768
|
: older;
|
|
@@ -1750,7 +1771,7 @@ var EntityStore = (function () {
|
|
|
1750
1771
|
: newer;
|
|
1751
1772
|
if (!incoming)
|
|
1752
1773
|
return;
|
|
1753
|
-
__DEV__ ? tsInvariant.invariant(typeof dataId === "string", "store.merge expects a string ID") : tsInvariant.invariant(typeof dataId === "string",
|
|
1774
|
+
__DEV__ ? tsInvariant.invariant(typeof dataId === "string", "store.merge expects a string ID") : tsInvariant.invariant(typeof dataId === "string", 2);
|
|
1754
1775
|
var merged = new DeepMerger(storeObjectReconciler).merge(existing, incoming);
|
|
1755
1776
|
this.data[dataId] = merged;
|
|
1756
1777
|
if (merged !== existing) {
|
|
@@ -1809,8 +1830,7 @@ var EntityStore = (function () {
|
|
|
1809
1830
|
: fields[storeFieldName] || fields[fieldName];
|
|
1810
1831
|
if (modify) {
|
|
1811
1832
|
var newValue = modify === delModifier ? DELETE :
|
|
1812
|
-
modify(maybeDeepFreeze(fieldValue), tslib.__assign(tslib.__assign({}, sharedDetails_1), { fieldName: fieldName,
|
|
1813
|
-
storeFieldName: storeFieldName, storage: _this.getStorage(dataId, storeFieldName) }));
|
|
1833
|
+
modify(maybeDeepFreeze(fieldValue), tslib.__assign(tslib.__assign({}, sharedDetails_1), { fieldName: fieldName, storeFieldName: storeFieldName, storage: _this.getStorage(dataId, storeFieldName) }));
|
|
1814
1834
|
if (newValue === INVALIDATE) {
|
|
1815
1835
|
_this.group.dirty(dataId, storeFieldName);
|
|
1816
1836
|
}
|
|
@@ -1952,15 +1972,21 @@ var EntityStore = (function () {
|
|
|
1952
1972
|
EntityStore.prototype.findChildRefIds = function (dataId) {
|
|
1953
1973
|
if (!hasOwn.call(this.refs, dataId)) {
|
|
1954
1974
|
var found_1 = this.refs[dataId] = Object.create(null);
|
|
1955
|
-
var
|
|
1975
|
+
var root = this.data[dataId];
|
|
1976
|
+
if (!root)
|
|
1977
|
+
return found_1;
|
|
1978
|
+
var workSet_1 = new Set([root]);
|
|
1956
1979
|
workSet_1.forEach(function (obj) {
|
|
1957
1980
|
if (isReference(obj)) {
|
|
1958
1981
|
found_1[obj.__ref] = true;
|
|
1959
1982
|
}
|
|
1960
|
-
|
|
1961
|
-
Object.
|
|
1962
|
-
|
|
1963
|
-
|
|
1983
|
+
if (isNonNullObject(obj)) {
|
|
1984
|
+
Object.keys(obj).forEach(function (key) {
|
|
1985
|
+
var child = obj[key];
|
|
1986
|
+
if (isNonNullObject(child)) {
|
|
1987
|
+
workSet_1.add(child);
|
|
1988
|
+
}
|
|
1989
|
+
});
|
|
1964
1990
|
}
|
|
1965
1991
|
});
|
|
1966
1992
|
}
|
|
@@ -1977,9 +2003,12 @@ var CacheGroup = (function () {
|
|
|
1977
2003
|
this.caching = caching;
|
|
1978
2004
|
this.parent = parent;
|
|
1979
2005
|
this.d = null;
|
|
1980
|
-
this.
|
|
1981
|
-
this.d = caching ? optimism.dep() : null;
|
|
2006
|
+
this.resetCaching();
|
|
1982
2007
|
}
|
|
2008
|
+
CacheGroup.prototype.resetCaching = function () {
|
|
2009
|
+
this.d = this.caching ? optimism.dep() : null;
|
|
2010
|
+
this.keyMaker = new trie.Trie(canUseWeakMap);
|
|
2011
|
+
};
|
|
1983
2012
|
CacheGroup.prototype.depend = function (dataId, storeFieldName) {
|
|
1984
2013
|
if (this.d) {
|
|
1985
2014
|
this.d(makeDepKey(dataId, storeFieldName));
|
|
@@ -2125,7 +2154,7 @@ function shallowCopy(value) {
|
|
|
2125
2154
|
}
|
|
2126
2155
|
var ObjectCanon = (function () {
|
|
2127
2156
|
function ObjectCanon() {
|
|
2128
|
-
this.known = new (
|
|
2157
|
+
this.known = new (canUseWeakSet ? WeakSet : Set)();
|
|
2129
2158
|
this.pool = new trie.Trie(canUseWeakMap);
|
|
2130
2159
|
this.passes = new WeakMap();
|
|
2131
2160
|
this.keysByJSON = new Map();
|
|
@@ -2208,6 +2237,9 @@ var ObjectCanon = (function () {
|
|
|
2208
2237
|
}());
|
|
2209
2238
|
var canonicalStringify = Object.assign(function (value) {
|
|
2210
2239
|
if (isNonNullObject(value)) {
|
|
2240
|
+
if (stringifyCanon === void 0) {
|
|
2241
|
+
resetCanonicalStringify();
|
|
2242
|
+
}
|
|
2211
2243
|
var canonical = stringifyCanon.admit(value);
|
|
2212
2244
|
var json = stringifyCache.get(canonical);
|
|
2213
2245
|
if (json === void 0) {
|
|
@@ -2217,12 +2249,14 @@ var canonicalStringify = Object.assign(function (value) {
|
|
|
2217
2249
|
}
|
|
2218
2250
|
return JSON.stringify(value);
|
|
2219
2251
|
}, {
|
|
2220
|
-
reset:
|
|
2221
|
-
stringifyCanon = new ObjectCanon;
|
|
2222
|
-
},
|
|
2252
|
+
reset: resetCanonicalStringify,
|
|
2223
2253
|
});
|
|
2224
|
-
var stringifyCanon
|
|
2225
|
-
var stringifyCache
|
|
2254
|
+
var stringifyCanon;
|
|
2255
|
+
var stringifyCache;
|
|
2256
|
+
function resetCanonicalStringify() {
|
|
2257
|
+
stringifyCanon = new ObjectCanon;
|
|
2258
|
+
stringifyCache = new (canUseWeakMap ? WeakMap : Map)();
|
|
2259
|
+
}
|
|
2226
2260
|
|
|
2227
2261
|
function missingFromInvariant(err, context) {
|
|
2228
2262
|
return new MissingFieldError(err.message, context.path.slice(), context.query, context.variables);
|
|
@@ -2238,9 +2272,9 @@ function execSelectionSetKeyArgs(options) {
|
|
|
2238
2272
|
var StoreReader = (function () {
|
|
2239
2273
|
function StoreReader(config) {
|
|
2240
2274
|
var _this = this;
|
|
2241
|
-
this.
|
|
2242
|
-
this.knownResults = new WeakMap();
|
|
2275
|
+
this.knownResults = new (canUseWeakMap ? WeakMap : Map)();
|
|
2243
2276
|
this.config = tslib.__assign(tslib.__assign({}, config), { addTypename: config.addTypename !== false });
|
|
2277
|
+
this.canon = config.canon || new ObjectCanon;
|
|
2244
2278
|
this.executeSelectionSet = optimism.wrap(function (options) {
|
|
2245
2279
|
var _a;
|
|
2246
2280
|
var canonizeResults = options.context.canonizeResults;
|
|
@@ -2277,6 +2311,9 @@ var StoreReader = (function () {
|
|
|
2277
2311
|
}
|
|
2278
2312
|
});
|
|
2279
2313
|
}
|
|
2314
|
+
StoreReader.prototype.resetCanon = function () {
|
|
2315
|
+
this.canon = new ObjectCanon;
|
|
2316
|
+
};
|
|
2280
2317
|
StoreReader.prototype.diffQueryAgainstStore = function (_a) {
|
|
2281
2318
|
var store = _a.store, query = _a.query, _b = _a.rootId, rootId = _b === void 0 ? 'ROOT_QUERY' : _b, variables = _a.variables, _c = _a.returnPartialData, returnPartialData = _c === void 0 ? true : _c, _d = _a.canonizeResults, canonizeResults = _d === void 0 ? true : _d;
|
|
2282
2319
|
var policies = this.config.cache.policies;
|
|
@@ -2325,7 +2362,7 @@ var StoreReader = (function () {
|
|
|
2325
2362
|
!context.store.has(objectOrReference.__ref)) {
|
|
2326
2363
|
return {
|
|
2327
2364
|
result: this.canon.empty,
|
|
2328
|
-
missing: [missingFromInvariant(__DEV__ ? new tsInvariant.InvariantError("Dangling reference to missing " + objectOrReference.__ref + " object") : new tsInvariant.InvariantError(
|
|
2365
|
+
missing: [missingFromInvariant(__DEV__ ? new tsInvariant.InvariantError("Dangling reference to missing " + objectOrReference.__ref + " object") : new tsInvariant.InvariantError(6), context)],
|
|
2329
2366
|
};
|
|
2330
2367
|
}
|
|
2331
2368
|
var variables = context.variables, policies = context.policies, store = context.store;
|
|
@@ -2364,7 +2401,7 @@ var StoreReader = (function () {
|
|
|
2364
2401
|
if (!addTypenameToDocument.added(selection)) {
|
|
2365
2402
|
getMissing().push(missingFromInvariant(__DEV__ ? new tsInvariant.InvariantError("Can't find field '" + selection.name.value + "' on " + (isReference(objectOrReference)
|
|
2366
2403
|
? objectOrReference.__ref + " object"
|
|
2367
|
-
: "object " + JSON.stringify(objectOrReference, null, 2))) : new tsInvariant.InvariantError(
|
|
2404
|
+
: "object " + JSON.stringify(objectOrReference, null, 2))) : new tsInvariant.InvariantError(7), context));
|
|
2368
2405
|
}
|
|
2369
2406
|
}
|
|
2370
2407
|
else if (Array.isArray(fieldValue)) {
|
|
@@ -2461,7 +2498,7 @@ function assertSelectionSetForIdValue(store, field, fieldValue) {
|
|
|
2461
2498
|
var workSet_1 = new Set([fieldValue]);
|
|
2462
2499
|
workSet_1.forEach(function (value) {
|
|
2463
2500
|
if (isNonNullObject(value)) {
|
|
2464
|
-
__DEV__ ? tsInvariant.invariant(!isReference(value), "Missing selection set for object of type " + getTypenameFromStoreObject(store, value) + " returned for query field " + field.name.value) : tsInvariant.invariant(!isReference(value),
|
|
2501
|
+
__DEV__ ? tsInvariant.invariant(!isReference(value), "Missing selection set for object of type " + getTypenameFromStoreObject(store, value) + " returned for query field " + field.name.value) : tsInvariant.invariant(!isReference(value), 8);
|
|
2465
2502
|
Object.values(value).forEach(workSet_1.add, workSet_1);
|
|
2466
2503
|
}
|
|
2467
2504
|
});
|
|
@@ -2490,6 +2527,7 @@ var StoreWriter = (function () {
|
|
|
2490
2527
|
fragmentMap: createFragmentMap(getFragmentDefinitions(query)),
|
|
2491
2528
|
overwrite: !!overwrite,
|
|
2492
2529
|
incomingById: new Map,
|
|
2530
|
+
clientOnly: false,
|
|
2493
2531
|
};
|
|
2494
2532
|
var ref = this.processSelectionSet({
|
|
2495
2533
|
result: result || Object.create(null),
|
|
@@ -2499,13 +2537,17 @@ var StoreWriter = (function () {
|
|
|
2499
2537
|
context: context,
|
|
2500
2538
|
});
|
|
2501
2539
|
if (!isReference(ref)) {
|
|
2502
|
-
throw __DEV__ ? new tsInvariant.InvariantError("Could not identify object " + JSON.stringify(result)) : new tsInvariant.InvariantError(
|
|
2540
|
+
throw __DEV__ ? new tsInvariant.InvariantError("Could not identify object " + JSON.stringify(result)) : new tsInvariant.InvariantError(9);
|
|
2503
2541
|
}
|
|
2504
2542
|
context.incomingById.forEach(function (_a, dataId) {
|
|
2505
2543
|
var fields = _a.fields, mergeTree = _a.mergeTree, selections = _a.selections;
|
|
2506
2544
|
var entityRef = makeReference(dataId);
|
|
2507
2545
|
if (mergeTree.map.size) {
|
|
2508
|
-
|
|
2546
|
+
var applied = _this.applyMerges(mergeTree, entityRef, fields, context);
|
|
2547
|
+
if (isReference(applied)) {
|
|
2548
|
+
return;
|
|
2549
|
+
}
|
|
2550
|
+
fields = applied;
|
|
2509
2551
|
}
|
|
2510
2552
|
if (__DEV__ && !context.overwrite) {
|
|
2511
2553
|
var hasSelectionSet_1 = function (storeFieldName) {
|
|
@@ -2567,7 +2609,10 @@ var StoreWriter = (function () {
|
|
|
2567
2609
|
if (isField(selection)) {
|
|
2568
2610
|
var resultFieldKey = resultKeyNameFromField(selection);
|
|
2569
2611
|
var value = result[resultFieldKey];
|
|
2570
|
-
|
|
2612
|
+
var wasClientOnly = context.clientOnly;
|
|
2613
|
+
context.clientOnly = wasClientOnly || !!(selection.directives &&
|
|
2614
|
+
selection.directives.some(function (d) { return d.name.value === "client"; }));
|
|
2615
|
+
if (value !== void 0) {
|
|
2571
2616
|
var storeFieldName = policies.getStoreFieldName({
|
|
2572
2617
|
typename: typename,
|
|
2573
2618
|
fieldName: selection.name.value,
|
|
@@ -2599,10 +2644,11 @@ var StoreWriter = (function () {
|
|
|
2599
2644
|
_a[storeFieldName] = incomingValue,
|
|
2600
2645
|
_a));
|
|
2601
2646
|
}
|
|
2602
|
-
else if (
|
|
2603
|
-
!
|
|
2604
|
-
|
|
2647
|
+
else if (!context.clientOnly &&
|
|
2648
|
+
!addTypenameToDocument.added(selection)) {
|
|
2649
|
+
__DEV__ && tsInvariant.invariant.error(("Missing field '" + resultKeyNameFromField(selection) + "' while writing result " + JSON.stringify(result, null, 2)).substring(0, 1000));
|
|
2605
2650
|
}
|
|
2651
|
+
context.clientOnly = wasClientOnly;
|
|
2606
2652
|
}
|
|
2607
2653
|
else {
|
|
2608
2654
|
var fragment = getFragmentFromSelection(selection, context.fragmentMap);
|
|
@@ -2988,7 +3034,7 @@ var Policies = (function () {
|
|
|
2988
3034
|
var rootId = "ROOT_" + which.toUpperCase();
|
|
2989
3035
|
var old = this.rootTypenamesById[rootId];
|
|
2990
3036
|
if (typename !== old) {
|
|
2991
|
-
__DEV__ ? tsInvariant.invariant(!old || old === which, "Cannot change root " + which + " __typename more than once") : tsInvariant.invariant(!old || old === which,
|
|
3037
|
+
__DEV__ ? tsInvariant.invariant(!old || old === which, "Cannot change root " + which + " __typename more than once") : tsInvariant.invariant(!old || old === which, 3);
|
|
2992
3038
|
if (old)
|
|
2993
3039
|
delete this.rootIdsByTypename[old];
|
|
2994
3040
|
this.rootIdsByTypename[typename] = rootId;
|
|
@@ -3201,12 +3247,25 @@ function makeFieldFunctionOptions(policies, objectOrReference, fieldSpec, contex
|
|
|
3201
3247
|
cache: policies.cache,
|
|
3202
3248
|
canRead: canRead,
|
|
3203
3249
|
readField: function (fieldNameOrOptions, from) {
|
|
3204
|
-
var options
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3250
|
+
var options;
|
|
3251
|
+
if (typeof fieldNameOrOptions === "string") {
|
|
3252
|
+
options = {
|
|
3253
|
+
fieldName: fieldNameOrOptions,
|
|
3254
|
+
from: arguments.length > 1 ? from : objectOrReference,
|
|
3255
|
+
};
|
|
3256
|
+
}
|
|
3257
|
+
else if (isNonNullObject(fieldNameOrOptions)) {
|
|
3258
|
+
options = tslib.__assign({}, fieldNameOrOptions);
|
|
3259
|
+
if (!hasOwn.call(fieldNameOrOptions, "from")) {
|
|
3260
|
+
options.from = objectOrReference;
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
else {
|
|
3264
|
+
__DEV__ && tsInvariant.invariant.warn("Unexpected readField arguments: " + stringifyForDisplay(Array.from(arguments)));
|
|
3265
|
+
return;
|
|
3266
|
+
}
|
|
3267
|
+
if (__DEV__ && options.from === void 0) {
|
|
3268
|
+
__DEV__ && tsInvariant.invariant.warn("Undefined 'from' passed to readField with arguments " + stringifyForDisplay(Array.from(arguments)));
|
|
3210
3269
|
}
|
|
3211
3270
|
if (void 0 === options.variables) {
|
|
3212
3271
|
options.variables = variables;
|
|
@@ -3219,7 +3278,7 @@ function makeFieldFunctionOptions(policies, objectOrReference, fieldSpec, contex
|
|
|
3219
3278
|
function makeMergeObjectsFunction(store) {
|
|
3220
3279
|
return function mergeObjects(existing, incoming) {
|
|
3221
3280
|
if (Array.isArray(existing) || Array.isArray(incoming)) {
|
|
3222
|
-
throw __DEV__ ? new tsInvariant.InvariantError("Cannot automatically merge arrays") : new tsInvariant.InvariantError(
|
|
3281
|
+
throw __DEV__ ? new tsInvariant.InvariantError("Cannot automatically merge arrays") : new tsInvariant.InvariantError(4);
|
|
3223
3282
|
}
|
|
3224
3283
|
if (isNonNullObject(existing) &&
|
|
3225
3284
|
isNonNullObject(incoming)) {
|
|
@@ -3316,7 +3375,7 @@ function computeKeyObject(response, specifier, strict, aliasMap) {
|
|
|
3316
3375
|
keyObj[prevKey = s] = response[responseName];
|
|
3317
3376
|
}
|
|
3318
3377
|
else {
|
|
3319
|
-
__DEV__ ? tsInvariant.invariant(!strict, "Missing field '" + responseName + "' while computing key fields") : tsInvariant.invariant(!strict,
|
|
3378
|
+
__DEV__ ? tsInvariant.invariant(!strict, "Missing field '" + responseName + "' while computing key fields") : tsInvariant.invariant(!strict, 5);
|
|
3320
3379
|
prevKey = void 0;
|
|
3321
3380
|
}
|
|
3322
3381
|
}
|
|
@@ -3351,16 +3410,23 @@ var InMemoryCache = (function (_super) {
|
|
|
3351
3410
|
return _this;
|
|
3352
3411
|
}
|
|
3353
3412
|
InMemoryCache.prototype.init = function () {
|
|
3354
|
-
var _this = this;
|
|
3355
3413
|
var rootStore = this.data = new EntityStore.Root({
|
|
3356
3414
|
policies: this.policies,
|
|
3357
3415
|
resultCaching: this.config.resultCaching,
|
|
3358
3416
|
});
|
|
3359
3417
|
this.optimisticData = rootStore.stump;
|
|
3418
|
+
this.resetResultCache();
|
|
3419
|
+
};
|
|
3420
|
+
InMemoryCache.prototype.resetResultCache = function (resetResultIdentities) {
|
|
3421
|
+
var _this = this;
|
|
3422
|
+
var previousReader = this.storeReader;
|
|
3360
3423
|
this.storeWriter = new StoreWriter(this, this.storeReader = new StoreReader({
|
|
3361
3424
|
cache: this,
|
|
3362
3425
|
addTypename: this.addTypename,
|
|
3363
3426
|
resultCacheMaxSize: this.config.resultCacheMaxSize,
|
|
3427
|
+
canon: resetResultIdentities
|
|
3428
|
+
? void 0
|
|
3429
|
+
: previousReader && previousReader.canon,
|
|
3364
3430
|
}));
|
|
3365
3431
|
this.maybeBroadcastWatch = optimism.wrap(function (c, options) {
|
|
3366
3432
|
return _this.broadcastWatch(c, options);
|
|
@@ -3374,8 +3440,13 @@ var InMemoryCache = (function (_super) {
|
|
|
3374
3440
|
}
|
|
3375
3441
|
}
|
|
3376
3442
|
});
|
|
3443
|
+
new Set([
|
|
3444
|
+
this.data.group,
|
|
3445
|
+
this.optimisticData.group,
|
|
3446
|
+
]).forEach(function (group) { return group.resetCaching(); });
|
|
3377
3447
|
};
|
|
3378
3448
|
InMemoryCache.prototype.restore = function (data) {
|
|
3449
|
+
this.init();
|
|
3379
3450
|
if (data)
|
|
3380
3451
|
this.data.replace(data);
|
|
3381
3452
|
return this;
|
|
@@ -3443,9 +3514,18 @@ var InMemoryCache = (function (_super) {
|
|
|
3443
3514
|
_this.maybeBroadcastWatch.forget(watch);
|
|
3444
3515
|
};
|
|
3445
3516
|
};
|
|
3446
|
-
InMemoryCache.prototype.gc = function () {
|
|
3517
|
+
InMemoryCache.prototype.gc = function (options) {
|
|
3447
3518
|
canonicalStringify.reset();
|
|
3448
|
-
|
|
3519
|
+
var ids = this.optimisticData.gc();
|
|
3520
|
+
if (options && !this.txCount) {
|
|
3521
|
+
if (options.resetResultCache) {
|
|
3522
|
+
this.resetResultCache(options.resetResultIdentities);
|
|
3523
|
+
}
|
|
3524
|
+
else if (options.resetResultIdentities) {
|
|
3525
|
+
this.storeReader.resetCanon();
|
|
3526
|
+
}
|
|
3527
|
+
}
|
|
3528
|
+
return ids;
|
|
3449
3529
|
};
|
|
3450
3530
|
InMemoryCache.prototype.retain = function (rootId, optimistic) {
|
|
3451
3531
|
return (optimistic ? this.optimisticData : this.data).retain(rootId);
|
|
@@ -3588,6 +3668,7 @@ var InMemoryCache = (function (_super) {
|
|
|
3588
3668
|
return InMemoryCache;
|
|
3589
3669
|
}(ApolloCache));
|
|
3590
3670
|
|
|
3671
|
+
__DEV__ ? tsInvariant.invariant("boolean" === typeof DEV, DEV) : tsInvariant.invariant("boolean" === typeof DEV, 22);
|
|
3591
3672
|
function isApolloError(err) {
|
|
3592
3673
|
return err.hasOwnProperty('graphQLErrors');
|
|
3593
3674
|
}
|
|
@@ -3639,95 +3720,35 @@ function isNetworkRequestInFlight(networkStatus) {
|
|
|
3639
3720
|
return networkStatus ? networkStatus < 7 : false;
|
|
3640
3721
|
}
|
|
3641
3722
|
|
|
3642
|
-
var Reobserver = (function () {
|
|
3643
|
-
function Reobserver(observer, options, fetch, shouldFetch) {
|
|
3644
|
-
this.observer = observer;
|
|
3645
|
-
this.options = options;
|
|
3646
|
-
this.fetch = fetch;
|
|
3647
|
-
this.shouldFetch = shouldFetch;
|
|
3648
|
-
}
|
|
3649
|
-
Reobserver.prototype.reobserve = function (newOptions, newNetworkStatus) {
|
|
3650
|
-
if (newOptions) {
|
|
3651
|
-
this.updateOptions(newOptions);
|
|
3652
|
-
}
|
|
3653
|
-
else {
|
|
3654
|
-
this.updatePolling();
|
|
3655
|
-
}
|
|
3656
|
-
var concast = this.fetch(this.options, newNetworkStatus);
|
|
3657
|
-
if (this.concast) {
|
|
3658
|
-
this.concast.removeObserver(this.observer, true);
|
|
3659
|
-
}
|
|
3660
|
-
concast.addObserver(this.observer);
|
|
3661
|
-
return (this.concast = concast).promise;
|
|
3662
|
-
};
|
|
3663
|
-
Reobserver.prototype.updateOptions = function (newOptions) {
|
|
3664
|
-
Object.assign(this.options, compact(newOptions));
|
|
3665
|
-
this.updatePolling();
|
|
3666
|
-
return this;
|
|
3667
|
-
};
|
|
3668
|
-
Reobserver.prototype.stop = function () {
|
|
3669
|
-
if (this.concast) {
|
|
3670
|
-
this.concast.removeObserver(this.observer);
|
|
3671
|
-
delete this.concast;
|
|
3672
|
-
}
|
|
3673
|
-
if (this.pollingInfo) {
|
|
3674
|
-
clearTimeout(this.pollingInfo.timeout);
|
|
3675
|
-
this.options.pollInterval = 0;
|
|
3676
|
-
this.updatePolling();
|
|
3677
|
-
}
|
|
3678
|
-
};
|
|
3679
|
-
Reobserver.prototype.updatePolling = function () {
|
|
3680
|
-
var _this = this;
|
|
3681
|
-
var _a = this, pollingInfo = _a.pollingInfo, pollInterval = _a.options.pollInterval;
|
|
3682
|
-
if (!pollInterval) {
|
|
3683
|
-
if (pollingInfo) {
|
|
3684
|
-
clearTimeout(pollingInfo.timeout);
|
|
3685
|
-
delete this.pollingInfo;
|
|
3686
|
-
}
|
|
3687
|
-
return;
|
|
3688
|
-
}
|
|
3689
|
-
if (pollingInfo &&
|
|
3690
|
-
pollingInfo.interval === pollInterval) {
|
|
3691
|
-
return;
|
|
3692
|
-
}
|
|
3693
|
-
__DEV__ ? tsInvariant.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : tsInvariant.invariant(pollInterval, 21);
|
|
3694
|
-
if (this.shouldFetch === false) {
|
|
3695
|
-
return;
|
|
3696
|
-
}
|
|
3697
|
-
var info = pollingInfo || (this.pollingInfo = {});
|
|
3698
|
-
info.interval = pollInterval;
|
|
3699
|
-
var maybeFetch = function () {
|
|
3700
|
-
if (_this.pollingInfo) {
|
|
3701
|
-
if (_this.shouldFetch && _this.shouldFetch()) {
|
|
3702
|
-
_this.reobserve({
|
|
3703
|
-
fetchPolicy: "network-only",
|
|
3704
|
-
nextFetchPolicy: _this.options.fetchPolicy || "cache-first",
|
|
3705
|
-
}, exports.NetworkStatus.poll).then(poll, poll);
|
|
3706
|
-
}
|
|
3707
|
-
else {
|
|
3708
|
-
poll();
|
|
3709
|
-
}
|
|
3710
|
-
}
|
|
3711
|
-
};
|
|
3712
|
-
var poll = function () {
|
|
3713
|
-
var info = _this.pollingInfo;
|
|
3714
|
-
if (info) {
|
|
3715
|
-
clearTimeout(info.timeout);
|
|
3716
|
-
info.timeout = setTimeout(maybeFetch, info.interval);
|
|
3717
|
-
}
|
|
3718
|
-
};
|
|
3719
|
-
poll();
|
|
3720
|
-
};
|
|
3721
|
-
return Reobserver;
|
|
3722
|
-
}());
|
|
3723
|
-
|
|
3724
3723
|
var warnedAboutUpdateQuery = false;
|
|
3725
3724
|
var ObservableQuery = (function (_super) {
|
|
3726
3725
|
tslib.__extends(ObservableQuery, _super);
|
|
3727
3726
|
function ObservableQuery(_a) {
|
|
3728
3727
|
var queryManager = _a.queryManager, queryInfo = _a.queryInfo, options = _a.options;
|
|
3729
3728
|
var _this = _super.call(this, function (observer) {
|
|
3730
|
-
|
|
3729
|
+
try {
|
|
3730
|
+
var subObserver = observer._subscription._observer;
|
|
3731
|
+
if (subObserver && !subObserver.error) {
|
|
3732
|
+
subObserver.error = defaultSubscriptionObserverErrorCallback;
|
|
3733
|
+
}
|
|
3734
|
+
}
|
|
3735
|
+
catch (_a) { }
|
|
3736
|
+
var first = !_this.observers.size;
|
|
3737
|
+
_this.observers.add(observer);
|
|
3738
|
+
if (_this.lastError) {
|
|
3739
|
+
observer.error && observer.error(_this.lastError);
|
|
3740
|
+
}
|
|
3741
|
+
else if (_this.lastResult) {
|
|
3742
|
+
observer.next && observer.next(_this.lastResult);
|
|
3743
|
+
}
|
|
3744
|
+
if (first) {
|
|
3745
|
+
_this.reobserve().catch(function () { });
|
|
3746
|
+
}
|
|
3747
|
+
return function () {
|
|
3748
|
+
if (_this.observers.delete(observer) && !_this.observers.size) {
|
|
3749
|
+
_this.tearDownQuery();
|
|
3750
|
+
}
|
|
3751
|
+
};
|
|
3731
3752
|
}) || this;
|
|
3732
3753
|
_this.observers = new Set();
|
|
3733
3754
|
_this.subscriptions = new Set();
|
|
@@ -3748,6 +3769,7 @@ var ObservableQuery = (function (_super) {
|
|
|
3748
3769
|
_this.queryId = queryManager.generateQueryId();
|
|
3749
3770
|
var opDef = getOperationDefinition(options.query);
|
|
3750
3771
|
_this.queryName = opDef && opDef.name && opDef.name.value;
|
|
3772
|
+
_this.initialFetchPolicy = options.fetchPolicy || "cache-first";
|
|
3751
3773
|
_this.queryManager = queryManager;
|
|
3752
3774
|
_this.queryInfo = queryInfo;
|
|
3753
3775
|
return _this;
|
|
@@ -3780,21 +3802,12 @@ var ObservableQuery = (function (_super) {
|
|
|
3780
3802
|
};
|
|
3781
3803
|
ObservableQuery.prototype.getCurrentResult = function (saveAsLastResult) {
|
|
3782
3804
|
if (saveAsLastResult === void 0) { saveAsLastResult = true; }
|
|
3783
|
-
var lastResult =
|
|
3805
|
+
var _a = this, lastResult = _a.lastResult, _b = _a.options.fetchPolicy, fetchPolicy = _b === void 0 ? "cache-first" : _b;
|
|
3784
3806
|
var networkStatus = this.queryInfo.networkStatus ||
|
|
3785
3807
|
(lastResult && lastResult.networkStatus) ||
|
|
3786
3808
|
exports.NetworkStatus.ready;
|
|
3787
3809
|
var result = tslib.__assign(tslib.__assign({}, lastResult), { loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus });
|
|
3788
|
-
if (this.
|
|
3789
|
-
return result;
|
|
3790
|
-
}
|
|
3791
|
-
var _a = this.options.fetchPolicy, fetchPolicy = _a === void 0 ? 'cache-first' : _a;
|
|
3792
|
-
if (fetchPolicy === 'no-cache' ||
|
|
3793
|
-
fetchPolicy === 'network-only') {
|
|
3794
|
-
delete result.partial;
|
|
3795
|
-
}
|
|
3796
|
-
else if (!result.data ||
|
|
3797
|
-
!this.queryManager.transform(this.options.query).hasForcedResolvers) {
|
|
3810
|
+
if (!this.queryManager.transform(this.options.query).hasForcedResolvers) {
|
|
3798
3811
|
var diff = this.queryInfo.getDiff();
|
|
3799
3812
|
result.data = (diff.complete ||
|
|
3800
3813
|
this.options.returnPartialData) ? diff.result : void 0;
|
|
@@ -3807,7 +3820,7 @@ var ObservableQuery = (function (_super) {
|
|
|
3807
3820
|
}
|
|
3808
3821
|
delete result.partial;
|
|
3809
3822
|
}
|
|
3810
|
-
else {
|
|
3823
|
+
else if (fetchPolicy !== "no-cache") {
|
|
3811
3824
|
result.partial = true;
|
|
3812
3825
|
}
|
|
3813
3826
|
if (!diff.complete &&
|
|
@@ -3846,16 +3859,17 @@ var ObservableQuery = (function (_super) {
|
|
|
3846
3859
|
pollInterval: 0,
|
|
3847
3860
|
};
|
|
3848
3861
|
var fetchPolicy = this.options.fetchPolicy;
|
|
3849
|
-
if (fetchPolicy
|
|
3850
|
-
fetchPolicy
|
|
3862
|
+
if (fetchPolicy === 'no-cache') {
|
|
3863
|
+
reobserveOptions.fetchPolicy = 'no-cache';
|
|
3864
|
+
}
|
|
3865
|
+
else if (fetchPolicy !== 'cache-and-network') {
|
|
3851
3866
|
reobserveOptions.fetchPolicy = 'network-only';
|
|
3852
|
-
reobserveOptions.nextFetchPolicy = fetchPolicy || "cache-first";
|
|
3853
3867
|
}
|
|
3854
3868
|
if (variables && !equality.equal(this.options.variables, variables)) {
|
|
3855
3869
|
reobserveOptions.variables = this.options.variables = tslib.__assign(tslib.__assign({}, this.options.variables), variables);
|
|
3856
3870
|
}
|
|
3857
3871
|
this.queryInfo.resetLastWrite();
|
|
3858
|
-
return this.
|
|
3872
|
+
return this.reobserve(reobserveOptions, exports.NetworkStatus.refetch);
|
|
3859
3873
|
};
|
|
3860
3874
|
ObservableQuery.prototype.fetchMore = function (fetchMoreOptions) {
|
|
3861
3875
|
var _this = this;
|
|
@@ -3941,18 +3955,10 @@ var ObservableQuery = (function (_super) {
|
|
|
3941
3955
|
if (!this.observers.size) {
|
|
3942
3956
|
return Promise.resolve();
|
|
3943
3957
|
}
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
fetchPolicy: fetchPolicy,
|
|
3958
|
+
return this.reobserve({
|
|
3959
|
+
fetchPolicy: this.initialFetchPolicy,
|
|
3947
3960
|
variables: variables,
|
|
3948
|
-
};
|
|
3949
|
-
if (fetchPolicy !== 'cache-first' &&
|
|
3950
|
-
fetchPolicy !== 'no-cache' &&
|
|
3951
|
-
fetchPolicy !== 'network-only') {
|
|
3952
|
-
reobserveOptions.fetchPolicy = 'cache-and-network';
|
|
3953
|
-
reobserveOptions.nextFetchPolicy = fetchPolicy;
|
|
3954
|
-
}
|
|
3955
|
-
return this.reobserve(reobserveOptions, exports.NetworkStatus.setVariables);
|
|
3961
|
+
}, exports.NetworkStatus.setVariables);
|
|
3956
3962
|
};
|
|
3957
3963
|
ObservableQuery.prototype.updateQuery = function (mapFn) {
|
|
3958
3964
|
var _a;
|
|
@@ -3977,12 +3983,57 @@ var ObservableQuery = (function (_super) {
|
|
|
3977
3983
|
}
|
|
3978
3984
|
};
|
|
3979
3985
|
ObservableQuery.prototype.startPolling = function (pollInterval) {
|
|
3980
|
-
this.
|
|
3986
|
+
this.options.pollInterval = pollInterval;
|
|
3987
|
+
this.updatePolling();
|
|
3981
3988
|
};
|
|
3982
3989
|
ObservableQuery.prototype.stopPolling = function () {
|
|
3983
|
-
|
|
3984
|
-
|
|
3990
|
+
this.options.pollInterval = 0;
|
|
3991
|
+
this.updatePolling();
|
|
3992
|
+
};
|
|
3993
|
+
ObservableQuery.prototype.fetch = function (options, newNetworkStatus) {
|
|
3994
|
+
this.queryManager.setObservableQuery(this);
|
|
3995
|
+
return this.queryManager.fetchQueryObservable(this.queryId, options, newNetworkStatus);
|
|
3996
|
+
};
|
|
3997
|
+
ObservableQuery.prototype.updatePolling = function () {
|
|
3998
|
+
var _this = this;
|
|
3999
|
+
if (this.queryManager.ssrMode) {
|
|
4000
|
+
return;
|
|
3985
4001
|
}
|
|
4002
|
+
var _a = this, pollingInfo = _a.pollingInfo, pollInterval = _a.options.pollInterval;
|
|
4003
|
+
if (!pollInterval) {
|
|
4004
|
+
if (pollingInfo) {
|
|
4005
|
+
clearTimeout(pollingInfo.timeout);
|
|
4006
|
+
delete this.pollingInfo;
|
|
4007
|
+
}
|
|
4008
|
+
return;
|
|
4009
|
+
}
|
|
4010
|
+
if (pollingInfo &&
|
|
4011
|
+
pollingInfo.interval === pollInterval) {
|
|
4012
|
+
return;
|
|
4013
|
+
}
|
|
4014
|
+
__DEV__ ? tsInvariant.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : tsInvariant.invariant(pollInterval, 13);
|
|
4015
|
+
var info = pollingInfo || (this.pollingInfo = {});
|
|
4016
|
+
info.interval = pollInterval;
|
|
4017
|
+
var maybeFetch = function () {
|
|
4018
|
+
if (_this.pollingInfo) {
|
|
4019
|
+
if (!isNetworkRequestInFlight(_this.queryInfo.networkStatus)) {
|
|
4020
|
+
_this.reobserve({
|
|
4021
|
+
fetchPolicy: "network-only",
|
|
4022
|
+
}, exports.NetworkStatus.poll).then(poll, poll);
|
|
4023
|
+
}
|
|
4024
|
+
else {
|
|
4025
|
+
poll();
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
};
|
|
4029
|
+
var poll = function () {
|
|
4030
|
+
var info = _this.pollingInfo;
|
|
4031
|
+
if (info) {
|
|
4032
|
+
clearTimeout(info.timeout);
|
|
4033
|
+
info.timeout = setTimeout(maybeFetch, info.interval);
|
|
4034
|
+
}
|
|
4035
|
+
};
|
|
4036
|
+
poll();
|
|
3986
4037
|
};
|
|
3987
4038
|
ObservableQuery.prototype.updateLastResult = function (newResult) {
|
|
3988
4039
|
var previousResult = this.lastResult;
|
|
@@ -3995,50 +4046,36 @@ var ObservableQuery = (function (_super) {
|
|
|
3995
4046
|
}
|
|
3996
4047
|
return previousResult;
|
|
3997
4048
|
};
|
|
3998
|
-
ObservableQuery.prototype.
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4049
|
+
ObservableQuery.prototype.reobserve = function (newOptions, newNetworkStatus) {
|
|
4050
|
+
this.isTornDown = false;
|
|
4051
|
+
var useDisposableConcast = newNetworkStatus === exports.NetworkStatus.refetch ||
|
|
4052
|
+
newNetworkStatus === exports.NetworkStatus.fetchMore ||
|
|
4053
|
+
newNetworkStatus === exports.NetworkStatus.poll;
|
|
4054
|
+
var oldVariables = this.options.variables;
|
|
4055
|
+
var options = useDisposableConcast
|
|
4056
|
+
? compact(this.options, newOptions)
|
|
4057
|
+
: Object.assign(this.options, compact(newOptions));
|
|
4058
|
+
if (!useDisposableConcast) {
|
|
4059
|
+
this.updatePolling();
|
|
4060
|
+
if (newOptions &&
|
|
4061
|
+
newOptions.variables &&
|
|
4062
|
+
!newOptions.fetchPolicy &&
|
|
4063
|
+
!equality.equal(newOptions.variables, oldVariables)) {
|
|
4064
|
+
options.fetchPolicy = this.initialFetchPolicy;
|
|
4065
|
+
if (newNetworkStatus === void 0) {
|
|
4066
|
+
newNetworkStatus = exports.NetworkStatus.setVariables;
|
|
4067
|
+
}
|
|
4007
4068
|
}
|
|
4008
4069
|
}
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
observer.error && observer.error(this.lastError);
|
|
4014
|
-
}
|
|
4015
|
-
else if (this.lastResult) {
|
|
4016
|
-
observer.next && observer.next(this.lastResult);
|
|
4017
|
-
}
|
|
4018
|
-
if (first) {
|
|
4019
|
-
this.reobserve().catch(function () { });
|
|
4020
|
-
}
|
|
4021
|
-
return function () {
|
|
4022
|
-
if (_this.observers.delete(observer) && !_this.observers.size) {
|
|
4023
|
-
_this.tearDownQuery();
|
|
4070
|
+
var concast = this.fetch(options, newNetworkStatus);
|
|
4071
|
+
if (!useDisposableConcast) {
|
|
4072
|
+
if (this.concast) {
|
|
4073
|
+
this.concast.removeObserver(this.observer, true);
|
|
4024
4074
|
}
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
return
|
|
4029
|
-
};
|
|
4030
|
-
ObservableQuery.prototype.newReobserver = function (shareOptions) {
|
|
4031
|
-
var _this = this;
|
|
4032
|
-
var _a = this, queryManager = _a.queryManager, queryId = _a.queryId;
|
|
4033
|
-
queryManager.setObservableQuery(this);
|
|
4034
|
-
return new Reobserver(this.observer, shareOptions ? this.options : tslib.__assign({}, this.options), function (currentOptions, newNetworkStatus) {
|
|
4035
|
-
queryManager.setObservableQuery(_this);
|
|
4036
|
-
return queryManager.fetchQueryObservable(queryId, currentOptions, newNetworkStatus);
|
|
4037
|
-
}, !queryManager.ssrMode && (function () { return !isNetworkRequestInFlight(_this.queryInfo.networkStatus); }));
|
|
4038
|
-
};
|
|
4039
|
-
ObservableQuery.prototype.reobserve = function (newOptions, newNetworkStatus) {
|
|
4040
|
-
this.isTornDown = false;
|
|
4041
|
-
return this.getReobserver().reobserve(newOptions, newNetworkStatus);
|
|
4075
|
+
this.concast = concast;
|
|
4076
|
+
}
|
|
4077
|
+
concast.addObserver(this.observer);
|
|
4078
|
+
return concast.promise;
|
|
4042
4079
|
};
|
|
4043
4080
|
ObservableQuery.prototype.observe = function () {
|
|
4044
4081
|
this.observer.next(this.getCurrentResult(false));
|
|
@@ -4049,10 +4086,11 @@ var ObservableQuery = (function (_super) {
|
|
|
4049
4086
|
ObservableQuery.prototype.tearDownQuery = function () {
|
|
4050
4087
|
if (this.isTornDown)
|
|
4051
4088
|
return;
|
|
4052
|
-
if (this.
|
|
4053
|
-
this.
|
|
4054
|
-
delete this.
|
|
4089
|
+
if (this.concast) {
|
|
4090
|
+
this.concast.removeObserver(this.observer);
|
|
4091
|
+
delete this.concast;
|
|
4055
4092
|
}
|
|
4093
|
+
this.stopPolling();
|
|
4056
4094
|
this.subscriptions.forEach(function (sub) { return sub.unsubscribe(); });
|
|
4057
4095
|
this.subscriptions.clear();
|
|
4058
4096
|
this.queryManager.stopQuery(this.queryId);
|
|
@@ -4068,7 +4106,6 @@ function defaultSubscriptionObserverErrorCallback(error) {
|
|
|
4068
4106
|
function applyNextFetchPolicy(options) {
|
|
4069
4107
|
var _a = options.fetchPolicy, fetchPolicy = _a === void 0 ? "cache-first" : _a, nextFetchPolicy = options.nextFetchPolicy;
|
|
4070
4108
|
if (nextFetchPolicy) {
|
|
4071
|
-
options.nextFetchPolicy = void 0;
|
|
4072
4109
|
options.fetchPolicy = typeof nextFetchPolicy === "function"
|
|
4073
4110
|
? nextFetchPolicy.call(options, fetchPolicy)
|
|
4074
4111
|
: nextFetchPolicy;
|
|
@@ -4138,8 +4175,7 @@ var LocalState = (function () {
|
|
|
4138
4175
|
};
|
|
4139
4176
|
LocalState.prototype.prepareContext = function (context) {
|
|
4140
4177
|
var cache = this.cache;
|
|
4141
|
-
return tslib.__assign(tslib.__assign({}, context), { cache: cache,
|
|
4142
|
-
getCacheKey: function (obj) {
|
|
4178
|
+
return tslib.__assign(tslib.__assign({}, context), { cache: cache, getCacheKey: function (obj) {
|
|
4143
4179
|
return cache.identify(obj);
|
|
4144
4180
|
} });
|
|
4145
4181
|
};
|
|
@@ -4203,8 +4239,7 @@ var LocalState = (function () {
|
|
|
4203
4239
|
_a = this, cache = _a.cache, client = _a.client;
|
|
4204
4240
|
execContext = {
|
|
4205
4241
|
fragmentMap: fragmentMap,
|
|
4206
|
-
context: tslib.__assign(tslib.__assign({}, context), { cache: cache,
|
|
4207
|
-
client: client }),
|
|
4242
|
+
context: tslib.__assign(tslib.__assign({}, context), { cache: cache, client: client }),
|
|
4208
4243
|
variables: variables,
|
|
4209
4244
|
fragmentMatcher: fragmentMatcher,
|
|
4210
4245
|
defaultOperationType: defaultOperationType,
|
|
@@ -4424,12 +4459,13 @@ var QueryInfo = (function () {
|
|
|
4424
4459
|
};
|
|
4425
4460
|
QueryInfo.prototype.getDiffOptions = function (variables) {
|
|
4426
4461
|
if (variables === void 0) { variables = this.variables; }
|
|
4462
|
+
var oq = this.observableQuery;
|
|
4427
4463
|
return {
|
|
4428
4464
|
query: this.document,
|
|
4429
4465
|
variables: variables,
|
|
4430
4466
|
returnPartialData: true,
|
|
4431
4467
|
optimistic: true,
|
|
4432
|
-
canonizeResults:
|
|
4468
|
+
canonizeResults: !oq || oq.options.canonizeResults !== false,
|
|
4433
4469
|
};
|
|
4434
4470
|
};
|
|
4435
4471
|
QueryInfo.prototype.setDiff = function (diff) {
|
|
@@ -4516,10 +4552,6 @@ var QueryInfo = (function () {
|
|
|
4516
4552
|
this.cancel = this.cache.watch(this.lastWatch = watchOptions);
|
|
4517
4553
|
}
|
|
4518
4554
|
};
|
|
4519
|
-
QueryInfo.prototype.canonize = function () {
|
|
4520
|
-
var oq = this.observableQuery;
|
|
4521
|
-
return !oq || oq.options.canonizeResults !== false;
|
|
4522
|
-
};
|
|
4523
4555
|
QueryInfo.prototype.resetLastWrite = function () {
|
|
4524
4556
|
this.lastWrite = void 0;
|
|
4525
4557
|
};
|
|
@@ -4537,7 +4569,7 @@ var QueryInfo = (function () {
|
|
|
4537
4569
|
if (options.fetchPolicy === 'no-cache') {
|
|
4538
4570
|
this.updateLastDiff({ result: result.data, complete: true }, this.getDiffOptions(options.variables));
|
|
4539
4571
|
}
|
|
4540
|
-
else if (
|
|
4572
|
+
else if (cacheWriteBehavior !== 0) {
|
|
4541
4573
|
if (shouldWriteResult(result, options.errorPolicy)) {
|
|
4542
4574
|
this.cache.performTransaction(function (cache) {
|
|
4543
4575
|
if (_this.shouldWrite(result, options.variables)) {
|
|
@@ -4633,7 +4665,7 @@ var QueryManager = (function () {
|
|
|
4633
4665
|
this.queries.forEach(function (_info, queryId) {
|
|
4634
4666
|
_this.stopQueryNoBroadcast(queryId);
|
|
4635
4667
|
});
|
|
4636
|
-
this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('QueryManager stopped while query was in flight') : new tsInvariant.InvariantError(
|
|
4668
|
+
this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('QueryManager stopped while query was in flight') : new tsInvariant.InvariantError(14));
|
|
4637
4669
|
};
|
|
4638
4670
|
QueryManager.prototype.cancelPendingFetches = function (error) {
|
|
4639
4671
|
this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
|
|
@@ -4646,8 +4678,8 @@ var QueryManager = (function () {
|
|
|
4646
4678
|
return tslib.__generator(this, function (_e) {
|
|
4647
4679
|
switch (_e.label) {
|
|
4648
4680
|
case 0:
|
|
4649
|
-
__DEV__ ? tsInvariant.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : tsInvariant.invariant(mutation,
|
|
4650
|
-
__DEV__ ? tsInvariant.invariant(!fetchPolicy || fetchPolicy === 'no-cache', "Mutations only support a 'no-cache' fetchPolicy. If you don't want to disable the cache, remove your fetchPolicy setting to proceed with the default mutation behavior.") : tsInvariant.invariant(!fetchPolicy || fetchPolicy === 'no-cache',
|
|
4681
|
+
__DEV__ ? tsInvariant.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : tsInvariant.invariant(mutation, 15);
|
|
4682
|
+
__DEV__ ? tsInvariant.invariant(!fetchPolicy || fetchPolicy === 'no-cache', "Mutations only support a 'no-cache' fetchPolicy. If you don't want to disable the cache, remove your fetchPolicy setting to proceed with the default mutation behavior.") : tsInvariant.invariant(!fetchPolicy || fetchPolicy === 'no-cache', 16);
|
|
4651
4683
|
mutationId = this.generateMutationId();
|
|
4652
4684
|
mutation = this.transform(mutation).document;
|
|
4653
4685
|
variables = this.getVariables(mutation, variables);
|
|
@@ -4932,10 +4964,10 @@ var QueryManager = (function () {
|
|
|
4932
4964
|
var _this = this;
|
|
4933
4965
|
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
4934
4966
|
__DEV__ ? tsInvariant.invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
|
|
4935
|
-
'in the query option.') : tsInvariant.invariant(options.query,
|
|
4936
|
-
__DEV__ ? tsInvariant.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : tsInvariant.invariant(options.query.kind === 'Document',
|
|
4937
|
-
__DEV__ ? tsInvariant.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : tsInvariant.invariant(!options.returnPartialData,
|
|
4938
|
-
__DEV__ ? tsInvariant.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : tsInvariant.invariant(!options.pollInterval,
|
|
4967
|
+
'in the query option.') : tsInvariant.invariant(options.query, 17);
|
|
4968
|
+
__DEV__ ? tsInvariant.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : tsInvariant.invariant(options.query.kind === 'Document', 18);
|
|
4969
|
+
__DEV__ ? tsInvariant.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : tsInvariant.invariant(!options.returnPartialData, 19);
|
|
4970
|
+
__DEV__ ? tsInvariant.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : tsInvariant.invariant(!options.pollInterval, 20);
|
|
4939
4971
|
return this.fetchQuery(queryId, options).finally(function () { return _this.stopQuery(queryId); });
|
|
4940
4972
|
};
|
|
4941
4973
|
QueryManager.prototype.generateQueryId = function () {
|
|
@@ -4957,7 +4989,7 @@ var QueryManager = (function () {
|
|
|
4957
4989
|
queryInfo.stop();
|
|
4958
4990
|
};
|
|
4959
4991
|
QueryManager.prototype.clearStore = function () {
|
|
4960
|
-
this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('Store reset while query was in flight (not completed in link chain)') : new tsInvariant.InvariantError(
|
|
4992
|
+
this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('Store reset while query was in flight (not completed in link chain)') : new tsInvariant.InvariantError(21));
|
|
4961
4993
|
this.queries.forEach(function (queryInfo) {
|
|
4962
4994
|
if (queryInfo.observableQuery) {
|
|
4963
4995
|
queryInfo.networkStatus = exports.NetworkStatus.loading;
|
|
@@ -4985,9 +5017,12 @@ var QueryManager = (function () {
|
|
|
4985
5017
|
var legacyQueryOptions = new Set();
|
|
4986
5018
|
if (Array.isArray(include)) {
|
|
4987
5019
|
include.forEach(function (desc) {
|
|
4988
|
-
if (typeof desc === "string"
|
|
5020
|
+
if (typeof desc === "string") {
|
|
4989
5021
|
queryNamesAndDocs.set(desc, false);
|
|
4990
5022
|
}
|
|
5023
|
+
else if (isDocumentNode(desc)) {
|
|
5024
|
+
queryNamesAndDocs.set(_this.transform(desc).document, false);
|
|
5025
|
+
}
|
|
4991
5026
|
else if (isNonNullObject(desc) && desc.query) {
|
|
4992
5027
|
legacyQueryOptions.add(desc);
|
|
4993
5028
|
}
|
|
@@ -5324,7 +5359,7 @@ var QueryManager = (function () {
|
|
|
5324
5359
|
isNonEmptyArray(diff.missing) &&
|
|
5325
5360
|
!equality.equal(data, {}) &&
|
|
5326
5361
|
!returnPartialData) {
|
|
5327
|
-
__DEV__ && tsInvariant.invariant.
|
|
5362
|
+
__DEV__ && tsInvariant.invariant.debug("Missing cache result fields: " + diff.missing.map(function (m) { return m.path.join('.'); }).join(', '), diff.missing);
|
|
5328
5363
|
}
|
|
5329
5364
|
var fromData = function (data) { return zenObservableTs.Observable.of(tslib.__assign({ data: data, loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus }, (diff.complete ? null : { partial: true }))); };
|
|
5330
5365
|
if (data && _this.transform(query).hasForcedResolvers) {
|
|
@@ -5621,6 +5656,9 @@ var ApolloClient = (function () {
|
|
|
5621
5656
|
var result = Promise.all(results);
|
|
5622
5657
|
result.queries = queries;
|
|
5623
5658
|
result.results = results;
|
|
5659
|
+
result.catch(function (error) {
|
|
5660
|
+
__DEV__ && tsInvariant.invariant.debug("In client.refetchQueries, Promise.all promise rejected with error " + error);
|
|
5661
|
+
});
|
|
5624
5662
|
return result;
|
|
5625
5663
|
};
|
|
5626
5664
|
ApolloClient.prototype.getObservableQueries = function (include) {
|
|
@@ -5651,7 +5689,7 @@ var ApolloClient = (function () {
|
|
|
5651
5689
|
return ApolloClient;
|
|
5652
5690
|
}());
|
|
5653
5691
|
|
|
5654
|
-
tsInvariant.setVerbosity("log");
|
|
5692
|
+
tsInvariant.setVerbosity(DEV ? "log" : "silent");
|
|
5655
5693
|
|
|
5656
5694
|
exports.setLogVerbosity = tsInvariant.setVerbosity;
|
|
5657
5695
|
exports.Observable = zenObservableTs.Observable;
|
|
@@ -5668,7 +5706,6 @@ exports.HttpLink = HttpLink;
|
|
|
5668
5706
|
exports.InMemoryCache = InMemoryCache;
|
|
5669
5707
|
exports.MissingFieldError = MissingFieldError;
|
|
5670
5708
|
exports.ObservableQuery = ObservableQuery;
|
|
5671
|
-
exports.__DEV__ = __DEV__$1;
|
|
5672
5709
|
exports.applyNextFetchPolicy = applyNextFetchPolicy;
|
|
5673
5710
|
exports.checkFetcher = checkFetcher;
|
|
5674
5711
|
exports.concat = concat;
|