@apollo/client 3.8.0-alpha.11 → 3.8.0-alpha.13
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 +594 -397
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +2 -1
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +30 -19
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.d.ts +2 -0
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +60 -48
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +175 -82
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +175 -82
- package/core/equalByQuery.d.ts +4 -0
- package/core/equalByQuery.d.ts.map +1 -0
- package/{react/hooks/compareResults.js → core/equalByQuery.js} +14 -10
- package/core/equalByQuery.js.map +1 -0
- package/core/index.d.ts +1 -1
- package/core/index.d.ts.map +1 -1
- package/core/index.js +1 -1
- package/core/index.js.map +1 -1
- package/errors/errors.cjs +17 -17
- package/errors/errors.cjs.map +1 -1
- package/errors/errors.cjs.native.js +17 -17
- package/errors/index.d.ts +24 -8
- package/errors/index.d.ts.map +1 -1
- package/errors/index.js +17 -19
- package/errors/index.js.map +1 -1
- package/invariantErrorCodes.js +29 -34
- package/link/batch-http/batch-http.cjs +23 -2
- package/link/batch-http/batch-http.cjs.map +1 -1
- package/link/batch-http/batch-http.cjs.native.js +23 -2
- package/link/batch-http/batchHttpLink.d.ts.map +1 -1
- package/link/batch-http/batchHttpLink.js +7 -2
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/core/types.d.ts +4 -0
- package/link/core/types.d.ts.map +1 -1
- package/link/core/types.js.map +1 -1
- package/link/http/createHttpLink.d.ts.map +1 -1
- package/link/http/createHttpLink.js +21 -20
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/http.cjs +59 -30
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +59 -30
- package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +34 -14
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
- package/link/http/selectHttpOptionsAndBody.js +2 -1
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/persisted-queries/index.d.ts.map +1 -1
- package/link/persisted-queries/index.js +12 -13
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs +12 -13
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +12 -13
- package/link/subscriptions/index.d.ts.map +1 -1
- package/link/subscriptions/index.js +10 -5
- package/link/subscriptions/index.js.map +1 -1
- package/link/subscriptions/subscriptions.cjs +9 -4
- package/link/subscriptions/subscriptions.cjs.map +1 -1
- package/link/subscriptions/subscriptions.cjs.native.js +9 -4
- package/link/utils/filterOperationVariables.d.ts +5 -0
- package/link/utils/filterOperationVariables.d.ts.map +1 -0
- package/link/utils/filterOperationVariables.js +18 -0
- package/link/utils/filterOperationVariables.js.map +1 -0
- package/link/utils/index.d.ts +1 -0
- package/link/utils/index.d.ts.map +1 -1
- package/link/utils/index.js +1 -0
- package/link/utils/index.js.map +1 -1
- package/link/utils/throwServerError.d.ts +1 -1
- package/link/utils/throwServerError.d.ts.map +1 -1
- package/link/utils/throwServerError.js.map +1 -1
- package/link/utils/utils.cjs +18 -0
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +18 -0
- package/package.json +24 -23
- package/react/cache/QuerySubscription.d.ts +11 -4
- package/react/cache/QuerySubscription.d.ts.map +1 -1
- package/react/cache/QuerySubscription.js +53 -35
- package/react/cache/QuerySubscription.js.map +1 -1
- package/react/cache/SuspenseCache.d.ts +3 -2
- package/react/cache/SuspenseCache.d.ts.map +1 -1
- package/react/cache/SuspenseCache.js +6 -7
- package/react/cache/SuspenseCache.js.map +1 -1
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/context.cjs +2 -2
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +2 -2
- package/react/hoc/hoc-utils.js +1 -1
- package/react/hoc/hoc.cjs +2 -2
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +2 -2
- package/react/hoc/withApollo.js +1 -1
- package/react/hooks/hooks.cjs +118 -146
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +118 -146
- package/react/hooks/internal/__use.d.ts +3 -1
- package/react/hooks/internal/__use.d.ts.map +1 -1
- package/react/hooks/internal/__use.js +16 -12
- package/react/hooks/internal/__use.js.map +1 -1
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useFragment.d.ts +2 -1
- package/react/hooks/useFragment.d.ts.map +1 -1
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts.map +1 -1
- package/react/hooks/useLazyQuery.js +13 -22
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useQuery.d.ts +3 -3
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +26 -25
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts.map +1 -1
- package/react/hooks/useSubscription.js +25 -13
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseCache.js +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +15 -3
- package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
- package/react/hooks/useSuspenseQuery.js +39 -53
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/index.d.ts +1 -1
- package/react/index.d.ts.map +1 -1
- package/react/index.js +1 -1
- package/react/index.js.map +1 -1
- package/react/parser/index.js +5 -5
- package/react/parser/parser.cjs +5 -5
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +5 -5
- package/react/react.cjs +58 -54
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +58 -54
- package/react/types/types.d.ts +2 -3
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +1 -1
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +1 -1
- package/testing/core/mocking/mockLink.js +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
- package/testing/react/MockedProvider.d.ts +1 -1
- package/testing/react/MockedProvider.d.ts.map +1 -1
- package/testing/react/MockedProvider.js +7 -6
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +8 -124
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +8 -124
- package/utilities/common/incrementalResult.d.ts +2 -1
- package/utilities/common/incrementalResult.d.ts.map +1 -1
- package/utilities/common/incrementalResult.js +4 -0
- package/utilities/common/incrementalResult.js.map +1 -1
- package/utilities/common/mergeOptions.d.ts +1 -1
- package/utilities/common/mergeOptions.d.ts.map +1 -1
- package/utilities/common/mergeOptions.js.map +1 -1
- package/utilities/common/objects.d.ts +1 -0
- package/utilities/common/objects.d.ts.map +1 -1
- package/utilities/common/objects.js +6 -0
- package/utilities/common/objects.js.map +1 -1
- package/utilities/common/omitDeep.d.ts +3 -0
- package/utilities/common/omitDeep.d.ts.map +1 -0
- package/utilities/common/omitDeep.js +42 -0
- package/utilities/common/omitDeep.js.map +1 -0
- package/utilities/common/stripTypename.d.ts +2 -0
- package/utilities/common/stripTypename.d.ts.map +1 -0
- package/utilities/common/stripTypename.js +5 -0
- package/utilities/common/stripTypename.js.map +1 -0
- package/utilities/graphql/directives.js +4 -4
- package/utilities/graphql/fragments.js +3 -3
- package/utilities/graphql/getFromAST.js +8 -8
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/graphql/storeUtils.js +2 -1
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.d.ts.map +1 -1
- package/utilities/graphql/transform.js +26 -16
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +5 -0
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +3 -0
- package/utilities/index.js.map +1 -1
- package/utilities/promises/decoration.d.ts +2 -0
- package/utilities/promises/decoration.d.ts.map +1 -1
- package/utilities/promises/decoration.js +12 -0
- package/utilities/promises/decoration.js.map +1 -1
- package/utilities/types/DeepOmit.d.ts +10 -0
- package/utilities/types/DeepOmit.d.ts.map +1 -0
- package/utilities/types/DeepOmit.js +2 -0
- package/utilities/types/DeepOmit.js.map +1 -0
- package/utilities/types/DeepPartial.d.ts +12 -0
- package/utilities/types/DeepPartial.d.ts.map +1 -0
- package/utilities/types/DeepPartial.js +2 -0
- package/utilities/types/DeepPartial.js.map +1 -0
- package/utilities/types/Primitive.d.ts +2 -0
- package/utilities/types/Primitive.d.ts.map +1 -0
- package/utilities/types/Primitive.js +2 -0
- package/utilities/types/Primitive.js.map +1 -0
- package/utilities/utilities.cjs +141 -31
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +141 -31
- package/version.js +1 -1
- package/react/hooks/compareResults.d.ts +0 -3
- package/react/hooks/compareResults.d.ts.map +0 -1
- package/react/hooks/compareResults.js.map +0 -1
package/apollo-client.cjs
CHANGED
|
@@ -6,7 +6,7 @@ var tslib = require('tslib');
|
|
|
6
6
|
var tsInvariant = require('ts-invariant');
|
|
7
7
|
var process$1 = require('ts-invariant/process');
|
|
8
8
|
var graphql = require('graphql');
|
|
9
|
-
var
|
|
9
|
+
var equal = require('@wry/equality');
|
|
10
10
|
var zenObservableTs = require('zen-observable-ts');
|
|
11
11
|
require('symbol-observable');
|
|
12
12
|
var optimism = require('optimism');
|
|
@@ -15,6 +15,8 @@ var trie = require('@wry/trie');
|
|
|
15
15
|
var graphqlTag = require('graphql-tag');
|
|
16
16
|
var React = require('react');
|
|
17
17
|
|
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
19
|
+
|
|
18
20
|
function _interopNamespace(e) {
|
|
19
21
|
if (e && e.__esModule) return e;
|
|
20
22
|
var n = Object.create(null);
|
|
@@ -27,7 +29,9 @@ function _interopNamespace(e) {
|
|
|
27
29
|
return Object.freeze(n);
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
30
33
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
34
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
31
35
|
|
|
32
36
|
function maybe(thunk) {
|
|
33
37
|
try {
|
|
@@ -63,7 +67,7 @@ function shouldInclude(_a, variables) {
|
|
|
63
67
|
var evaledValue = false;
|
|
64
68
|
if (ifArgument.value.kind === 'Variable') {
|
|
65
69
|
evaledValue = variables && variables[ifArgument.value.name.value];
|
|
66
|
-
__DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @".concat(directive.name.value, " directive.")) : tsInvariant.invariant(evaledValue !== void 0,
|
|
70
|
+
__DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @".concat(directive.name.value, " directive.")) : tsInvariant.invariant(evaledValue !== void 0, 41);
|
|
67
71
|
}
|
|
68
72
|
else {
|
|
69
73
|
evaledValue = ifArgument.value.value;
|
|
@@ -71,7 +75,6 @@ function shouldInclude(_a, variables) {
|
|
|
71
75
|
return directive.name.value === 'skip' ? !evaledValue : evaledValue;
|
|
72
76
|
});
|
|
73
77
|
}
|
|
74
|
-
var hasAnyDirectives = function (names, root) { return hasDirectives(names, root, false); };
|
|
75
78
|
function hasDirectives(names, root, all) {
|
|
76
79
|
var nameSet = new Set(names);
|
|
77
80
|
var uniqueCount = nameSet.size;
|
|
@@ -100,13 +103,13 @@ function getInclusionDirectives(directives) {
|
|
|
100
103
|
return;
|
|
101
104
|
var directiveArguments = directive.arguments;
|
|
102
105
|
var directiveName = directive.name.value;
|
|
103
|
-
__DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @".concat(directiveName, " directive.")) : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1,
|
|
106
|
+
__DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @".concat(directiveName, " directive.")) : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, 42);
|
|
104
107
|
var ifArgument = directiveArguments[0];
|
|
105
|
-
__DEV__ ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @".concat(directiveName, " directive.")) : tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if',
|
|
108
|
+
__DEV__ ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @".concat(directiveName, " directive.")) : tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', 43);
|
|
106
109
|
var ifValue = ifArgument.value;
|
|
107
110
|
__DEV__ ? tsInvariant.invariant(ifValue &&
|
|
108
111
|
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @".concat(directiveName, " directive must be a variable or a boolean value.")) : tsInvariant.invariant(ifValue &&
|
|
109
|
-
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'),
|
|
112
|
+
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 44);
|
|
110
113
|
result.push({ directive: directive, ifArgument: ifArgument });
|
|
111
114
|
});
|
|
112
115
|
}
|
|
@@ -119,14 +122,14 @@ function getFragmentQueryDocument(document, fragmentName) {
|
|
|
119
122
|
document.definitions.forEach(function (definition) {
|
|
120
123
|
if (definition.kind === 'OperationDefinition') {
|
|
121
124
|
throw __DEV__ ? new tsInvariant.InvariantError("Found a ".concat(definition.operation, " operation").concat(definition.name ? " named '".concat(definition.name.value, "'") : '', ". ") +
|
|
122
|
-
'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new tsInvariant.InvariantError(
|
|
125
|
+
'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new tsInvariant.InvariantError(45);
|
|
123
126
|
}
|
|
124
127
|
if (definition.kind === 'FragmentDefinition') {
|
|
125
128
|
fragments.push(definition);
|
|
126
129
|
}
|
|
127
130
|
});
|
|
128
131
|
if (typeof actualFragmentName === 'undefined') {
|
|
129
|
-
__DEV__ ? tsInvariant.invariant(fragments.length === 1, "Found ".concat(fragments.length, " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.")) : tsInvariant.invariant(fragments.length === 1,
|
|
132
|
+
__DEV__ ? tsInvariant.invariant(fragments.length === 1, "Found ".concat(fragments.length, " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.")) : tsInvariant.invariant(fragments.length === 1, 46);
|
|
130
133
|
actualFragmentName = fragments[0].name.value;
|
|
131
134
|
}
|
|
132
135
|
var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
|
|
@@ -167,7 +170,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
167
170
|
return fragmentMap(fragmentName);
|
|
168
171
|
}
|
|
169
172
|
var fragment = fragmentMap && fragmentMap[fragmentName];
|
|
170
|
-
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named ".concat(fragmentName)) : tsInvariant.invariant(fragment,
|
|
173
|
+
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named ".concat(fragmentName)) : tsInvariant.invariant(fragment, 47);
|
|
171
174
|
return fragment || null;
|
|
172
175
|
}
|
|
173
176
|
default:
|
|
@@ -178,6 +181,12 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
178
181
|
function isNonNullObject(obj) {
|
|
179
182
|
return obj !== null && typeof obj === 'object';
|
|
180
183
|
}
|
|
184
|
+
function isPlainObject(obj) {
|
|
185
|
+
return (obj !== null &&
|
|
186
|
+
typeof obj === 'object' &&
|
|
187
|
+
(Object.getPrototypeOf(obj) === Object.prototype ||
|
|
188
|
+
Object.getPrototypeOf(obj) === null));
|
|
189
|
+
}
|
|
181
190
|
|
|
182
191
|
function makeReference(id) {
|
|
183
192
|
return { __ref: String(id) };
|
|
@@ -251,7 +260,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
|
|
|
251
260
|
else {
|
|
252
261
|
throw __DEV__ ? new tsInvariant.InvariantError("The inline argument \"".concat(name.value, "\" of kind \"").concat(value.kind, "\"") +
|
|
253
262
|
'is not supported. Use variables instead of inline arguments to ' +
|
|
254
|
-
'overcome this limitation.') : new tsInvariant.InvariantError(
|
|
263
|
+
'overcome this limitation.') : new tsInvariant.InvariantError(56);
|
|
255
264
|
}
|
|
256
265
|
}
|
|
257
266
|
function storeKeyNameFromField(field, variables) {
|
|
@@ -285,6 +294,7 @@ var KNOWN_DIRECTIVES = [
|
|
|
285
294
|
'client',
|
|
286
295
|
'rest',
|
|
287
296
|
'export',
|
|
297
|
+
'nonreactive',
|
|
288
298
|
];
|
|
289
299
|
var getStoreKeyName = Object.assign(function (fieldName, args, directives) {
|
|
290
300
|
if (args &&
|
|
@@ -385,16 +395,16 @@ function isInlineFragment(selection) {
|
|
|
385
395
|
}
|
|
386
396
|
|
|
387
397
|
function checkDocument(doc) {
|
|
388
|
-
__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',
|
|
398
|
+
__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', 48);
|
|
389
399
|
var operations = doc.definitions
|
|
390
400
|
.filter(function (d) { return d.kind !== 'FragmentDefinition'; })
|
|
391
401
|
.map(function (definition) {
|
|
392
402
|
if (definition.kind !== 'OperationDefinition') {
|
|
393
|
-
throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"".concat(definition.kind, "\"")) : new tsInvariant.InvariantError(
|
|
403
|
+
throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"".concat(definition.kind, "\"")) : new tsInvariant.InvariantError(49);
|
|
394
404
|
}
|
|
395
405
|
return definition;
|
|
396
406
|
});
|
|
397
|
-
__DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains ".concat(operations.length, " operations")) : tsInvariant.invariant(operations.length <= 1,
|
|
407
|
+
__DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains ".concat(operations.length, " operations")) : tsInvariant.invariant(operations.length <= 1, 50);
|
|
398
408
|
return doc;
|
|
399
409
|
}
|
|
400
410
|
function getOperationDefinition(doc) {
|
|
@@ -417,14 +427,14 @@ function getFragmentDefinitions(doc) {
|
|
|
417
427
|
}
|
|
418
428
|
function getQueryDefinition(doc) {
|
|
419
429
|
var queryDef = getOperationDefinition(doc);
|
|
420
|
-
__DEV__ ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : tsInvariant.invariant(queryDef && queryDef.operation === 'query',
|
|
430
|
+
__DEV__ ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : tsInvariant.invariant(queryDef && queryDef.operation === 'query', 51);
|
|
421
431
|
return queryDef;
|
|
422
432
|
}
|
|
423
433
|
function getFragmentDefinition(doc) {
|
|
424
|
-
__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',
|
|
425
|
-
__DEV__ ? tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : tsInvariant.invariant(doc.definitions.length <= 1,
|
|
434
|
+
__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', 52);
|
|
435
|
+
__DEV__ ? tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : tsInvariant.invariant(doc.definitions.length <= 1, 53);
|
|
426
436
|
var fragmentDef = doc.definitions[0];
|
|
427
|
-
__DEV__ ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition',
|
|
437
|
+
__DEV__ ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 54);
|
|
428
438
|
return fragmentDef;
|
|
429
439
|
}
|
|
430
440
|
function getMainDefinition(queryDoc) {
|
|
@@ -447,7 +457,7 @@ function getMainDefinition(queryDoc) {
|
|
|
447
457
|
if (fragmentDefinition) {
|
|
448
458
|
return fragmentDefinition;
|
|
449
459
|
}
|
|
450
|
-
throw __DEV__ ? new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new tsInvariant.InvariantError(
|
|
460
|
+
throw __DEV__ ? new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new tsInvariant.InvariantError(55);
|
|
451
461
|
}
|
|
452
462
|
function getDefaultValues(definition) {
|
|
453
463
|
var defaultValues = Object.create(null);
|
|
@@ -483,19 +493,30 @@ function nullIfDocIsEmpty(doc) {
|
|
|
483
493
|
? null
|
|
484
494
|
: doc;
|
|
485
495
|
}
|
|
486
|
-
function getDirectiveMatcher(
|
|
487
|
-
var
|
|
488
|
-
var tests =
|
|
489
|
-
|
|
490
|
-
if (directive
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
496
|
+
function getDirectiveMatcher(configs) {
|
|
497
|
+
var names = new Map();
|
|
498
|
+
var tests = new Map();
|
|
499
|
+
configs.forEach(function (directive) {
|
|
500
|
+
if (directive) {
|
|
501
|
+
if (directive.name) {
|
|
502
|
+
names.set(directive.name, directive);
|
|
503
|
+
}
|
|
504
|
+
else if (directive.test) {
|
|
505
|
+
tests.set(directive.test, directive);
|
|
506
|
+
}
|
|
495
507
|
}
|
|
496
508
|
});
|
|
497
|
-
return function (directive) {
|
|
498
|
-
|
|
509
|
+
return function (directive) {
|
|
510
|
+
var config = names.get(directive.name.value);
|
|
511
|
+
if (!config && tests.size) {
|
|
512
|
+
tests.forEach(function (testConfig, test) {
|
|
513
|
+
if (test(directive)) {
|
|
514
|
+
config = testConfig;
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
return config;
|
|
519
|
+
};
|
|
499
520
|
}
|
|
500
521
|
function makeInUseGetterFunction(defaultKey) {
|
|
501
522
|
var map = new Map();
|
|
@@ -512,6 +533,7 @@ function makeInUseGetterFunction(defaultKey) {
|
|
|
512
533
|
};
|
|
513
534
|
}
|
|
514
535
|
function removeDirectivesFromDocument(directives, doc) {
|
|
536
|
+
checkDocument(doc);
|
|
515
537
|
var getInUseByOperationName = makeInUseGetterFunction("");
|
|
516
538
|
var getInUseByFragmentName = makeInUseGetterFunction("");
|
|
517
539
|
var getInUse = function (ancestors) {
|
|
@@ -535,10 +557,8 @@ function removeDirectivesFromDocument(directives, doc) {
|
|
|
535
557
|
}
|
|
536
558
|
}
|
|
537
559
|
var directiveMatcher = getDirectiveMatcher(directives);
|
|
538
|
-
var
|
|
539
|
-
|
|
540
|
-
nodeDirectives &&
|
|
541
|
-
nodeDirectives.some(directiveMatcher)); };
|
|
560
|
+
var shouldRemoveField = function (nodeDirectives) { return (isNonEmptyArray(nodeDirectives) &&
|
|
561
|
+
nodeDirectives.map(directiveMatcher).some(function (config) { return config && config.remove; })); };
|
|
542
562
|
var originalFragmentDefsByPath = new Map();
|
|
543
563
|
var firstVisitMadeChanges = false;
|
|
544
564
|
var fieldOrInlineFragmentVisitor = {
|
|
@@ -697,22 +717,6 @@ var addTypenameToDocument = Object.assign(function (doc) {
|
|
|
697
717
|
return field === TYPENAME_FIELD;
|
|
698
718
|
},
|
|
699
719
|
});
|
|
700
|
-
var connectionRemoveConfig = {
|
|
701
|
-
test: function (directive) {
|
|
702
|
-
var willRemove = directive.name.value === 'connection';
|
|
703
|
-
if (willRemove) {
|
|
704
|
-
if (!directive.arguments ||
|
|
705
|
-
!directive.arguments.some(function (arg) { return arg.name.value === 'key'; })) {
|
|
706
|
-
__DEV__ && tsInvariant.invariant.warn('Removing an @connection directive even though it does not have a key. ' +
|
|
707
|
-
'You may want to use the key parameter to specify a store key.');
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
return willRemove;
|
|
711
|
-
},
|
|
712
|
-
};
|
|
713
|
-
function removeConnectionDirectiveFromDocument(doc) {
|
|
714
|
-
return removeDirectivesFromDocument([connectionRemoveConfig], checkDocument(doc));
|
|
715
|
-
}
|
|
716
720
|
function buildQueryFromSelectionSet(document) {
|
|
717
721
|
var definition = getMainDefinition(document);
|
|
718
722
|
var definitionOperation = definition.operation;
|
|
@@ -812,6 +816,43 @@ var DeepMerger = (function () {
|
|
|
812
816
|
return DeepMerger;
|
|
813
817
|
}());
|
|
814
818
|
|
|
819
|
+
function createFulfilledPromise(value) {
|
|
820
|
+
var promise = Promise.resolve(value);
|
|
821
|
+
promise.status = 'fulfilled';
|
|
822
|
+
promise.value = value;
|
|
823
|
+
return promise;
|
|
824
|
+
}
|
|
825
|
+
function createRejectedPromise(reason) {
|
|
826
|
+
var promise = Promise.reject(reason);
|
|
827
|
+
promise.status = 'rejected';
|
|
828
|
+
promise.reason = reason;
|
|
829
|
+
return promise;
|
|
830
|
+
}
|
|
831
|
+
function isStatefulPromise(promise) {
|
|
832
|
+
return 'status' in promise;
|
|
833
|
+
}
|
|
834
|
+
function wrapPromiseWithState(promise) {
|
|
835
|
+
if (isStatefulPromise(promise)) {
|
|
836
|
+
return promise;
|
|
837
|
+
}
|
|
838
|
+
var pendingPromise = promise;
|
|
839
|
+
pendingPromise.status = 'pending';
|
|
840
|
+
pendingPromise.then(function (value) {
|
|
841
|
+
if (pendingPromise.status === 'pending') {
|
|
842
|
+
var fulfilledPromise = pendingPromise;
|
|
843
|
+
fulfilledPromise.status = 'fulfilled';
|
|
844
|
+
fulfilledPromise.value = value;
|
|
845
|
+
}
|
|
846
|
+
}, function (reason) {
|
|
847
|
+
if (pendingPromise.status === 'pending') {
|
|
848
|
+
var rejectedPromise = pendingPromise;
|
|
849
|
+
rejectedPromise.status = 'rejected';
|
|
850
|
+
rejectedPromise.reason = reason;
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
return promise;
|
|
854
|
+
}
|
|
855
|
+
|
|
815
856
|
var toString = Object.prototype.toString;
|
|
816
857
|
function cloneDeep(value) {
|
|
817
858
|
return cloneDeepHelper(value);
|
|
@@ -1094,6 +1135,9 @@ function isExecutionPatchResult(value) {
|
|
|
1094
1135
|
return (isExecutionPatchIncrementalResult(value) ||
|
|
1095
1136
|
isExecutionPatchInitialResult(value));
|
|
1096
1137
|
}
|
|
1138
|
+
function isApolloPayloadResult(value) {
|
|
1139
|
+
return isNonNullObject(value) && "payload" in value;
|
|
1140
|
+
}
|
|
1097
1141
|
function mergeIncrementalData(prevResult, result) {
|
|
1098
1142
|
var mergedData = prevResult;
|
|
1099
1143
|
var merger = new DeepMerger();
|
|
@@ -1192,6 +1236,51 @@ function isNodeReadableStream(value) {
|
|
|
1192
1236
|
return !!value.pipe;
|
|
1193
1237
|
}
|
|
1194
1238
|
|
|
1239
|
+
function omitDeep(value, key) {
|
|
1240
|
+
return __omitDeep(value, key);
|
|
1241
|
+
}
|
|
1242
|
+
function __omitDeep(value, key, known) {
|
|
1243
|
+
if (known === void 0) { known = new Map(); }
|
|
1244
|
+
if (known.has(value)) {
|
|
1245
|
+
return known.get(value);
|
|
1246
|
+
}
|
|
1247
|
+
var modified = false;
|
|
1248
|
+
if (Array.isArray(value)) {
|
|
1249
|
+
var array_1 = [];
|
|
1250
|
+
known.set(value, array_1);
|
|
1251
|
+
value.forEach(function (value, index) {
|
|
1252
|
+
var result = __omitDeep(value, key, known);
|
|
1253
|
+
modified || (modified = result !== value);
|
|
1254
|
+
array_1[index] = result;
|
|
1255
|
+
});
|
|
1256
|
+
if (modified) {
|
|
1257
|
+
return array_1;
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
else if (isPlainObject(value)) {
|
|
1261
|
+
var obj_1 = Object.create(Object.getPrototypeOf(value));
|
|
1262
|
+
known.set(value, obj_1);
|
|
1263
|
+
Object.keys(value).forEach(function (k) {
|
|
1264
|
+
if (k === key) {
|
|
1265
|
+
modified = true;
|
|
1266
|
+
}
|
|
1267
|
+
else {
|
|
1268
|
+
var result = __omitDeep(value[k], key, known);
|
|
1269
|
+
modified || (modified = result !== value[k]);
|
|
1270
|
+
obj_1[k] = result;
|
|
1271
|
+
}
|
|
1272
|
+
});
|
|
1273
|
+
if (modified) {
|
|
1274
|
+
return obj_1;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
return value;
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
function stripTypename(value) {
|
|
1281
|
+
return omitDeep(value, '__typename');
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1195
1284
|
function fromError(errorValue) {
|
|
1196
1285
|
return new zenObservableTs.Observable(function (observer) {
|
|
1197
1286
|
observer.error(errorValue);
|
|
@@ -1291,6 +1380,22 @@ function transformOperation(operation) {
|
|
|
1291
1380
|
return transformedOperation;
|
|
1292
1381
|
}
|
|
1293
1382
|
|
|
1383
|
+
function filterOperationVariables(variables, operation) {
|
|
1384
|
+
var result = tslib.__assign({}, variables);
|
|
1385
|
+
var unusedNames = new Set(Object.keys(variables));
|
|
1386
|
+
graphql.visit(operation.query, {
|
|
1387
|
+
Variable: function (node, _key, parent) {
|
|
1388
|
+
if (parent && parent.kind !== 'VariableDefinition') {
|
|
1389
|
+
unusedNames.delete(node.name.value);
|
|
1390
|
+
}
|
|
1391
|
+
},
|
|
1392
|
+
});
|
|
1393
|
+
unusedNames.forEach(function (name) {
|
|
1394
|
+
delete result[name];
|
|
1395
|
+
});
|
|
1396
|
+
return result;
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1294
1399
|
function passthrough(op, forward) {
|
|
1295
1400
|
return (forward ? forward(op) : zenObservableTs.Observable.of());
|
|
1296
1401
|
}
|
|
@@ -1396,7 +1501,7 @@ var concat = ApolloLink.concat;
|
|
|
1396
1501
|
|
|
1397
1502
|
var execute = ApolloLink.execute;
|
|
1398
1503
|
|
|
1399
|
-
var version = '3.8.0-alpha.
|
|
1504
|
+
var version = '3.8.0-alpha.13';
|
|
1400
1505
|
|
|
1401
1506
|
function asyncIterator(source) {
|
|
1402
1507
|
var _a;
|
|
@@ -1541,20 +1646,56 @@ function responseIterator(response) {
|
|
|
1541
1646
|
throw new Error("Unknown body type for responseIterator. Please pass a streamable response.");
|
|
1542
1647
|
}
|
|
1543
1648
|
|
|
1649
|
+
var PROTOCOL_ERRORS_SYMBOL = Symbol();
|
|
1650
|
+
function graphQLResultHasProtocolErrors(result) {
|
|
1651
|
+
if (result.extensions) {
|
|
1652
|
+
return Array.isArray(result.extensions[PROTOCOL_ERRORS_SYMBOL]);
|
|
1653
|
+
}
|
|
1654
|
+
return false;
|
|
1655
|
+
}
|
|
1656
|
+
function isApolloError(err) {
|
|
1657
|
+
return err.hasOwnProperty('graphQLErrors');
|
|
1658
|
+
}
|
|
1659
|
+
var generateErrorMessage = function (err) {
|
|
1660
|
+
var errors = tslib.__spreadArray(tslib.__spreadArray(tslib.__spreadArray([], err.graphQLErrors, true), err.clientErrors, true), err.protocolErrors, true);
|
|
1661
|
+
if (err.networkError)
|
|
1662
|
+
errors.push(err.networkError);
|
|
1663
|
+
return errors
|
|
1664
|
+
.map(function (err) { return isNonNullObject(err) && err.message || 'Error message not found.'; })
|
|
1665
|
+
.join('\n');
|
|
1666
|
+
};
|
|
1667
|
+
var ApolloError = (function (_super) {
|
|
1668
|
+
tslib.__extends(ApolloError, _super);
|
|
1669
|
+
function ApolloError(_a) {
|
|
1670
|
+
var graphQLErrors = _a.graphQLErrors, protocolErrors = _a.protocolErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;
|
|
1671
|
+
var _this = _super.call(this, errorMessage) || this;
|
|
1672
|
+
_this.name = 'ApolloError';
|
|
1673
|
+
_this.graphQLErrors = graphQLErrors || [];
|
|
1674
|
+
_this.protocolErrors = protocolErrors || [];
|
|
1675
|
+
_this.clientErrors = clientErrors || [];
|
|
1676
|
+
_this.networkError = networkError || null;
|
|
1677
|
+
_this.message = errorMessage || generateErrorMessage(_this);
|
|
1678
|
+
_this.extraInfo = extraInfo;
|
|
1679
|
+
_this.__proto__ = ApolloError.prototype;
|
|
1680
|
+
return _this;
|
|
1681
|
+
}
|
|
1682
|
+
return ApolloError;
|
|
1683
|
+
}(Error));
|
|
1684
|
+
|
|
1544
1685
|
var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
1545
1686
|
function readMultipartBody(response, observer) {
|
|
1546
|
-
var _a, _b, _c;
|
|
1687
|
+
var _a, _b, _c, _d, _e;
|
|
1547
1688
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1548
|
-
var decoder, contentType, delimiter, boundaryVal, boundary, buffer, iterator, running,
|
|
1549
|
-
var
|
|
1550
|
-
return tslib.__generator(this, function (
|
|
1551
|
-
switch (
|
|
1689
|
+
var decoder, contentType, delimiter, boundaryVal, boundary, buffer, iterator, running, _f, value, done, chunk, bi, message, i, headers, contentType_1, body, result, next;
|
|
1690
|
+
var _g, _h;
|
|
1691
|
+
return tslib.__generator(this, function (_j) {
|
|
1692
|
+
switch (_j.label) {
|
|
1552
1693
|
case 0:
|
|
1553
1694
|
if (TextDecoder === undefined) {
|
|
1554
1695
|
throw new Error("TextDecoder must be defined in the environment: please import a polyfill.");
|
|
1555
1696
|
}
|
|
1556
1697
|
decoder = new TextDecoder("utf-8");
|
|
1557
|
-
contentType = (_a = response.headers) === null || _a === void 0 ? void 0 : _a.get(
|
|
1698
|
+
contentType = (_a = response.headers) === null || _a === void 0 ? void 0 : _a.get("content-type");
|
|
1558
1699
|
delimiter = "boundary=";
|
|
1559
1700
|
boundaryVal = (contentType === null || contentType === void 0 ? void 0 : contentType.includes(delimiter))
|
|
1560
1701
|
? contentType === null || contentType === void 0 ? void 0 : contentType.substring((contentType === null || contentType === void 0 ? void 0 : contentType.indexOf(delimiter)) + delimiter.length).replace(/['"]/g, "").replace(/\;(.*)/gm, "").trim()
|
|
@@ -1563,22 +1704,22 @@ function readMultipartBody(response, observer) {
|
|
|
1563
1704
|
buffer = "";
|
|
1564
1705
|
iterator = responseIterator(response);
|
|
1565
1706
|
running = true;
|
|
1566
|
-
|
|
1707
|
+
_j.label = 1;
|
|
1567
1708
|
case 1:
|
|
1568
1709
|
if (!running) return [3, 3];
|
|
1569
1710
|
return [4, iterator.next()];
|
|
1570
1711
|
case 2:
|
|
1571
|
-
|
|
1712
|
+
_f = _j.sent(), value = _f.value, done = _f.done;
|
|
1572
1713
|
chunk = typeof value === "string" ? value : decoder.decode(value);
|
|
1573
1714
|
running = !done;
|
|
1574
1715
|
buffer += chunk;
|
|
1575
1716
|
bi = buffer.indexOf(boundary);
|
|
1576
1717
|
while (bi > -1) {
|
|
1577
1718
|
message = void 0;
|
|
1578
|
-
|
|
1719
|
+
_g = [
|
|
1579
1720
|
buffer.slice(0, bi),
|
|
1580
1721
|
buffer.slice(bi + boundary.length),
|
|
1581
|
-
], message =
|
|
1722
|
+
], message = _g[0], buffer = _g[1];
|
|
1582
1723
|
if (message.trim()) {
|
|
1583
1724
|
i = message.indexOf("\r\n\r\n");
|
|
1584
1725
|
headers = parseHeaders(message.slice(0, i));
|
|
@@ -1593,8 +1734,26 @@ function readMultipartBody(response, observer) {
|
|
|
1593
1734
|
if (Object.keys(result).length > 1 ||
|
|
1594
1735
|
"data" in result ||
|
|
1595
1736
|
"incremental" in result ||
|
|
1596
|
-
"errors" in result
|
|
1597
|
-
|
|
1737
|
+
"errors" in result ||
|
|
1738
|
+
"payload" in result) {
|
|
1739
|
+
if (isApolloPayloadResult(result)) {
|
|
1740
|
+
next = {};
|
|
1741
|
+
if ("payload" in result) {
|
|
1742
|
+
next = tslib.__assign({}, result.payload);
|
|
1743
|
+
}
|
|
1744
|
+
if ("errors" in result) {
|
|
1745
|
+
next = tslib.__assign(tslib.__assign({}, next), { extensions: tslib.__assign(tslib.__assign({}, ("extensions" in next ? next.extensions : null)), (_h = {}, _h[PROTOCOL_ERRORS_SYMBOL] = result.errors, _h)) });
|
|
1746
|
+
}
|
|
1747
|
+
(_b = observer.next) === null || _b === void 0 ? void 0 : _b.call(observer, next);
|
|
1748
|
+
}
|
|
1749
|
+
else {
|
|
1750
|
+
(_c = observer.next) === null || _c === void 0 ? void 0 : _c.call(observer, result);
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
else if (Object.keys(result).length === 1 &&
|
|
1754
|
+
"hasNext" in result &&
|
|
1755
|
+
!result.hasNext) {
|
|
1756
|
+
(_d = observer.complete) === null || _d === void 0 ? void 0 : _d.call(observer);
|
|
1598
1757
|
}
|
|
1599
1758
|
}
|
|
1600
1759
|
catch (err) {
|
|
@@ -1605,7 +1764,7 @@ function readMultipartBody(response, observer) {
|
|
|
1605
1764
|
}
|
|
1606
1765
|
return [3, 1];
|
|
1607
1766
|
case 3:
|
|
1608
|
-
(
|
|
1767
|
+
(_e = observer.complete) === null || _e === void 0 ? void 0 : _e.call(observer);
|
|
1609
1768
|
return [2];
|
|
1610
1769
|
}
|
|
1611
1770
|
});
|
|
@@ -1744,7 +1903,7 @@ function selectHttpOptionsAndBodyInternal(operation, printer) {
|
|
|
1744
1903
|
options.headers = removeDuplicateHeaders(options.headers, http.preserveHeaderCase);
|
|
1745
1904
|
}
|
|
1746
1905
|
var operationName = operation.operationName, extensions = operation.extensions, variables = operation.variables, query = operation.query;
|
|
1747
|
-
var body = { operationName: operationName, variables: variables };
|
|
1906
|
+
var body = { operationName: operationName, variables: stripTypename(variables) };
|
|
1748
1907
|
if (http.includeExtensions)
|
|
1749
1908
|
body.extensions = extensions;
|
|
1750
1909
|
if (http.includeQuery)
|
|
@@ -1885,20 +2044,7 @@ var createHttpLink = function (linkOptions) {
|
|
|
1885
2044
|
}
|
|
1886
2045
|
var _b = selectHttpOptionsAndBodyInternal(operation, print, fallbackHttpConfig, linkConfig, contextConfig), options = _b.options, body = _b.body;
|
|
1887
2046
|
if (body.variables && !includeUnusedVariables) {
|
|
1888
|
-
|
|
1889
|
-
graphql.visit(operation.query, {
|
|
1890
|
-
Variable: function (node, _key, parent) {
|
|
1891
|
-
if (parent && parent.kind !== 'VariableDefinition') {
|
|
1892
|
-
unusedNames_1.delete(node.name.value);
|
|
1893
|
-
}
|
|
1894
|
-
},
|
|
1895
|
-
});
|
|
1896
|
-
if (unusedNames_1.size) {
|
|
1897
|
-
body.variables = tslib.__assign({}, body.variables);
|
|
1898
|
-
unusedNames_1.forEach(function (name) {
|
|
1899
|
-
delete body.variables[name];
|
|
1900
|
-
});
|
|
1901
|
-
}
|
|
2047
|
+
body.variables = filterOperationVariables(body.variables, operation);
|
|
1902
2048
|
}
|
|
1903
2049
|
var controller;
|
|
1904
2050
|
if (!options.signal) {
|
|
@@ -1910,13 +2056,28 @@ var createHttpLink = function (linkOptions) {
|
|
|
1910
2056
|
var definitionIsMutation = function (d) {
|
|
1911
2057
|
return d.kind === 'OperationDefinition' && d.operation === 'mutation';
|
|
1912
2058
|
};
|
|
2059
|
+
var definitionIsSubscription = function (d) {
|
|
2060
|
+
return d.kind === 'OperationDefinition' && d.operation === 'subscription';
|
|
2061
|
+
};
|
|
2062
|
+
var isSubscription = definitionIsSubscription(getMainDefinition(operation.query));
|
|
2063
|
+
var hasDefer = hasDirectives(['defer'], operation.query);
|
|
1913
2064
|
if (useGETForQueries &&
|
|
1914
2065
|
!operation.query.definitions.some(definitionIsMutation)) {
|
|
1915
2066
|
options.method = 'GET';
|
|
1916
2067
|
}
|
|
1917
|
-
if (
|
|
2068
|
+
if (hasDefer || isSubscription) {
|
|
1918
2069
|
options.headers = options.headers || {};
|
|
1919
|
-
|
|
2070
|
+
var acceptHeader = "multipart/mixed;";
|
|
2071
|
+
if (isSubscription && hasDefer) {
|
|
2072
|
+
__DEV__ && tsInvariant.invariant.warn("Multipart-subscriptions do not support @defer");
|
|
2073
|
+
}
|
|
2074
|
+
if (isSubscription) {
|
|
2075
|
+
acceptHeader += 'boundary=graphql;subscriptionSpec=1.0,application/json';
|
|
2076
|
+
}
|
|
2077
|
+
else if (hasDefer) {
|
|
2078
|
+
acceptHeader += 'deferSpec=20220824,application/json';
|
|
2079
|
+
}
|
|
2080
|
+
options.headers.accept = acceptHeader;
|
|
1920
2081
|
}
|
|
1921
2082
|
if (options.method === 'GET') {
|
|
1922
2083
|
var _d = rewriteURIForGET(chosenURI, body), newURI = _d.newURI, parseError = _d.parseError;
|
|
@@ -2568,7 +2729,7 @@ var Layer = (function (_super) {
|
|
|
2568
2729
|
}
|
|
2569
2730
|
else if (ownStoreObject !== parentStoreObject) {
|
|
2570
2731
|
Object.keys(ownStoreObject).forEach(function (storeFieldName) {
|
|
2571
|
-
if (!
|
|
2732
|
+
if (!equal.equal(ownStoreObject[storeFieldName], parentStoreObject[storeFieldName])) {
|
|
2572
2733
|
_this.group.dirty(dataId, storeFieldName);
|
|
2573
2734
|
}
|
|
2574
2735
|
});
|
|
@@ -2612,7 +2773,7 @@ var Stump = (function (_super) {
|
|
|
2612
2773
|
function storeObjectReconciler(existingObject, incomingObject, property) {
|
|
2613
2774
|
var existingValue = existingObject[property];
|
|
2614
2775
|
var incomingValue = incomingObject[property];
|
|
2615
|
-
return
|
|
2776
|
+
return equal.equal(existingValue, incomingValue) ? existingValue : incomingValue;
|
|
2616
2777
|
}
|
|
2617
2778
|
function supportsResultCaching(store) {
|
|
2618
2779
|
return !!(store instanceof EntityStore && store.group.caching);
|
|
@@ -3939,7 +4100,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
|
|
|
3939
4100
|
return;
|
|
3940
4101
|
if (isReference(existing))
|
|
3941
4102
|
return;
|
|
3942
|
-
if (
|
|
4103
|
+
if (equal.equal(existing, incoming))
|
|
3943
4104
|
return;
|
|
3944
4105
|
if (Object.keys(existing).every(function (key) { return store.getFieldValue(incoming, key) !== void 0; })) {
|
|
3945
4106
|
return;
|
|
@@ -4262,51 +4423,13 @@ var InMemoryCache = (function (_super) {
|
|
|
4262
4423
|
return;
|
|
4263
4424
|
}
|
|
4264
4425
|
}
|
|
4265
|
-
if (!lastDiff || !
|
|
4426
|
+
if (!lastDiff || !equal.equal(lastDiff.result, diff.result)) {
|
|
4266
4427
|
c.callback(c.lastDiff = diff, lastDiff);
|
|
4267
4428
|
}
|
|
4268
4429
|
};
|
|
4269
4430
|
return InMemoryCache;
|
|
4270
4431
|
}(ApolloCache));
|
|
4271
4432
|
|
|
4272
|
-
function isApolloError(err) {
|
|
4273
|
-
return err.hasOwnProperty('graphQLErrors');
|
|
4274
|
-
}
|
|
4275
|
-
var generateErrorMessage = function (err) {
|
|
4276
|
-
var message = '';
|
|
4277
|
-
if (isNonEmptyArray(err.graphQLErrors) || isNonEmptyArray(err.clientErrors)) {
|
|
4278
|
-
var errors = (err.graphQLErrors || [])
|
|
4279
|
-
.concat(err.clientErrors || []);
|
|
4280
|
-
errors.forEach(function (error) {
|
|
4281
|
-
var errorMessage = error
|
|
4282
|
-
? error.message
|
|
4283
|
-
: 'Error message not found.';
|
|
4284
|
-
message += "".concat(errorMessage, "\n");
|
|
4285
|
-
});
|
|
4286
|
-
}
|
|
4287
|
-
if (err.networkError) {
|
|
4288
|
-
message += "".concat(err.networkError.message, "\n");
|
|
4289
|
-
}
|
|
4290
|
-
message = message.replace(/\n$/, '');
|
|
4291
|
-
return message;
|
|
4292
|
-
};
|
|
4293
|
-
var ApolloError = (function (_super) {
|
|
4294
|
-
tslib.__extends(ApolloError, _super);
|
|
4295
|
-
function ApolloError(_a) {
|
|
4296
|
-
var graphQLErrors = _a.graphQLErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;
|
|
4297
|
-
var _this = _super.call(this, errorMessage) || this;
|
|
4298
|
-
_this.name = 'ApolloError';
|
|
4299
|
-
_this.graphQLErrors = graphQLErrors || [];
|
|
4300
|
-
_this.clientErrors = clientErrors || [];
|
|
4301
|
-
_this.networkError = networkError || null;
|
|
4302
|
-
_this.message = errorMessage || generateErrorMessage(_this);
|
|
4303
|
-
_this.extraInfo = extraInfo;
|
|
4304
|
-
_this.__proto__ = ApolloError.prototype;
|
|
4305
|
-
return _this;
|
|
4306
|
-
}
|
|
4307
|
-
return ApolloError;
|
|
4308
|
-
}(Error));
|
|
4309
|
-
|
|
4310
4433
|
exports.NetworkStatus = void 0;
|
|
4311
4434
|
(function (NetworkStatus) {
|
|
4312
4435
|
NetworkStatus[NetworkStatus["loading"] = 1] = "loading";
|
|
@@ -4324,6 +4447,70 @@ function isNetworkRequestSettled(networkStatus) {
|
|
|
4324
4447
|
return networkStatus === 7 || networkStatus === 8;
|
|
4325
4448
|
}
|
|
4326
4449
|
|
|
4450
|
+
function equalByQuery(query, _a, _b, variables) {
|
|
4451
|
+
var aData = _a.data, aRest = tslib.__rest(_a, ["data"]);
|
|
4452
|
+
var bData = _b.data, bRest = tslib.__rest(_b, ["data"]);
|
|
4453
|
+
return equal__default(aRest, bRest) && equalBySelectionSet(getMainDefinition(query).selectionSet, aData, bData, {
|
|
4454
|
+
fragmentMap: createFragmentMap(getFragmentDefinitions(query)),
|
|
4455
|
+
variables: variables,
|
|
4456
|
+
});
|
|
4457
|
+
}
|
|
4458
|
+
function equalBySelectionSet(selectionSet, aResult, bResult, context) {
|
|
4459
|
+
if (aResult === bResult) {
|
|
4460
|
+
return true;
|
|
4461
|
+
}
|
|
4462
|
+
var seenSelections = new Set();
|
|
4463
|
+
return selectionSet.selections.every(function (selection) {
|
|
4464
|
+
if (seenSelections.has(selection))
|
|
4465
|
+
return true;
|
|
4466
|
+
seenSelections.add(selection);
|
|
4467
|
+
if (!shouldInclude(selection, context.variables))
|
|
4468
|
+
return true;
|
|
4469
|
+
if (selectionHasNonreactiveDirective(selection))
|
|
4470
|
+
return true;
|
|
4471
|
+
if (isField(selection)) {
|
|
4472
|
+
var resultKey = resultKeyNameFromField(selection);
|
|
4473
|
+
var aResultChild = aResult && aResult[resultKey];
|
|
4474
|
+
var bResultChild = bResult && bResult[resultKey];
|
|
4475
|
+
var childSelectionSet = selection.selectionSet;
|
|
4476
|
+
if (!childSelectionSet) {
|
|
4477
|
+
return equal__default(aResultChild, bResultChild);
|
|
4478
|
+
}
|
|
4479
|
+
var aChildIsArray = Array.isArray(aResultChild);
|
|
4480
|
+
var bChildIsArray = Array.isArray(bResultChild);
|
|
4481
|
+
if (aChildIsArray !== bChildIsArray)
|
|
4482
|
+
return false;
|
|
4483
|
+
if (aChildIsArray && bChildIsArray) {
|
|
4484
|
+
var length_1 = aResultChild.length;
|
|
4485
|
+
if (bResultChild.length !== length_1) {
|
|
4486
|
+
return false;
|
|
4487
|
+
}
|
|
4488
|
+
for (var i = 0; i < length_1; ++i) {
|
|
4489
|
+
if (!equalBySelectionSet(childSelectionSet, aResultChild[i], bResultChild[i], context)) {
|
|
4490
|
+
return false;
|
|
4491
|
+
}
|
|
4492
|
+
}
|
|
4493
|
+
return true;
|
|
4494
|
+
}
|
|
4495
|
+
return equalBySelectionSet(childSelectionSet, aResultChild, bResultChild, context);
|
|
4496
|
+
}
|
|
4497
|
+
else {
|
|
4498
|
+
var fragment = getFragmentFromSelection(selection, context.fragmentMap);
|
|
4499
|
+
if (fragment) {
|
|
4500
|
+
if (selectionHasNonreactiveDirective(fragment))
|
|
4501
|
+
return true;
|
|
4502
|
+
return equalBySelectionSet(fragment.selectionSet, aResult, bResult, context);
|
|
4503
|
+
}
|
|
4504
|
+
}
|
|
4505
|
+
});
|
|
4506
|
+
}
|
|
4507
|
+
function selectionHasNonreactiveDirective(selection) {
|
|
4508
|
+
return !!selection.directives && selection.directives.some(directiveIsNonreactive);
|
|
4509
|
+
}
|
|
4510
|
+
function directiveIsNonreactive(dir) {
|
|
4511
|
+
return dir.name.value === "nonreactive";
|
|
4512
|
+
}
|
|
4513
|
+
|
|
4327
4514
|
var assign = Object.assign, hasOwnProperty$2 = Object.hasOwnProperty;
|
|
4328
4515
|
var ObservableQuery = (function (_super) {
|
|
4329
4516
|
tslib.__extends(ObservableQuery, _super);
|
|
@@ -4418,7 +4605,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4418
4605
|
if (diff.complete || this.options.returnPartialData) {
|
|
4419
4606
|
result.data = diff.result;
|
|
4420
4607
|
}
|
|
4421
|
-
if (
|
|
4608
|
+
if (equal.equal(result.data, {})) {
|
|
4422
4609
|
result.data = void 0;
|
|
4423
4610
|
}
|
|
4424
4611
|
if (diff.complete) {
|
|
@@ -4449,15 +4636,21 @@ var ObservableQuery = (function (_super) {
|
|
|
4449
4636
|
return result;
|
|
4450
4637
|
};
|
|
4451
4638
|
ObservableQuery.prototype.isDifferentFromLastResult = function (newResult, variables) {
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4639
|
+
if (!this.last) {
|
|
4640
|
+
return true;
|
|
4641
|
+
}
|
|
4642
|
+
var query = this.options.query;
|
|
4643
|
+
var resultIsDifferent = this.queryManager.transform(query).hasNonreactiveDirective
|
|
4644
|
+
? !equalByQuery(query, this.last.result, newResult, this.variables)
|
|
4645
|
+
: !equal.equal(this.last.result, newResult);
|
|
4646
|
+
return (resultIsDifferent ||
|
|
4647
|
+
(variables && !equal.equal(this.last.variables, variables)));
|
|
4455
4648
|
};
|
|
4456
4649
|
ObservableQuery.prototype.getLast = function (key, variablesMustMatch) {
|
|
4457
4650
|
var last = this.last;
|
|
4458
4651
|
if (last &&
|
|
4459
4652
|
last[key] &&
|
|
4460
|
-
(!variablesMustMatch ||
|
|
4653
|
+
(!variablesMustMatch || equal.equal(last.variables, this.variables))) {
|
|
4461
4654
|
return last[key];
|
|
4462
4655
|
}
|
|
4463
4656
|
};
|
|
@@ -4496,7 +4689,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4496
4689
|
__DEV__ && tsInvariant.invariant.warn("Called refetch(".concat(JSON.stringify(variables), ") for query ").concat(((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || JSON.stringify(queryDef), ", which does not declare a $variables variable.\nDid you mean to call refetch(variables) instead of refetch({ variables })?"));
|
|
4497
4690
|
}
|
|
4498
4691
|
}
|
|
4499
|
-
if (variables && !
|
|
4692
|
+
if (variables && !equal.equal(this.options.variables, variables)) {
|
|
4500
4693
|
reobserveOptions.variables = this.options.variables = tslib.__assign(tslib.__assign({}, this.options.variables), variables);
|
|
4501
4694
|
}
|
|
4502
4695
|
this.queryInfo.resetLastWrite();
|
|
@@ -4591,7 +4784,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4591
4784
|
return this.reobserve(newOptions);
|
|
4592
4785
|
};
|
|
4593
4786
|
ObservableQuery.prototype.setVariables = function (variables) {
|
|
4594
|
-
if (
|
|
4787
|
+
if (equal.equal(this.variables, variables)) {
|
|
4595
4788
|
return this.observers.size
|
|
4596
4789
|
? this.result()
|
|
4597
4790
|
: Promise.resolve();
|
|
@@ -4656,7 +4849,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4656
4849
|
};
|
|
4657
4850
|
ObservableQuery.prototype.fetch = function (options, newNetworkStatus) {
|
|
4658
4851
|
this.queryManager.setObservableQuery(this);
|
|
4659
|
-
return this.queryManager
|
|
4852
|
+
return this.queryManager['fetchConcastWithInfo'](this.queryId, options, newNetworkStatus);
|
|
4660
4853
|
};
|
|
4661
4854
|
ObservableQuery.prototype.updatePolling = function () {
|
|
4662
4855
|
var _this = this;
|
|
@@ -4701,15 +4894,15 @@ var ObservableQuery = (function (_super) {
|
|
|
4701
4894
|
};
|
|
4702
4895
|
ObservableQuery.prototype.updateLastResult = function (newResult, variables) {
|
|
4703
4896
|
if (variables === void 0) { variables = this.variables; }
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
if (!isNonEmptyArray(newResult.errors)) {
|
|
4708
|
-
delete this.last.error;
|
|
4897
|
+
var error = this.getLastError();
|
|
4898
|
+
if (error && this.last && !equal.equal(variables, this.last.variables)) {
|
|
4899
|
+
error = void 0;
|
|
4709
4900
|
}
|
|
4710
|
-
return this.last
|
|
4901
|
+
return this.last = tslib.__assign({ result: this.queryManager.assumeImmutableResults
|
|
4902
|
+
? newResult
|
|
4903
|
+
: cloneDeep(newResult), variables: variables }, (error ? { error: error } : null));
|
|
4711
4904
|
};
|
|
4712
|
-
ObservableQuery.prototype.
|
|
4905
|
+
ObservableQuery.prototype.reobserveAsConcast = function (newOptions, newNetworkStatus) {
|
|
4713
4906
|
var _this = this;
|
|
4714
4907
|
this.isTornDown = false;
|
|
4715
4908
|
var useDisposableConcast = newNetworkStatus === exports.NetworkStatus.refetch ||
|
|
@@ -4725,7 +4918,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4725
4918
|
this.updatePolling();
|
|
4726
4919
|
if (newOptions &&
|
|
4727
4920
|
newOptions.variables &&
|
|
4728
|
-
!
|
|
4921
|
+
!equal.equal(newOptions.variables, oldVariables) &&
|
|
4729
4922
|
options.fetchPolicy !== "standby" &&
|
|
4730
4923
|
options.fetchPolicy === oldFetchPolicy) {
|
|
4731
4924
|
this.applyNextFetchPolicy("variables-changed", options);
|
|
@@ -4735,7 +4928,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4735
4928
|
}
|
|
4736
4929
|
}
|
|
4737
4930
|
var variables = options.variables && tslib.__assign({}, options.variables);
|
|
4738
|
-
var
|
|
4931
|
+
var _a = this.fetch(options, newNetworkStatus), concast = _a.concast, fromLink = _a.fromLink;
|
|
4739
4932
|
var observer = {
|
|
4740
4933
|
next: function (result) {
|
|
4741
4934
|
_this.reportResult(result, variables);
|
|
@@ -4744,7 +4937,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4744
4937
|
_this.reportError(error, variables);
|
|
4745
4938
|
},
|
|
4746
4939
|
};
|
|
4747
|
-
if (!useDisposableConcast) {
|
|
4940
|
+
if (!useDisposableConcast && (fromLink || !this.concast)) {
|
|
4748
4941
|
if (this.concast && this.observer) {
|
|
4749
4942
|
this.concast.removeObserver(this.observer);
|
|
4750
4943
|
}
|
|
@@ -4752,18 +4945,22 @@ var ObservableQuery = (function (_super) {
|
|
|
4752
4945
|
this.observer = observer;
|
|
4753
4946
|
}
|
|
4754
4947
|
concast.addObserver(observer);
|
|
4755
|
-
return concast
|
|
4948
|
+
return concast;
|
|
4949
|
+
};
|
|
4950
|
+
ObservableQuery.prototype.reobserve = function (newOptions, newNetworkStatus) {
|
|
4951
|
+
return this.reobserveAsConcast(newOptions, newNetworkStatus).promise;
|
|
4756
4952
|
};
|
|
4757
4953
|
ObservableQuery.prototype.observe = function () {
|
|
4758
4954
|
this.reportResult(this.getCurrentResult(false), this.variables);
|
|
4759
4955
|
};
|
|
4760
4956
|
ObservableQuery.prototype.reportResult = function (result, variables) {
|
|
4761
4957
|
var lastError = this.getLastError();
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4958
|
+
var isDifferent = this.isDifferentFromLastResult(result, variables);
|
|
4959
|
+
if (lastError || !result.partial || this.options.returnPartialData) {
|
|
4960
|
+
this.updateLastResult(result, variables);
|
|
4961
|
+
}
|
|
4962
|
+
if (lastError || isDifferent) {
|
|
4963
|
+
iterateObserversSafely(this.observers, "next", result);
|
|
4767
4964
|
}
|
|
4768
4965
|
};
|
|
4769
4966
|
ObservableQuery.prototype.reportError = function (error, variables) {
|
|
@@ -5172,10 +5369,10 @@ var QueryInfo = (function () {
|
|
|
5172
5369
|
var networkStatus = query.networkStatus || exports.NetworkStatus.loading;
|
|
5173
5370
|
if (this.variables &&
|
|
5174
5371
|
this.networkStatus !== exports.NetworkStatus.loading &&
|
|
5175
|
-
!
|
|
5372
|
+
!equal.equal(this.variables, query.variables)) {
|
|
5176
5373
|
networkStatus = exports.NetworkStatus.setVariables;
|
|
5177
5374
|
}
|
|
5178
|
-
if (!
|
|
5375
|
+
if (!equal.equal(query.variables, this.variables)) {
|
|
5179
5376
|
this.lastDiff = void 0;
|
|
5180
5377
|
}
|
|
5181
5378
|
Object.assign(this, {
|
|
@@ -5200,7 +5397,7 @@ var QueryInfo = (function () {
|
|
|
5200
5397
|
QueryInfo.prototype.getDiff = function (variables) {
|
|
5201
5398
|
if (variables === void 0) { variables = this.variables; }
|
|
5202
5399
|
var options = this.getDiffOptions(variables);
|
|
5203
|
-
if (this.lastDiff &&
|
|
5400
|
+
if (this.lastDiff && equal.equal(options, this.lastDiff.options)) {
|
|
5204
5401
|
return this.lastDiff.diff;
|
|
5205
5402
|
}
|
|
5206
5403
|
this.updateWatch(this.variables = variables);
|
|
@@ -5234,7 +5431,7 @@ var QueryInfo = (function () {
|
|
|
5234
5431
|
var oldDiff = this.lastDiff && this.lastDiff.diff;
|
|
5235
5432
|
this.updateLastDiff(diff);
|
|
5236
5433
|
if (!this.dirty &&
|
|
5237
|
-
!
|
|
5434
|
+
!equal.equal(oldDiff && oldDiff.result, diff && diff.result)) {
|
|
5238
5435
|
this.dirty = true;
|
|
5239
5436
|
if (!this.notifyTimeout) {
|
|
5240
5437
|
this.notifyTimeout = setTimeout(function () { return _this.notify(); }, 0);
|
|
@@ -5309,7 +5506,7 @@ var QueryInfo = (function () {
|
|
|
5309
5506
|
}
|
|
5310
5507
|
var watchOptions = tslib.__assign(tslib.__assign({}, this.getDiffOptions(variables)), { watcher: this, callback: function (diff) { return _this.setDiff(diff); } });
|
|
5311
5508
|
if (!this.lastWatch ||
|
|
5312
|
-
!
|
|
5509
|
+
!equal.equal(watchOptions, this.lastWatch)) {
|
|
5313
5510
|
this.cancel();
|
|
5314
5511
|
this.cancel = this.cache.watch(this.lastWatch = watchOptions);
|
|
5315
5512
|
}
|
|
@@ -5321,8 +5518,8 @@ var QueryInfo = (function () {
|
|
|
5321
5518
|
var lastWrite = this.lastWrite;
|
|
5322
5519
|
return !(lastWrite &&
|
|
5323
5520
|
lastWrite.dmCount === destructiveMethodCounts.get(this.cache) &&
|
|
5324
|
-
|
|
5325
|
-
|
|
5521
|
+
equal.equal(variables, lastWrite.variables) &&
|
|
5522
|
+
equal.equal(result.data, lastWrite.result.data));
|
|
5326
5523
|
};
|
|
5327
5524
|
QueryInfo.prototype.markResult = function (result, document, options, cacheWriteBehavior) {
|
|
5328
5525
|
var _this = this;
|
|
@@ -5724,14 +5921,17 @@ var QueryManager = (function () {
|
|
|
5724
5921
|
var _a = (this.defaultOptions.transformQuery || Object.create(null)).removeClientFields, removeClientFields = _a === void 0 ? true : _a;
|
|
5725
5922
|
if (!transformCache.has(document)) {
|
|
5726
5923
|
var transformed = this.cache.transformDocument(document);
|
|
5727
|
-
var
|
|
5924
|
+
var serverQuery = removeDirectivesFromDocument([
|
|
5925
|
+
removeClientFields ? { name: 'client', remove: true } : {},
|
|
5926
|
+
{ name: 'connection' },
|
|
5927
|
+
{ name: 'nonreactive' },
|
|
5928
|
+
], transformed);
|
|
5728
5929
|
var clientQuery = this.localState.clientQuery(transformed);
|
|
5729
|
-
var serverQuery = noConnection &&
|
|
5730
|
-
this.localState.serverQuery(noConnection, { removeClientFields: removeClientFields });
|
|
5731
5930
|
var cacheEntry_1 = {
|
|
5732
5931
|
document: transformed,
|
|
5733
5932
|
hasClientExports: hasClientExports(transformed),
|
|
5734
5933
|
hasForcedResolvers: this.localState.shouldForceResolvers(transformed),
|
|
5934
|
+
hasNonreactiveDirective: hasDirectives(['nonreactive'], transformed),
|
|
5735
5935
|
clientQuery: clientQuery,
|
|
5736
5936
|
serverQuery: serverQuery,
|
|
5737
5937
|
defaultVars: getDefaultValues(getOperationDefinition(transformed)),
|
|
@@ -5929,10 +6129,17 @@ var QueryManager = (function () {
|
|
|
5929
6129
|
}
|
|
5930
6130
|
_this.broadcastQueries();
|
|
5931
6131
|
}
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
}
|
|
6132
|
+
var hasErrors = graphQLResultHasError(result);
|
|
6133
|
+
var hasProtocolErrors = graphQLResultHasProtocolErrors(result);
|
|
6134
|
+
if (hasErrors || hasProtocolErrors) {
|
|
6135
|
+
var errors = {};
|
|
6136
|
+
if (hasErrors) {
|
|
6137
|
+
errors.graphQLErrors = result.errors;
|
|
6138
|
+
}
|
|
6139
|
+
if (hasProtocolErrors) {
|
|
6140
|
+
errors.protocolErrors = result.extensions[PROTOCOL_ERRORS_SYMBOL];
|
|
6141
|
+
}
|
|
6142
|
+
throw new ApolloError(errors);
|
|
5936
6143
|
}
|
|
5937
6144
|
return result;
|
|
5938
6145
|
});
|
|
@@ -6064,6 +6271,9 @@ var QueryManager = (function () {
|
|
|
6064
6271
|
});
|
|
6065
6272
|
};
|
|
6066
6273
|
QueryManager.prototype.fetchQueryObservable = function (queryId, options, networkStatus) {
|
|
6274
|
+
return this.fetchConcastWithInfo(queryId, options, networkStatus).concast;
|
|
6275
|
+
};
|
|
6276
|
+
QueryManager.prototype.fetchConcastWithInfo = function (queryId, options, networkStatus) {
|
|
6067
6277
|
var _this = this;
|
|
6068
6278
|
if (networkStatus === void 0) { networkStatus = exports.NetworkStatus.loading; }
|
|
6069
6279
|
var query = this.transform(options.query).document;
|
|
@@ -6082,24 +6292,36 @@ var QueryManager = (function () {
|
|
|
6082
6292
|
});
|
|
6083
6293
|
var fromVariables = function (variables) {
|
|
6084
6294
|
normalized.variables = variables;
|
|
6085
|
-
var
|
|
6295
|
+
var sourcesWithInfo = _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
|
|
6086
6296
|
if (normalized.fetchPolicy !== "standby" &&
|
|
6087
|
-
|
|
6297
|
+
sourcesWithInfo.sources.length > 0 &&
|
|
6088
6298
|
queryInfo.observableQuery) {
|
|
6089
6299
|
queryInfo.observableQuery["applyNextFetchPolicy"]("after-fetch", options);
|
|
6090
6300
|
}
|
|
6091
|
-
return
|
|
6301
|
+
return sourcesWithInfo;
|
|
6092
6302
|
};
|
|
6093
6303
|
var cleanupCancelFn = function () { return _this.fetchCancelFns.delete(queryId); };
|
|
6094
6304
|
this.fetchCancelFns.set(queryId, function (reason) {
|
|
6095
6305
|
cleanupCancelFn();
|
|
6096
6306
|
setTimeout(function () { return concast.cancel(reason); });
|
|
6097
6307
|
});
|
|
6098
|
-
var concast
|
|
6099
|
-
|
|
6100
|
-
|
|
6308
|
+
var concast, containsDataFromLink;
|
|
6309
|
+
if (this.transform(normalized.query).hasClientExports) {
|
|
6310
|
+
concast = new Concast(this.localState
|
|
6311
|
+
.addExportedVariables(normalized.query, normalized.variables, normalized.context)
|
|
6312
|
+
.then(fromVariables).then(function (sourcesWithInfo) { return sourcesWithInfo.sources; }));
|
|
6313
|
+
containsDataFromLink = true;
|
|
6314
|
+
}
|
|
6315
|
+
else {
|
|
6316
|
+
var sourcesWithInfo = fromVariables(normalized.variables);
|
|
6317
|
+
containsDataFromLink = sourcesWithInfo.fromLink;
|
|
6318
|
+
concast = new Concast(sourcesWithInfo.sources);
|
|
6319
|
+
}
|
|
6101
6320
|
concast.promise.then(cleanupCancelFn, cleanupCancelFn);
|
|
6102
|
-
return
|
|
6321
|
+
return {
|
|
6322
|
+
concast: concast,
|
|
6323
|
+
fromLink: containsDataFromLink,
|
|
6324
|
+
};
|
|
6103
6325
|
};
|
|
6104
6326
|
QueryManager.prototype.refetchQueries = function (_a) {
|
|
6105
6327
|
var _this = this;
|
|
@@ -6184,7 +6406,7 @@ var QueryManager = (function () {
|
|
|
6184
6406
|
var data = diff.result;
|
|
6185
6407
|
if (__DEV__ &&
|
|
6186
6408
|
!returnPartialData &&
|
|
6187
|
-
!
|
|
6409
|
+
!equal.equal(data, {})) {
|
|
6188
6410
|
logMissingFieldErrors(diff.missing);
|
|
6189
6411
|
}
|
|
6190
6412
|
var fromData = function (data) { return zenObservableTs.Observable.of(tslib.__assign({ data: data, loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus }, (diff.complete ? null : { partial: true }))); };
|
|
@@ -6223,54 +6445,40 @@ var QueryManager = (function () {
|
|
|
6223
6445
|
case "cache-first": {
|
|
6224
6446
|
var diff = readCache();
|
|
6225
6447
|
if (diff.complete) {
|
|
6226
|
-
return [
|
|
6227
|
-
resultsFromCache(diff, queryInfo.markReady()),
|
|
6228
|
-
];
|
|
6448
|
+
return { fromLink: false, sources: [resultsFromCache(diff, queryInfo.markReady())] };
|
|
6229
6449
|
}
|
|
6230
6450
|
if (returnPartialData || shouldNotify) {
|
|
6231
|
-
return [
|
|
6232
|
-
resultsFromCache(diff),
|
|
6233
|
-
resultsFromLink(),
|
|
6234
|
-
];
|
|
6451
|
+
return { fromLink: true, sources: [resultsFromCache(diff), resultsFromLink()] };
|
|
6235
6452
|
}
|
|
6236
|
-
return [
|
|
6237
|
-
resultsFromLink(),
|
|
6238
|
-
];
|
|
6453
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
6239
6454
|
}
|
|
6240
6455
|
case "cache-and-network": {
|
|
6241
6456
|
var diff = readCache();
|
|
6242
6457
|
if (diff.complete || returnPartialData || shouldNotify) {
|
|
6243
|
-
return [
|
|
6244
|
-
resultsFromCache(diff),
|
|
6245
|
-
resultsFromLink(),
|
|
6246
|
-
];
|
|
6458
|
+
return { fromLink: true, sources: [resultsFromCache(diff), resultsFromLink()] };
|
|
6247
6459
|
}
|
|
6248
|
-
return [
|
|
6249
|
-
resultsFromLink(),
|
|
6250
|
-
];
|
|
6460
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
6251
6461
|
}
|
|
6252
6462
|
case "cache-only":
|
|
6253
|
-
return [
|
|
6254
|
-
resultsFromCache(readCache(), queryInfo.markReady()),
|
|
6255
|
-
];
|
|
6463
|
+
return { fromLink: false, sources: [resultsFromCache(readCache(), queryInfo.markReady())] };
|
|
6256
6464
|
case "network-only":
|
|
6257
6465
|
if (shouldNotify) {
|
|
6258
|
-
return [
|
|
6259
|
-
resultsFromCache(readCache()),
|
|
6260
|
-
resultsFromLink(),
|
|
6261
|
-
];
|
|
6466
|
+
return { fromLink: true, sources: [resultsFromCache(readCache()), resultsFromLink()] };
|
|
6262
6467
|
}
|
|
6263
|
-
return [resultsFromLink()];
|
|
6468
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
6264
6469
|
case "no-cache":
|
|
6265
6470
|
if (shouldNotify) {
|
|
6266
|
-
return
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6471
|
+
return {
|
|
6472
|
+
fromLink: true,
|
|
6473
|
+
sources: [
|
|
6474
|
+
resultsFromCache(queryInfo.getDiff()),
|
|
6475
|
+
resultsFromLink(),
|
|
6476
|
+
],
|
|
6477
|
+
};
|
|
6270
6478
|
}
|
|
6271
|
-
return [resultsFromLink()];
|
|
6479
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
6272
6480
|
case "standby":
|
|
6273
|
-
return [];
|
|
6481
|
+
return { fromLink: false, sources: [] };
|
|
6274
6482
|
}
|
|
6275
6483
|
};
|
|
6276
6484
|
QueryManager.prototype.getQuery = function (queryId) {
|
|
@@ -6544,7 +6752,7 @@ var ApolloConsumer = function (props) {
|
|
|
6544
6752
|
var ApolloContext = getApolloContext();
|
|
6545
6753
|
return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
|
|
6546
6754
|
__DEV__ ? tsInvariant.invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
|
|
6547
|
-
'Wrap the root component in an <ApolloProvider>.') : tsInvariant.invariant(context && context.client,
|
|
6755
|
+
'Wrap the root component in an <ApolloProvider>.') : tsInvariant.invariant(context && context.client, 28);
|
|
6548
6756
|
return props.children(context.client);
|
|
6549
6757
|
}));
|
|
6550
6758
|
};
|
|
@@ -6561,7 +6769,7 @@ var ApolloProvider = function (_a) {
|
|
|
6561
6769
|
context = Object.assign({}, context, { suspenseCache: suspenseCache });
|
|
6562
6770
|
}
|
|
6563
6771
|
__DEV__ ? tsInvariant.invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
|
|
6564
|
-
'sure you pass in your client via the "client" prop.') : tsInvariant.invariant(context.client,
|
|
6772
|
+
'sure you pass in your client via the "client" prop.') : tsInvariant.invariant(context.client, 29);
|
|
6565
6773
|
return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
|
|
6566
6774
|
}));
|
|
6567
6775
|
};
|
|
@@ -6571,14 +6779,14 @@ function useApolloClient(override) {
|
|
|
6571
6779
|
var client = override || context.client;
|
|
6572
6780
|
__DEV__ ? tsInvariant.invariant(!!client, 'Could not find "client" in the context or passed in as an option. ' +
|
|
6573
6781
|
'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient ' +
|
|
6574
|
-
'instance in via options.') : tsInvariant.invariant(!!client,
|
|
6782
|
+
'instance in via options.') : tsInvariant.invariant(!!client, 32);
|
|
6575
6783
|
return client;
|
|
6576
6784
|
}
|
|
6577
6785
|
|
|
6578
6786
|
var didWarnUncachedGetSnapshot = false;
|
|
6579
6787
|
var uSESKey = "useSyncExternalStore";
|
|
6580
|
-
var realHook = React__namespace[uSESKey];
|
|
6581
|
-
var useSyncExternalStore = realHook || (function (subscribe, getSnapshot, getServerSnapshot) {
|
|
6788
|
+
var realHook$1 = React__namespace[uSESKey];
|
|
6789
|
+
var useSyncExternalStore = realHook$1 || (function (subscribe, getSnapshot, getServerSnapshot) {
|
|
6582
6790
|
var value = getSnapshot();
|
|
6583
6791
|
if (__DEV__ &&
|
|
6584
6792
|
!didWarnUncachedGetSnapshot &&
|
|
@@ -6649,7 +6857,7 @@ function parser(document) {
|
|
|
6649
6857
|
var variables, type, name;
|
|
6650
6858
|
__DEV__ ? tsInvariant.invariant(!!document && !!document.kind, "Argument of ".concat(document, " passed to parser was not a valid GraphQL ") +
|
|
6651
6859
|
"DocumentNode. You may need to use 'graphql-tag' or another method " +
|
|
6652
|
-
"to convert your operation into a document") : tsInvariant.invariant(!!document && !!document.kind,
|
|
6860
|
+
"to convert your operation into a document") : tsInvariant.invariant(!!document && !!document.kind, 35);
|
|
6653
6861
|
var fragments = [];
|
|
6654
6862
|
var queries = [];
|
|
6655
6863
|
var mutations = [];
|
|
@@ -6677,11 +6885,11 @@ function parser(document) {
|
|
|
6677
6885
|
__DEV__ ? tsInvariant.invariant(!fragments.length ||
|
|
6678
6886
|
(queries.length || mutations.length || subscriptions.length), "Passing only a fragment to 'graphql' is not yet supported. " +
|
|
6679
6887
|
"You must include a query, subscription or mutation as well") : tsInvariant.invariant(!fragments.length ||
|
|
6680
|
-
(queries.length || mutations.length || subscriptions.length),
|
|
6888
|
+
(queries.length || mutations.length || subscriptions.length), 36);
|
|
6681
6889
|
__DEV__ ? tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1, "react-apollo only supports a query, subscription, or a mutation per HOC. " +
|
|
6682
6890
|
"".concat(document, " had ").concat(queries.length, " queries, ").concat(subscriptions.length, " ") +
|
|
6683
6891
|
"subscriptions and ".concat(mutations.length, " mutations. ") +
|
|
6684
|
-
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1,
|
|
6892
|
+
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1, 37);
|
|
6685
6893
|
type = queries.length ? exports.DocumentType.Query : exports.DocumentType.Mutation;
|
|
6686
6894
|
if (!queries.length && !mutations.length)
|
|
6687
6895
|
type = exports.DocumentType.Subscription;
|
|
@@ -6692,7 +6900,7 @@ function parser(document) {
|
|
|
6692
6900
|
: subscriptions;
|
|
6693
6901
|
__DEV__ ? tsInvariant.invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. ".concat(document, " had ") +
|
|
6694
6902
|
"".concat(definitions.length, " definitions. ") +
|
|
6695
|
-
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(definitions.length === 1,
|
|
6903
|
+
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(definitions.length === 1, 38);
|
|
6696
6904
|
var definition = definitions[0];
|
|
6697
6905
|
variables = definition.variableDefinitions || [];
|
|
6698
6906
|
if (definition.name && definition.name.kind === 'Name') {
|
|
@@ -6710,7 +6918,7 @@ function verifyDocumentType(document, type) {
|
|
|
6710
6918
|
var requiredOperationName = operationName(type);
|
|
6711
6919
|
var usedOperationName = operationName(operation.type);
|
|
6712
6920
|
__DEV__ ? tsInvariant.invariant(operation.type === type, "Running a ".concat(requiredOperationName, " requires a graphql ") +
|
|
6713
|
-
"".concat(requiredOperationName, ", but a ").concat(usedOperationName, " was used instead.")) : tsInvariant.invariant(operation.type === type,
|
|
6921
|
+
"".concat(requiredOperationName, ", but a ").concat(usedOperationName, " was used instead.")) : tsInvariant.invariant(operation.type === type, 39);
|
|
6714
6922
|
}
|
|
6715
6923
|
|
|
6716
6924
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
@@ -6736,8 +6944,6 @@ var InternalState = (function () {
|
|
|
6736
6944
|
function InternalState(client, query, previous) {
|
|
6737
6945
|
this.client = client;
|
|
6738
6946
|
this.query = query;
|
|
6739
|
-
this.asyncResolveFns = new Set();
|
|
6740
|
-
this.optionsToIgnoreOnce = new (canUseWeakSet ? WeakSet : Set)();
|
|
6741
6947
|
this.ssrDisabledResult = maybeDeepFreeze({
|
|
6742
6948
|
loading: true,
|
|
6743
6949
|
data: void 0,
|
|
@@ -6761,20 +6967,30 @@ var InternalState = (function () {
|
|
|
6761
6967
|
InternalState.prototype.forceUpdate = function () {
|
|
6762
6968
|
__DEV__ && tsInvariant.invariant.warn("Calling default no-op implementation of InternalState#forceUpdate");
|
|
6763
6969
|
};
|
|
6764
|
-
InternalState.prototype.
|
|
6970
|
+
InternalState.prototype.executeQuery = function (options) {
|
|
6765
6971
|
var _this = this;
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6972
|
+
var _a;
|
|
6973
|
+
if (options.query) {
|
|
6974
|
+
Object.assign(this, { query: options.query });
|
|
6975
|
+
}
|
|
6976
|
+
this.watchQueryOptions = this.createWatchQueryOptions(this.queryHookOptions = options);
|
|
6977
|
+
var concast = this.observable.reobserveAsConcast(this.getObsQueryOptions());
|
|
6978
|
+
this.previousData = ((_a = this.result) === null || _a === void 0 ? void 0 : _a.data) || this.previousData;
|
|
6979
|
+
this.result = void 0;
|
|
6980
|
+
this.forceUpdate();
|
|
6981
|
+
return new Promise(function (resolve) {
|
|
6982
|
+
var result;
|
|
6983
|
+
concast.subscribe({
|
|
6984
|
+
next: function (value) {
|
|
6985
|
+
result = value;
|
|
6986
|
+
},
|
|
6987
|
+
error: function () {
|
|
6988
|
+
resolve(_this.toQueryResult(_this.observable.getCurrentResult()));
|
|
6989
|
+
},
|
|
6990
|
+
complete: function () {
|
|
6991
|
+
resolve(_this.toQueryResult(result));
|
|
6992
|
+
}
|
|
6993
|
+
});
|
|
6778
6994
|
});
|
|
6779
6995
|
};
|
|
6780
6996
|
InternalState.prototype.useQuery = function (options) {
|
|
@@ -6792,7 +7008,7 @@ var InternalState = (function () {
|
|
|
6792
7008
|
if (previousResult &&
|
|
6793
7009
|
previousResult.loading === result.loading &&
|
|
6794
7010
|
previousResult.networkStatus === result.networkStatus &&
|
|
6795
|
-
|
|
7011
|
+
equal.equal(previousResult.data, result.data)) {
|
|
6796
7012
|
return;
|
|
6797
7013
|
}
|
|
6798
7014
|
_this.setResult(result);
|
|
@@ -6813,7 +7029,7 @@ var InternalState = (function () {
|
|
|
6813
7029
|
var previousResult = _this.result;
|
|
6814
7030
|
if (!previousResult ||
|
|
6815
7031
|
(previousResult && previousResult.loading) ||
|
|
6816
|
-
!
|
|
7032
|
+
!equal.equal(error, previousResult.error)) {
|
|
6817
7033
|
_this.setResult({
|
|
6818
7034
|
data: (previousResult && previousResult.data),
|
|
6819
7035
|
error: error,
|
|
@@ -6830,22 +7046,15 @@ var InternalState = (function () {
|
|
|
6830
7046
|
this.client.disableNetworkFetches,
|
|
6831
7047
|
]), function () { return _this.getCurrentResult(); }, function () { return _this.getCurrentResult(); });
|
|
6832
7048
|
this.unsafeHandlePartialRefetch(result);
|
|
6833
|
-
|
|
6834
|
-
if (!queryResult.loading && this.asyncResolveFns.size) {
|
|
6835
|
-
this.asyncResolveFns.forEach(function (resolve) { return resolve(queryResult); });
|
|
6836
|
-
this.asyncResolveFns.clear();
|
|
6837
|
-
}
|
|
6838
|
-
return queryResult;
|
|
7049
|
+
return this.toQueryResult(result);
|
|
6839
7050
|
};
|
|
6840
7051
|
InternalState.prototype.useOptions = function (options) {
|
|
6841
7052
|
var _a;
|
|
6842
7053
|
var watchQueryOptions = this.createWatchQueryOptions(this.queryHookOptions = options);
|
|
6843
7054
|
var currentWatchQueryOptions = this.watchQueryOptions;
|
|
6844
|
-
if (
|
|
6845
|
-
!equality.equal(watchQueryOptions, currentWatchQueryOptions)) {
|
|
7055
|
+
if (!equal.equal(watchQueryOptions, currentWatchQueryOptions)) {
|
|
6846
7056
|
this.watchQueryOptions = watchQueryOptions;
|
|
6847
7057
|
if (currentWatchQueryOptions && this.observable) {
|
|
6848
|
-
this.optionsToIgnoreOnce.delete(currentWatchQueryOptions);
|
|
6849
7058
|
this.observable.reobserve(this.getObsQueryOptions());
|
|
6850
7059
|
this.previousData = ((_a = this.result) === null || _a === void 0 ? void 0 : _a.data) || this.previousData;
|
|
6851
7060
|
this.result = void 0;
|
|
@@ -7012,11 +7221,15 @@ var EAGER_METHODS = [
|
|
|
7012
7221
|
'subscribeToMore',
|
|
7013
7222
|
];
|
|
7014
7223
|
function useLazyQuery(query, options) {
|
|
7015
|
-
var _a
|
|
7016
|
-
var abortControllersRef = React.useRef(new Set());
|
|
7224
|
+
var _a;
|
|
7017
7225
|
var execOptionsRef = React.useRef();
|
|
7018
|
-
var
|
|
7019
|
-
var
|
|
7226
|
+
var optionsRef = React.useRef();
|
|
7227
|
+
var queryRef = React.useRef();
|
|
7228
|
+
var merged = mergeOptions(options, execOptionsRef.current || {});
|
|
7229
|
+
var document = (_a = merged === null || merged === void 0 ? void 0 : merged.query) !== null && _a !== void 0 ? _a : query;
|
|
7230
|
+
optionsRef.current = merged;
|
|
7231
|
+
queryRef.current = document;
|
|
7232
|
+
var internalState = useInternalState(useApolloClient(options && options.client), document);
|
|
7020
7233
|
var useQueryResult = internalState.useQuery(tslib.__assign(tslib.__assign({}, merged), { skip: !execOptionsRef.current }));
|
|
7021
7234
|
var initialFetchPolicy = useQueryResult.observable.options.initialFetchPolicy ||
|
|
7022
7235
|
internalState.getDefaultFetchPolicy();
|
|
@@ -7042,28 +7255,15 @@ function useLazyQuery(query, options) {
|
|
|
7042
7255
|
return eagerMethods;
|
|
7043
7256
|
}, []);
|
|
7044
7257
|
Object.assign(result, eagerMethods);
|
|
7045
|
-
React.useEffect(function () {
|
|
7046
|
-
return function () {
|
|
7047
|
-
abortControllersRef.current.forEach(function (controller) {
|
|
7048
|
-
controller.abort();
|
|
7049
|
-
});
|
|
7050
|
-
};
|
|
7051
|
-
}, []);
|
|
7052
7258
|
var execute = React.useCallback(function (executeOptions) {
|
|
7053
|
-
var controller = new AbortController();
|
|
7054
|
-
abortControllersRef.current.add(controller);
|
|
7055
7259
|
execOptionsRef.current = executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
|
|
7056
7260
|
fetchPolicy: initialFetchPolicy,
|
|
7057
7261
|
};
|
|
7262
|
+
var options = mergeOptions(optionsRef.current, tslib.__assign({ query: queryRef.current }, execOptionsRef.current));
|
|
7058
7263
|
var promise = internalState
|
|
7059
|
-
.
|
|
7060
|
-
.then(function (queryResult) {
|
|
7061
|
-
|
|
7062
|
-
return Object.assign(queryResult, eagerMethods);
|
|
7063
|
-
});
|
|
7064
|
-
promise.catch(function () {
|
|
7065
|
-
abortControllersRef.current.delete(controller);
|
|
7066
|
-
});
|
|
7264
|
+
.executeQuery(tslib.__assign(tslib.__assign({}, options), { skip: false }))
|
|
7265
|
+
.then(function (queryResult) { return Object.assign(queryResult, eagerMethods); });
|
|
7266
|
+
promise.catch(function () { });
|
|
7067
7267
|
return promise;
|
|
7068
7268
|
}, []);
|
|
7069
7269
|
return [execute, result];
|
|
@@ -7119,7 +7319,7 @@ function useMutation(mutation, options) {
|
|
|
7119
7319
|
error: error,
|
|
7120
7320
|
client: client,
|
|
7121
7321
|
};
|
|
7122
|
-
if (ref.current.isMounted && !
|
|
7322
|
+
if (ref.current.isMounted && !equal.equal(ref.current.result, result_1)) {
|
|
7123
7323
|
setResult(ref.current.result = result_1);
|
|
7124
7324
|
}
|
|
7125
7325
|
}
|
|
@@ -7137,7 +7337,7 @@ function useMutation(mutation, options) {
|
|
|
7137
7337
|
called: true,
|
|
7138
7338
|
client: client,
|
|
7139
7339
|
};
|
|
7140
|
-
if (!
|
|
7340
|
+
if (!equal.equal(ref.current.result, result_2)) {
|
|
7141
7341
|
setResult(ref.current.result = result_2);
|
|
7142
7342
|
}
|
|
7143
7343
|
}
|
|
@@ -7227,7 +7427,7 @@ function useSubscription(subscription, options) {
|
|
|
7227
7427
|
subscription !== ref.current.subscription ||
|
|
7228
7428
|
(options === null || options === void 0 ? void 0 : options.fetchPolicy) !== ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.fetchPolicy) ||
|
|
7229
7429
|
!(options === null || options === void 0 ? void 0 : options.skip) !== !((_c = ref.current.options) === null || _c === void 0 ? void 0 : _c.skip) ||
|
|
7230
|
-
!
|
|
7430
|
+
!equal.equal(options === null || options === void 0 ? void 0 : options.variables, (_d = ref.current.options) === null || _d === void 0 ? void 0 : _d.variables))) ||
|
|
7231
7431
|
canResetObservableRef.current) {
|
|
7232
7432
|
setResult({
|
|
7233
7433
|
loading: true,
|
|
@@ -7249,9 +7449,13 @@ function useSubscription(subscription, options) {
|
|
|
7249
7449
|
if (!observable) {
|
|
7250
7450
|
return;
|
|
7251
7451
|
}
|
|
7452
|
+
var subscriptionStopped = false;
|
|
7252
7453
|
var subscription = observable.subscribe({
|
|
7253
7454
|
next: function (fetchResult) {
|
|
7254
7455
|
var _a, _b;
|
|
7456
|
+
if (subscriptionStopped) {
|
|
7457
|
+
return;
|
|
7458
|
+
}
|
|
7255
7459
|
var result = {
|
|
7256
7460
|
loading: false,
|
|
7257
7461
|
data: fetchResult.data,
|
|
@@ -7274,26 +7478,33 @@ function useSubscription(subscription, options) {
|
|
|
7274
7478
|
},
|
|
7275
7479
|
error: function (error) {
|
|
7276
7480
|
var _a, _b;
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
|
|
7481
|
+
if (!subscriptionStopped) {
|
|
7482
|
+
setResult({
|
|
7483
|
+
loading: false,
|
|
7484
|
+
data: void 0,
|
|
7485
|
+
error: error,
|
|
7486
|
+
variables: options === null || options === void 0 ? void 0 : options.variables,
|
|
7487
|
+
});
|
|
7488
|
+
(_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
|
|
7489
|
+
}
|
|
7284
7490
|
},
|
|
7285
7491
|
complete: function () {
|
|
7286
7492
|
var _a, _b;
|
|
7287
|
-
if (
|
|
7288
|
-
ref.current.options.onComplete
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
ref.current.options.onSubscriptionComplete
|
|
7493
|
+
if (!subscriptionStopped) {
|
|
7494
|
+
if ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onComplete) {
|
|
7495
|
+
ref.current.options.onComplete();
|
|
7496
|
+
}
|
|
7497
|
+
else if ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onSubscriptionComplete) {
|
|
7498
|
+
ref.current.options.onSubscriptionComplete();
|
|
7499
|
+
}
|
|
7292
7500
|
}
|
|
7293
7501
|
},
|
|
7294
7502
|
});
|
|
7295
7503
|
return function () {
|
|
7296
|
-
|
|
7504
|
+
subscriptionStopped = true;
|
|
7505
|
+
setTimeout(function () {
|
|
7506
|
+
subscription.unsubscribe();
|
|
7507
|
+
});
|
|
7297
7508
|
};
|
|
7298
7509
|
}, [observable]);
|
|
7299
7510
|
return result;
|
|
@@ -7323,13 +7534,13 @@ function useFragment_experimental(options) {
|
|
|
7323
7534
|
var getSnapshot = function () {
|
|
7324
7535
|
var latestDiffToResult = diffToResult(latestDiff);
|
|
7325
7536
|
return resultRef.current &&
|
|
7326
|
-
|
|
7537
|
+
equal.equal(resultRef.current.data, latestDiffToResult.data)
|
|
7327
7538
|
? resultRef.current
|
|
7328
7539
|
: (resultRef.current = latestDiffToResult);
|
|
7329
7540
|
};
|
|
7330
7541
|
return useSyncExternalStore(function (forceUpdate) {
|
|
7331
7542
|
return cache.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: true, callback: function (diff) {
|
|
7332
|
-
if (!
|
|
7543
|
+
if (!equal.equal(diff, latestDiff)) {
|
|
7333
7544
|
resultRef.current = diffToResult((latestDiff = diff));
|
|
7334
7545
|
forceUpdate();
|
|
7335
7546
|
}
|
|
@@ -7349,7 +7560,7 @@ function diffToResult(diff) {
|
|
|
7349
7560
|
|
|
7350
7561
|
function useDeepMemo(memoFn, deps) {
|
|
7351
7562
|
var ref = React.useRef();
|
|
7352
|
-
if (!ref.current || !
|
|
7563
|
+
if (!ref.current || !equal.equal(ref.current.deps, deps)) {
|
|
7353
7564
|
ref.current = { value: memoFn(), deps: deps };
|
|
7354
7565
|
}
|
|
7355
7566
|
return ref.current.value;
|
|
@@ -7365,85 +7576,60 @@ function useStrictModeSafeCleanupEffect(cleanup) {
|
|
|
7365
7576
|
}, []);
|
|
7366
7577
|
}
|
|
7367
7578
|
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
function
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
fulfilledPromise.status = 'fulfilled';
|
|
7381
|
-
fulfilledPromise.value = value;
|
|
7579
|
+
var useKey = 'use';
|
|
7580
|
+
var realHook = React__default[useKey];
|
|
7581
|
+
var __use = realHook ||
|
|
7582
|
+
function __use(promise) {
|
|
7583
|
+
var statefulPromise = wrapPromiseWithState(promise);
|
|
7584
|
+
switch (statefulPromise.status) {
|
|
7585
|
+
case 'pending':
|
|
7586
|
+
throw statefulPromise;
|
|
7587
|
+
case 'rejected':
|
|
7588
|
+
throw statefulPromise.reason;
|
|
7589
|
+
case 'fulfilled':
|
|
7590
|
+
return statefulPromise.value;
|
|
7382
7591
|
}
|
|
7383
|
-
}
|
|
7384
|
-
if (pendingPromise.status === 'pending') {
|
|
7385
|
-
var rejectedPromise = pendingPromise;
|
|
7386
|
-
rejectedPromise.status = 'rejected';
|
|
7387
|
-
rejectedPromise.reason = reason;
|
|
7388
|
-
}
|
|
7389
|
-
});
|
|
7390
|
-
return promise;
|
|
7391
|
-
}
|
|
7392
|
-
|
|
7393
|
-
function __use(promise) {
|
|
7394
|
-
var statefulPromise = wrapPromiseWithState(promise);
|
|
7395
|
-
switch (statefulPromise.status) {
|
|
7396
|
-
case 'pending':
|
|
7397
|
-
throw statefulPromise;
|
|
7398
|
-
case 'rejected':
|
|
7399
|
-
throw statefulPromise.reason;
|
|
7400
|
-
case 'fulfilled':
|
|
7401
|
-
return statefulPromise.value;
|
|
7402
|
-
}
|
|
7403
|
-
}
|
|
7592
|
+
};
|
|
7404
7593
|
|
|
7405
7594
|
function useSuspenseCache(override) {
|
|
7406
7595
|
var context = React.useContext(getApolloContext());
|
|
7407
7596
|
var suspenseCache = override || context.suspenseCache;
|
|
7408
7597
|
__DEV__ ? tsInvariant.invariant(suspenseCache, 'Could not find a "suspenseCache" in the context or passed in as an option. ' +
|
|
7409
7598
|
'Wrap the root component in an <ApolloProvider> and provide a suspenseCache, ' +
|
|
7410
|
-
'or pass a SuspenseCache instance in via options.') : tsInvariant.invariant(suspenseCache,
|
|
7599
|
+
'or pass a SuspenseCache instance in via options.') : tsInvariant.invariant(suspenseCache, 33);
|
|
7411
7600
|
return suspenseCache;
|
|
7412
7601
|
}
|
|
7413
7602
|
|
|
7414
7603
|
function useSuspenseQuery_experimental(query, options) {
|
|
7415
7604
|
if (options === void 0) { options = Object.create(null); }
|
|
7416
|
-
var didPreviouslySuspend = React.useRef(false);
|
|
7417
7605
|
var client = useApolloClient(options.client);
|
|
7418
7606
|
var suspenseCache = useSuspenseCache(options.suspenseCache);
|
|
7419
7607
|
var watchQueryOptions = useWatchQueryOptions({ query: query, options: options });
|
|
7420
|
-
var
|
|
7421
|
-
var
|
|
7422
|
-
var
|
|
7423
|
-
var
|
|
7424
|
-
var
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
(
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
var fetchMore = React.useCallback(function (options) { return subscription.fetchMore(options); }, [subscription]);
|
|
7446
|
-
var refetch = React.useCallback(function (variables) { return subscription.refetch(variables); }, [subscription]);
|
|
7608
|
+
var variables = watchQueryOptions.variables;
|
|
7609
|
+
var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
|
|
7610
|
+
var _b = usePromiseVersion(), version = _b[0], setVersion = _b[1];
|
|
7611
|
+
var cacheKey = [client, query, canonicalStringify(variables)].concat(queryKey);
|
|
7612
|
+
var subscription = suspenseCache.getSubscription(cacheKey, function () {
|
|
7613
|
+
return client.watchQuery(watchQueryOptions);
|
|
7614
|
+
});
|
|
7615
|
+
useTrackedSubscriptions(subscription);
|
|
7616
|
+
React.useEffect(function () {
|
|
7617
|
+
return subscription.listen(function () {
|
|
7618
|
+
setVersion('main');
|
|
7619
|
+
});
|
|
7620
|
+
}, [subscription]);
|
|
7621
|
+
var promise = subscription.promises[version] || subscription.promises.main;
|
|
7622
|
+
var result = __use(promise);
|
|
7623
|
+
var fetchMore = React.useCallback(function (options) {
|
|
7624
|
+
var promise = subscription.fetchMore(options);
|
|
7625
|
+
setVersion('network');
|
|
7626
|
+
return promise;
|
|
7627
|
+
}, [subscription]);
|
|
7628
|
+
var refetch = React.useCallback(function (variables) {
|
|
7629
|
+
var promise = subscription.refetch(variables);
|
|
7630
|
+
setVersion('network');
|
|
7631
|
+
return promise;
|
|
7632
|
+
}, [subscription]);
|
|
7447
7633
|
var subscribeToMore = React.useCallback(function (options) { return subscription.observable.subscribeToMore(options); }, [subscription]);
|
|
7448
7634
|
return React.useMemo(function () {
|
|
7449
7635
|
return {
|
|
@@ -7471,7 +7657,7 @@ function validateFetchPolicy(fetchPolicy) {
|
|
|
7471
7657
|
'no-cache',
|
|
7472
7658
|
'cache-and-network',
|
|
7473
7659
|
];
|
|
7474
|
-
__DEV__ ? tsInvariant.invariant(supportedFetchPolicies.includes(fetchPolicy), "The fetch policy `".concat(fetchPolicy, "` is not supported with suspense.")) : tsInvariant.invariant(supportedFetchPolicies.includes(fetchPolicy),
|
|
7660
|
+
__DEV__ ? tsInvariant.invariant(supportedFetchPolicies.includes(fetchPolicy), "The fetch policy `".concat(fetchPolicy, "` is not supported with suspense.")) : tsInvariant.invariant(supportedFetchPolicies.includes(fetchPolicy), 34);
|
|
7475
7661
|
}
|
|
7476
7662
|
function validatePartialDataReturn(fetchPolicy, returnPartialData) {
|
|
7477
7663
|
if (fetchPolicy === 'no-cache' && returnPartialData) {
|
|
@@ -7486,73 +7672,62 @@ function toApolloError(result) {
|
|
|
7486
7672
|
function useTrackedSubscriptions(subscription) {
|
|
7487
7673
|
var trackedSubscriptions = React.useRef(new Set());
|
|
7488
7674
|
trackedSubscriptions.current.add(subscription);
|
|
7489
|
-
|
|
7675
|
+
useStrictModeSafeCleanupEffect(function () {
|
|
7490
7676
|
trackedSubscriptions.current.forEach(function (sub) { return sub.dispose(); });
|
|
7491
|
-
};
|
|
7677
|
+
});
|
|
7678
|
+
}
|
|
7679
|
+
function usePromiseVersion() {
|
|
7680
|
+
var _a = React.useState({
|
|
7681
|
+
version: 'main',
|
|
7682
|
+
}), version = _a[0].version, setState = _a[1];
|
|
7683
|
+
var setVersion = React.useCallback(function (version) { return setState({ version: version }); }, []);
|
|
7684
|
+
return [version, setVersion];
|
|
7492
7685
|
}
|
|
7493
7686
|
function useWatchQueryOptions(_a) {
|
|
7494
7687
|
var query = _a.query, options = _a.options;
|
|
7495
|
-
var watchQueryOptions = useDeepMemo(function () { return (tslib.__assign(tslib.__assign({}, options), { query: query, notifyOnNetworkStatusChange:
|
|
7688
|
+
var watchQueryOptions = useDeepMemo(function () { return (tslib.__assign(tslib.__assign({}, options), { query: query, notifyOnNetworkStatusChange: false, nextFetchPolicy: void 0 })); }, [options, query]);
|
|
7496
7689
|
if (__DEV__) {
|
|
7497
7690
|
validateOptions(watchQueryOptions);
|
|
7498
7691
|
}
|
|
7499
7692
|
return watchQueryOptions;
|
|
7500
7693
|
}
|
|
7501
|
-
function shouldUseCachedResult(result, _a) {
|
|
7502
|
-
var returnPartialData = _a.returnPartialData, fetchPolicy = _a.fetchPolicy;
|
|
7503
|
-
if (result.networkStatus === exports.NetworkStatus.refetch ||
|
|
7504
|
-
result.networkStatus === exports.NetworkStatus.fetchMore ||
|
|
7505
|
-
result.networkStatus === exports.NetworkStatus.error) {
|
|
7506
|
-
return false;
|
|
7507
|
-
}
|
|
7508
|
-
switch (fetchPolicy) {
|
|
7509
|
-
case void 0:
|
|
7510
|
-
case 'cache-first':
|
|
7511
|
-
case 'cache-and-network': {
|
|
7512
|
-
return Boolean(result.data && (!result.partial || returnPartialData));
|
|
7513
|
-
}
|
|
7514
|
-
default:
|
|
7515
|
-
return false;
|
|
7516
|
-
}
|
|
7517
|
-
}
|
|
7518
7694
|
|
|
7519
|
-
function wrapWithCustomPromise(concast) {
|
|
7520
|
-
return new Promise(function (resolve, reject) {
|
|
7521
|
-
var subscription = concast.subscribe({
|
|
7522
|
-
next: function (value) {
|
|
7523
|
-
resolve(value);
|
|
7524
|
-
subscription.unsubscribe();
|
|
7525
|
-
},
|
|
7526
|
-
error: reject,
|
|
7527
|
-
});
|
|
7528
|
-
});
|
|
7529
|
-
}
|
|
7530
|
-
var isMultipartQuery = optimism.wrap(function (query) {
|
|
7531
|
-
return hasAnyDirectives(['defer', 'stream'], query);
|
|
7532
|
-
});
|
|
7533
7695
|
var QuerySubscription = (function () {
|
|
7534
7696
|
function QuerySubscription(observable, options) {
|
|
7535
7697
|
if (options === void 0) { options = Object.create(null); }
|
|
7698
|
+
var _this = this;
|
|
7536
7699
|
var _a;
|
|
7537
7700
|
this.listeners = new Set();
|
|
7701
|
+
this.initialized = false;
|
|
7702
|
+
this.refetching = false;
|
|
7538
7703
|
this.listen = this.listen.bind(this);
|
|
7539
7704
|
this.handleNext = this.handleNext.bind(this);
|
|
7540
7705
|
this.handleError = this.handleError.bind(this);
|
|
7541
7706
|
this.dispose = this.dispose.bind(this);
|
|
7542
7707
|
this.observable = observable;
|
|
7543
|
-
this.result = observable.getCurrentResult();
|
|
7708
|
+
this.result = observable.getCurrentResult(false);
|
|
7544
7709
|
if (options.onDispose) {
|
|
7545
7710
|
this.onDispose = options.onDispose;
|
|
7546
7711
|
}
|
|
7712
|
+
if (isNetworkRequestSettled(this.result.networkStatus) ||
|
|
7713
|
+
(this.result.data &&
|
|
7714
|
+
(!this.result.partial || this.observable.options.returnPartialData))) {
|
|
7715
|
+
this.promises = { main: createFulfilledPromise(this.result) };
|
|
7716
|
+
this.initialized = true;
|
|
7717
|
+
this.refetching = false;
|
|
7718
|
+
}
|
|
7547
7719
|
this.subscription = observable.subscribe({
|
|
7548
7720
|
next: this.handleNext,
|
|
7549
7721
|
error: this.handleError,
|
|
7550
7722
|
});
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7723
|
+
if (!this.promises) {
|
|
7724
|
+
this.promises = {
|
|
7725
|
+
main: new Promise(function (resolve, reject) {
|
|
7726
|
+
_this.resolve = resolve;
|
|
7727
|
+
_this.reject = reject;
|
|
7728
|
+
}),
|
|
7729
|
+
};
|
|
7730
|
+
}
|
|
7556
7731
|
this.autoDisposeTimeoutId = setTimeout(this.dispose, (_a = options.autoDisposeTimeoutMs) !== null && _a !== void 0 ? _a : 30000);
|
|
7557
7732
|
}
|
|
7558
7733
|
QuerySubscription.prototype.listen = function (listener) {
|
|
@@ -7564,12 +7739,15 @@ var QuerySubscription = (function () {
|
|
|
7564
7739
|
};
|
|
7565
7740
|
};
|
|
7566
7741
|
QuerySubscription.prototype.refetch = function (variables) {
|
|
7567
|
-
this.
|
|
7568
|
-
|
|
7742
|
+
this.refetching = true;
|
|
7743
|
+
var promise = this.observable.refetch(variables);
|
|
7744
|
+
this.promises.network = promise;
|
|
7745
|
+
return promise;
|
|
7569
7746
|
};
|
|
7570
7747
|
QuerySubscription.prototype.fetchMore = function (options) {
|
|
7571
|
-
|
|
7572
|
-
|
|
7748
|
+
var promise = this.observable.fetchMore(options);
|
|
7749
|
+
this.promises.network = promise;
|
|
7750
|
+
return promise;
|
|
7573
7751
|
};
|
|
7574
7752
|
QuerySubscription.prototype.dispose = function () {
|
|
7575
7753
|
this.subscription.unsubscribe();
|
|
@@ -7578,21 +7756,39 @@ var QuerySubscription = (function () {
|
|
|
7578
7756
|
QuerySubscription.prototype.onDispose = function () {
|
|
7579
7757
|
};
|
|
7580
7758
|
QuerySubscription.prototype.handleNext = function (result) {
|
|
7581
|
-
if (
|
|
7582
|
-
this.
|
|
7583
|
-
result
|
|
7759
|
+
if (!this.initialized) {
|
|
7760
|
+
this.initialized = true;
|
|
7761
|
+
this.result = result;
|
|
7762
|
+
this.resolve(result);
|
|
7763
|
+
return;
|
|
7764
|
+
}
|
|
7765
|
+
if (result.data === this.result.data) {
|
|
7766
|
+
return;
|
|
7767
|
+
}
|
|
7768
|
+
if (this.result.data && result.data === void 0) {
|
|
7584
7769
|
result.data = this.result.data;
|
|
7585
7770
|
}
|
|
7586
7771
|
this.result = result;
|
|
7587
|
-
this.
|
|
7772
|
+
this.promises.main = createFulfilledPromise(result);
|
|
7773
|
+
this.deliver();
|
|
7588
7774
|
};
|
|
7589
7775
|
QuerySubscription.prototype.handleError = function (error) {
|
|
7590
7776
|
var result = tslib.__assign(tslib.__assign({}, this.result), { error: error, networkStatus: exports.NetworkStatus.error });
|
|
7591
7777
|
this.result = result;
|
|
7592
|
-
this.
|
|
7778
|
+
if (!this.initialized || this.refetching) {
|
|
7779
|
+
this.initialized = true;
|
|
7780
|
+
this.refetching = false;
|
|
7781
|
+
this.reject(error);
|
|
7782
|
+
return;
|
|
7783
|
+
}
|
|
7784
|
+
this.result = result;
|
|
7785
|
+
this.promises.main = result.data
|
|
7786
|
+
? createFulfilledPromise(result)
|
|
7787
|
+
: createRejectedPromise(result);
|
|
7788
|
+
this.deliver();
|
|
7593
7789
|
};
|
|
7594
|
-
QuerySubscription.prototype.deliver = function (
|
|
7595
|
-
this.listeners.forEach(function (listener) { return listener(
|
|
7790
|
+
QuerySubscription.prototype.deliver = function () {
|
|
7791
|
+
this.listeners.forEach(function (listener) { return listener(); });
|
|
7596
7792
|
};
|
|
7597
7793
|
return QuerySubscription;
|
|
7598
7794
|
}());
|
|
@@ -7604,16 +7800,16 @@ var SuspenseCache = (function () {
|
|
|
7604
7800
|
this.subscriptions = new Map();
|
|
7605
7801
|
this.options = options;
|
|
7606
7802
|
}
|
|
7607
|
-
SuspenseCache.prototype.getSubscription = function (
|
|
7803
|
+
SuspenseCache.prototype.getSubscription = function (cacheKey, createObservable) {
|
|
7608
7804
|
var _this = this;
|
|
7609
|
-
var
|
|
7610
|
-
if (!this.subscriptions.has(
|
|
7611
|
-
this.subscriptions.set(
|
|
7805
|
+
var stableCacheKey = this.cacheKeys.lookupArray(cacheKey);
|
|
7806
|
+
if (!this.subscriptions.has(stableCacheKey)) {
|
|
7807
|
+
this.subscriptions.set(stableCacheKey, new QuerySubscription(createObservable(), {
|
|
7612
7808
|
autoDisposeTimeoutMs: this.options.autoDisposeTimeoutMs,
|
|
7613
|
-
onDispose: function () { return _this.subscriptions.delete(
|
|
7809
|
+
onDispose: function () { return _this.subscriptions.delete(stableCacheKey); },
|
|
7614
7810
|
}));
|
|
7615
7811
|
}
|
|
7616
|
-
return this.subscriptions.get(
|
|
7812
|
+
return this.subscriptions.get(stableCacheKey);
|
|
7617
7813
|
};
|
|
7618
7814
|
return SuspenseCache;
|
|
7619
7815
|
}());
|
|
@@ -7650,6 +7846,7 @@ exports.fromError = fromError;
|
|
|
7650
7846
|
exports.fromPromise = fromPromise;
|
|
7651
7847
|
exports.getApolloContext = getApolloContext;
|
|
7652
7848
|
exports.isApolloError = isApolloError;
|
|
7849
|
+
exports.isNetworkRequestSettled = isNetworkRequestSettled;
|
|
7653
7850
|
exports.isReference = isReference;
|
|
7654
7851
|
exports.makeReference = makeReference;
|
|
7655
7852
|
exports.makeVar = makeVar;
|