@apollo/client 3.8.0-alpha.12 → 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 +145 -119
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js.map +1 -1
- package/core/core.cjs +1 -1
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +1 -1
- package/invariantErrorCodes.js +29 -34
- package/link/http/parseAndCheckHttpResponse.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/utils/throwServerError.d.ts +1 -1
- package/link/utils/throwServerError.d.ts.map +1 -1
- package/link/utils/throwServerError.js.map +1 -1
- package/package.json +18 -17
- package/react/cache/QuerySubscription.d.ts +11 -4
- package/react/cache/QuerySubscription.d.ts.map +1 -1
- package/react/cache/QuerySubscription.js +52 -34
- package/react/cache/QuerySubscription.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 +58 -63
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +58 -63
- 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/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 +34 -52
- package/react/hooks/useSuspenseQuery.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 +52 -33
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +52 -33
- package/react/types/types.d.ts +1 -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/utilities/graphql/directives.js +4 -4
- package/utilities/graphql/fragments.js +3 -3
- package/utilities/graphql/getFromAST.js +8 -8
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/index.d.ts +2 -1
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +1 -1
- 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 +4 -3
- package/utilities/types/DeepOmit.d.ts.map +1 -1
- package/utilities/types/DeepOmit.js.map +1 -1
- 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 +30 -16
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +30 -16
- package/version.js +1 -1
package/apollo-client.cjs
CHANGED
|
@@ -67,7 +67,7 @@ function shouldInclude(_a, variables) {
|
|
|
67
67
|
var evaledValue = false;
|
|
68
68
|
if (ifArgument.value.kind === 'Variable') {
|
|
69
69
|
evaledValue = variables && variables[ifArgument.value.name.value];
|
|
70
|
-
__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);
|
|
71
71
|
}
|
|
72
72
|
else {
|
|
73
73
|
evaledValue = ifArgument.value.value;
|
|
@@ -75,7 +75,6 @@ function shouldInclude(_a, variables) {
|
|
|
75
75
|
return directive.name.value === 'skip' ? !evaledValue : evaledValue;
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
var hasAnyDirectives = function (names, root) { return hasDirectives(names, root, false); };
|
|
79
78
|
function hasDirectives(names, root, all) {
|
|
80
79
|
var nameSet = new Set(names);
|
|
81
80
|
var uniqueCount = nameSet.size;
|
|
@@ -104,13 +103,13 @@ function getInclusionDirectives(directives) {
|
|
|
104
103
|
return;
|
|
105
104
|
var directiveArguments = directive.arguments;
|
|
106
105
|
var directiveName = directive.name.value;
|
|
107
|
-
__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);
|
|
108
107
|
var ifArgument = directiveArguments[0];
|
|
109
|
-
__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);
|
|
110
109
|
var ifValue = ifArgument.value;
|
|
111
110
|
__DEV__ ? tsInvariant.invariant(ifValue &&
|
|
112
111
|
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @".concat(directiveName, " directive must be a variable or a boolean value.")) : tsInvariant.invariant(ifValue &&
|
|
113
|
-
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'),
|
|
112
|
+
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 44);
|
|
114
113
|
result.push({ directive: directive, ifArgument: ifArgument });
|
|
115
114
|
});
|
|
116
115
|
}
|
|
@@ -123,14 +122,14 @@ function getFragmentQueryDocument(document, fragmentName) {
|
|
|
123
122
|
document.definitions.forEach(function (definition) {
|
|
124
123
|
if (definition.kind === 'OperationDefinition') {
|
|
125
124
|
throw __DEV__ ? new tsInvariant.InvariantError("Found a ".concat(definition.operation, " operation").concat(definition.name ? " named '".concat(definition.name.value, "'") : '', ". ") +
|
|
126
|
-
'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);
|
|
127
126
|
}
|
|
128
127
|
if (definition.kind === 'FragmentDefinition') {
|
|
129
128
|
fragments.push(definition);
|
|
130
129
|
}
|
|
131
130
|
});
|
|
132
131
|
if (typeof actualFragmentName === 'undefined') {
|
|
133
|
-
__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);
|
|
134
133
|
actualFragmentName = fragments[0].name.value;
|
|
135
134
|
}
|
|
136
135
|
var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
|
|
@@ -171,7 +170,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
171
170
|
return fragmentMap(fragmentName);
|
|
172
171
|
}
|
|
173
172
|
var fragment = fragmentMap && fragmentMap[fragmentName];
|
|
174
|
-
__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);
|
|
175
174
|
return fragment || null;
|
|
176
175
|
}
|
|
177
176
|
default:
|
|
@@ -261,7 +260,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
|
|
|
261
260
|
else {
|
|
262
261
|
throw __DEV__ ? new tsInvariant.InvariantError("The inline argument \"".concat(name.value, "\" of kind \"").concat(value.kind, "\"") +
|
|
263
262
|
'is not supported. Use variables instead of inline arguments to ' +
|
|
264
|
-
'overcome this limitation.') : new tsInvariant.InvariantError(
|
|
263
|
+
'overcome this limitation.') : new tsInvariant.InvariantError(56);
|
|
265
264
|
}
|
|
266
265
|
}
|
|
267
266
|
function storeKeyNameFromField(field, variables) {
|
|
@@ -396,16 +395,16 @@ function isInlineFragment(selection) {
|
|
|
396
395
|
}
|
|
397
396
|
|
|
398
397
|
function checkDocument(doc) {
|
|
399
|
-
__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);
|
|
400
399
|
var operations = doc.definitions
|
|
401
400
|
.filter(function (d) { return d.kind !== 'FragmentDefinition'; })
|
|
402
401
|
.map(function (definition) {
|
|
403
402
|
if (definition.kind !== 'OperationDefinition') {
|
|
404
|
-
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);
|
|
405
404
|
}
|
|
406
405
|
return definition;
|
|
407
406
|
});
|
|
408
|
-
__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);
|
|
409
408
|
return doc;
|
|
410
409
|
}
|
|
411
410
|
function getOperationDefinition(doc) {
|
|
@@ -428,14 +427,14 @@ function getFragmentDefinitions(doc) {
|
|
|
428
427
|
}
|
|
429
428
|
function getQueryDefinition(doc) {
|
|
430
429
|
var queryDef = getOperationDefinition(doc);
|
|
431
|
-
__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);
|
|
432
431
|
return queryDef;
|
|
433
432
|
}
|
|
434
433
|
function getFragmentDefinition(doc) {
|
|
435
|
-
__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',
|
|
436
|
-
__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);
|
|
437
436
|
var fragmentDef = doc.definitions[0];
|
|
438
|
-
__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);
|
|
439
438
|
return fragmentDef;
|
|
440
439
|
}
|
|
441
440
|
function getMainDefinition(queryDoc) {
|
|
@@ -458,7 +457,7 @@ function getMainDefinition(queryDoc) {
|
|
|
458
457
|
if (fragmentDefinition) {
|
|
459
458
|
return fragmentDefinition;
|
|
460
459
|
}
|
|
461
|
-
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);
|
|
462
461
|
}
|
|
463
462
|
function getDefaultValues(definition) {
|
|
464
463
|
var defaultValues = Object.create(null);
|
|
@@ -817,6 +816,18 @@ var DeepMerger = (function () {
|
|
|
817
816
|
return DeepMerger;
|
|
818
817
|
}());
|
|
819
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
|
+
}
|
|
820
831
|
function isStatefulPromise(promise) {
|
|
821
832
|
return 'status' in promise;
|
|
822
833
|
}
|
|
@@ -1490,7 +1501,7 @@ var concat = ApolloLink.concat;
|
|
|
1490
1501
|
|
|
1491
1502
|
var execute = ApolloLink.execute;
|
|
1492
1503
|
|
|
1493
|
-
var version = '3.8.0-alpha.
|
|
1504
|
+
var version = '3.8.0-alpha.13';
|
|
1494
1505
|
|
|
1495
1506
|
function asyncIterator(source) {
|
|
1496
1507
|
var _a;
|
|
@@ -6741,7 +6752,7 @@ var ApolloConsumer = function (props) {
|
|
|
6741
6752
|
var ApolloContext = getApolloContext();
|
|
6742
6753
|
return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
|
|
6743
6754
|
__DEV__ ? tsInvariant.invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
|
|
6744
|
-
'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);
|
|
6745
6756
|
return props.children(context.client);
|
|
6746
6757
|
}));
|
|
6747
6758
|
};
|
|
@@ -6758,7 +6769,7 @@ var ApolloProvider = function (_a) {
|
|
|
6758
6769
|
context = Object.assign({}, context, { suspenseCache: suspenseCache });
|
|
6759
6770
|
}
|
|
6760
6771
|
__DEV__ ? tsInvariant.invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
|
|
6761
|
-
'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);
|
|
6762
6773
|
return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
|
|
6763
6774
|
}));
|
|
6764
6775
|
};
|
|
@@ -6768,7 +6779,7 @@ function useApolloClient(override) {
|
|
|
6768
6779
|
var client = override || context.client;
|
|
6769
6780
|
__DEV__ ? tsInvariant.invariant(!!client, 'Could not find "client" in the context or passed in as an option. ' +
|
|
6770
6781
|
'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient ' +
|
|
6771
|
-
'instance in via options.') : tsInvariant.invariant(!!client,
|
|
6782
|
+
'instance in via options.') : tsInvariant.invariant(!!client, 32);
|
|
6772
6783
|
return client;
|
|
6773
6784
|
}
|
|
6774
6785
|
|
|
@@ -6846,7 +6857,7 @@ function parser(document) {
|
|
|
6846
6857
|
var variables, type, name;
|
|
6847
6858
|
__DEV__ ? tsInvariant.invariant(!!document && !!document.kind, "Argument of ".concat(document, " passed to parser was not a valid GraphQL ") +
|
|
6848
6859
|
"DocumentNode. You may need to use 'graphql-tag' or another method " +
|
|
6849
|
-
"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);
|
|
6850
6861
|
var fragments = [];
|
|
6851
6862
|
var queries = [];
|
|
6852
6863
|
var mutations = [];
|
|
@@ -6874,11 +6885,11 @@ function parser(document) {
|
|
|
6874
6885
|
__DEV__ ? tsInvariant.invariant(!fragments.length ||
|
|
6875
6886
|
(queries.length || mutations.length || subscriptions.length), "Passing only a fragment to 'graphql' is not yet supported. " +
|
|
6876
6887
|
"You must include a query, subscription or mutation as well") : tsInvariant.invariant(!fragments.length ||
|
|
6877
|
-
(queries.length || mutations.length || subscriptions.length),
|
|
6888
|
+
(queries.length || mutations.length || subscriptions.length), 36);
|
|
6878
6889
|
__DEV__ ? tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1, "react-apollo only supports a query, subscription, or a mutation per HOC. " +
|
|
6879
6890
|
"".concat(document, " had ").concat(queries.length, " queries, ").concat(subscriptions.length, " ") +
|
|
6880
6891
|
"subscriptions and ".concat(mutations.length, " mutations. ") +
|
|
6881
|
-
"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);
|
|
6882
6893
|
type = queries.length ? exports.DocumentType.Query : exports.DocumentType.Mutation;
|
|
6883
6894
|
if (!queries.length && !mutations.length)
|
|
6884
6895
|
type = exports.DocumentType.Subscription;
|
|
@@ -6889,7 +6900,7 @@ function parser(document) {
|
|
|
6889
6900
|
: subscriptions;
|
|
6890
6901
|
__DEV__ ? tsInvariant.invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. ".concat(document, " had ") +
|
|
6891
6902
|
"".concat(definitions.length, " definitions. ") +
|
|
6892
|
-
"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);
|
|
6893
6904
|
var definition = definitions[0];
|
|
6894
6905
|
variables = definition.variableDefinitions || [];
|
|
6895
6906
|
if (definition.name && definition.name.kind === 'Name') {
|
|
@@ -6907,7 +6918,7 @@ function verifyDocumentType(document, type) {
|
|
|
6907
6918
|
var requiredOperationName = operationName(type);
|
|
6908
6919
|
var usedOperationName = operationName(operation.type);
|
|
6909
6920
|
__DEV__ ? tsInvariant.invariant(operation.type === type, "Running a ".concat(requiredOperationName, " requires a graphql ") +
|
|
6910
|
-
"".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);
|
|
6911
6922
|
}
|
|
6912
6923
|
|
|
6913
6924
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
@@ -7438,9 +7449,13 @@ function useSubscription(subscription, options) {
|
|
|
7438
7449
|
if (!observable) {
|
|
7439
7450
|
return;
|
|
7440
7451
|
}
|
|
7452
|
+
var subscriptionStopped = false;
|
|
7441
7453
|
var subscription = observable.subscribe({
|
|
7442
7454
|
next: function (fetchResult) {
|
|
7443
7455
|
var _a, _b;
|
|
7456
|
+
if (subscriptionStopped) {
|
|
7457
|
+
return;
|
|
7458
|
+
}
|
|
7444
7459
|
var result = {
|
|
7445
7460
|
loading: false,
|
|
7446
7461
|
data: fetchResult.data,
|
|
@@ -7463,26 +7478,33 @@ function useSubscription(subscription, options) {
|
|
|
7463
7478
|
},
|
|
7464
7479
|
error: function (error) {
|
|
7465
7480
|
var _a, _b;
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
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
|
+
}
|
|
7473
7490
|
},
|
|
7474
7491
|
complete: function () {
|
|
7475
7492
|
var _a, _b;
|
|
7476
|
-
if (
|
|
7477
|
-
ref.current.options.onComplete
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
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
|
+
}
|
|
7481
7500
|
}
|
|
7482
7501
|
},
|
|
7483
7502
|
});
|
|
7484
7503
|
return function () {
|
|
7485
|
-
|
|
7504
|
+
subscriptionStopped = true;
|
|
7505
|
+
setTimeout(function () {
|
|
7506
|
+
subscription.unsubscribe();
|
|
7507
|
+
});
|
|
7486
7508
|
};
|
|
7487
7509
|
}, [observable]);
|
|
7488
7510
|
return result;
|
|
@@ -7574,46 +7596,40 @@ function useSuspenseCache(override) {
|
|
|
7574
7596
|
var suspenseCache = override || context.suspenseCache;
|
|
7575
7597
|
__DEV__ ? tsInvariant.invariant(suspenseCache, 'Could not find a "suspenseCache" in the context or passed in as an option. ' +
|
|
7576
7598
|
'Wrap the root component in an <ApolloProvider> and provide a suspenseCache, ' +
|
|
7577
|
-
'or pass a SuspenseCache instance in via options.') : tsInvariant.invariant(suspenseCache,
|
|
7599
|
+
'or pass a SuspenseCache instance in via options.') : tsInvariant.invariant(suspenseCache, 33);
|
|
7578
7600
|
return suspenseCache;
|
|
7579
7601
|
}
|
|
7580
7602
|
|
|
7581
7603
|
function useSuspenseQuery_experimental(query, options) {
|
|
7582
7604
|
if (options === void 0) { options = Object.create(null); }
|
|
7583
|
-
var didPreviouslySuspend = React.useRef(false);
|
|
7584
7605
|
var client = useApolloClient(options.client);
|
|
7585
7606
|
var suspenseCache = useSuspenseCache(options.suspenseCache);
|
|
7586
7607
|
var watchQueryOptions = useWatchQueryOptions({ query: query, options: options });
|
|
7587
|
-
var
|
|
7588
|
-
var
|
|
7589
|
-
var
|
|
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];
|
|
7590
7611
|
var cacheKey = [client, query, canonicalStringify(variables)].concat(queryKey);
|
|
7591
7612
|
var subscription = suspenseCache.getSubscription(cacheKey, function () {
|
|
7592
7613
|
return client.watchQuery(watchQueryOptions);
|
|
7593
7614
|
});
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
__use(subscription.promise);
|
|
7613
|
-
}
|
|
7614
|
-
didPreviouslySuspend.current = true;
|
|
7615
|
-
var fetchMore = React.useCallback(function (options) { return subscription.fetchMore(options); }, [subscription]);
|
|
7616
|
-
var refetch = React.useCallback(function (variables) { return subscription.refetch(variables); }, [subscription]);
|
|
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]);
|
|
7617
7633
|
var subscribeToMore = React.useCallback(function (options) { return subscription.observable.subscribeToMore(options); }, [subscription]);
|
|
7618
7634
|
return React.useMemo(function () {
|
|
7619
7635
|
return {
|
|
@@ -7641,7 +7657,7 @@ function validateFetchPolicy(fetchPolicy) {
|
|
|
7641
7657
|
'no-cache',
|
|
7642
7658
|
'cache-and-network',
|
|
7643
7659
|
];
|
|
7644
|
-
__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);
|
|
7645
7661
|
}
|
|
7646
7662
|
function validatePartialDataReturn(fetchPolicy, returnPartialData) {
|
|
7647
7663
|
if (fetchPolicy === 'no-cache' && returnPartialData) {
|
|
@@ -7656,73 +7672,62 @@ function toApolloError(result) {
|
|
|
7656
7672
|
function useTrackedSubscriptions(subscription) {
|
|
7657
7673
|
var trackedSubscriptions = React.useRef(new Set());
|
|
7658
7674
|
trackedSubscriptions.current.add(subscription);
|
|
7659
|
-
|
|
7675
|
+
useStrictModeSafeCleanupEffect(function () {
|
|
7660
7676
|
trackedSubscriptions.current.forEach(function (sub) { return sub.dispose(); });
|
|
7661
|
-
};
|
|
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];
|
|
7662
7685
|
}
|
|
7663
7686
|
function useWatchQueryOptions(_a) {
|
|
7664
7687
|
var query = _a.query, options = _a.options;
|
|
7665
|
-
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]);
|
|
7666
7689
|
if (__DEV__) {
|
|
7667
7690
|
validateOptions(watchQueryOptions);
|
|
7668
7691
|
}
|
|
7669
7692
|
return watchQueryOptions;
|
|
7670
7693
|
}
|
|
7671
|
-
function shouldUseCachedResult(result, _a) {
|
|
7672
|
-
var returnPartialData = _a.returnPartialData, fetchPolicy = _a.fetchPolicy;
|
|
7673
|
-
if (result.networkStatus === exports.NetworkStatus.refetch ||
|
|
7674
|
-
result.networkStatus === exports.NetworkStatus.fetchMore ||
|
|
7675
|
-
result.networkStatus === exports.NetworkStatus.error) {
|
|
7676
|
-
return false;
|
|
7677
|
-
}
|
|
7678
|
-
switch (fetchPolicy) {
|
|
7679
|
-
case void 0:
|
|
7680
|
-
case 'cache-first':
|
|
7681
|
-
case 'cache-and-network': {
|
|
7682
|
-
return Boolean(result.data && (!result.partial || returnPartialData));
|
|
7683
|
-
}
|
|
7684
|
-
default:
|
|
7685
|
-
return false;
|
|
7686
|
-
}
|
|
7687
|
-
}
|
|
7688
7694
|
|
|
7689
|
-
function wrapWithCustomPromise(concast) {
|
|
7690
|
-
return new Promise(function (resolve, reject) {
|
|
7691
|
-
var subscription = concast.subscribe({
|
|
7692
|
-
next: function (value) {
|
|
7693
|
-
resolve(value);
|
|
7694
|
-
subscription.unsubscribe();
|
|
7695
|
-
},
|
|
7696
|
-
error: reject,
|
|
7697
|
-
});
|
|
7698
|
-
});
|
|
7699
|
-
}
|
|
7700
|
-
var isMultipartQuery = optimism.wrap(function (query) {
|
|
7701
|
-
return hasAnyDirectives(['defer', 'stream'], query);
|
|
7702
|
-
});
|
|
7703
7695
|
var QuerySubscription = (function () {
|
|
7704
7696
|
function QuerySubscription(observable, options) {
|
|
7705
7697
|
if (options === void 0) { options = Object.create(null); }
|
|
7698
|
+
var _this = this;
|
|
7706
7699
|
var _a;
|
|
7707
7700
|
this.listeners = new Set();
|
|
7701
|
+
this.initialized = false;
|
|
7702
|
+
this.refetching = false;
|
|
7708
7703
|
this.listen = this.listen.bind(this);
|
|
7709
7704
|
this.handleNext = this.handleNext.bind(this);
|
|
7710
7705
|
this.handleError = this.handleError.bind(this);
|
|
7711
7706
|
this.dispose = this.dispose.bind(this);
|
|
7712
7707
|
this.observable = observable;
|
|
7713
|
-
this.result = observable.getCurrentResult();
|
|
7708
|
+
this.result = observable.getCurrentResult(false);
|
|
7714
7709
|
if (options.onDispose) {
|
|
7715
7710
|
this.onDispose = options.onDispose;
|
|
7716
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
|
+
}
|
|
7717
7719
|
this.subscription = observable.subscribe({
|
|
7718
7720
|
next: this.handleNext,
|
|
7719
7721
|
error: this.handleError,
|
|
7720
7722
|
});
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
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
|
+
}
|
|
7726
7731
|
this.autoDisposeTimeoutId = setTimeout(this.dispose, (_a = options.autoDisposeTimeoutMs) !== null && _a !== void 0 ? _a : 30000);
|
|
7727
7732
|
}
|
|
7728
7733
|
QuerySubscription.prototype.listen = function (listener) {
|
|
@@ -7734,12 +7739,15 @@ var QuerySubscription = (function () {
|
|
|
7734
7739
|
};
|
|
7735
7740
|
};
|
|
7736
7741
|
QuerySubscription.prototype.refetch = function (variables) {
|
|
7737
|
-
this.
|
|
7738
|
-
|
|
7742
|
+
this.refetching = true;
|
|
7743
|
+
var promise = this.observable.refetch(variables);
|
|
7744
|
+
this.promises.network = promise;
|
|
7745
|
+
return promise;
|
|
7739
7746
|
};
|
|
7740
7747
|
QuerySubscription.prototype.fetchMore = function (options) {
|
|
7741
|
-
|
|
7742
|
-
|
|
7748
|
+
var promise = this.observable.fetchMore(options);
|
|
7749
|
+
this.promises.network = promise;
|
|
7750
|
+
return promise;
|
|
7743
7751
|
};
|
|
7744
7752
|
QuerySubscription.prototype.dispose = function () {
|
|
7745
7753
|
this.subscription.unsubscribe();
|
|
@@ -7748,21 +7756,39 @@ var QuerySubscription = (function () {
|
|
|
7748
7756
|
QuerySubscription.prototype.onDispose = function () {
|
|
7749
7757
|
};
|
|
7750
7758
|
QuerySubscription.prototype.handleNext = function (result) {
|
|
7751
|
-
if (
|
|
7752
|
-
this.
|
|
7753
|
-
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) {
|
|
7754
7769
|
result.data = this.result.data;
|
|
7755
7770
|
}
|
|
7756
7771
|
this.result = result;
|
|
7757
|
-
this.
|
|
7772
|
+
this.promises.main = createFulfilledPromise(result);
|
|
7773
|
+
this.deliver();
|
|
7758
7774
|
};
|
|
7759
7775
|
QuerySubscription.prototype.handleError = function (error) {
|
|
7760
7776
|
var result = tslib.__assign(tslib.__assign({}, this.result), { error: error, networkStatus: exports.NetworkStatus.error });
|
|
7761
7777
|
this.result = result;
|
|
7762
|
-
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();
|
|
7763
7789
|
};
|
|
7764
|
-
QuerySubscription.prototype.deliver = function (
|
|
7765
|
-
this.listeners.forEach(function (listener) { return listener(
|
|
7790
|
+
QuerySubscription.prototype.deliver = function () {
|
|
7791
|
+
this.listeners.forEach(function (listener) { return listener(); });
|
|
7766
7792
|
};
|
|
7767
7793
|
return QuerySubscription;
|
|
7768
7794
|
}());
|