@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/utilities/utilities.cjs
CHANGED
|
@@ -18,7 +18,7 @@ function shouldInclude(_a, variables) {
|
|
|
18
18
|
var evaledValue = false;
|
|
19
19
|
if (ifArgument.value.kind === 'Variable') {
|
|
20
20
|
evaledValue = variables && variables[ifArgument.value.name.value];
|
|
21
|
-
globals.__DEV__ ? globals.invariant(evaledValue !== void 0, "Invalid variable referenced in @".concat(directive.name.value, " directive.")) : globals.invariant(evaledValue !== void 0,
|
|
21
|
+
globals.__DEV__ ? globals.invariant(evaledValue !== void 0, "Invalid variable referenced in @".concat(directive.name.value, " directive.")) : globals.invariant(evaledValue !== void 0, 41);
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
24
|
evaledValue = ifArgument.value.value;
|
|
@@ -65,13 +65,13 @@ function getInclusionDirectives(directives) {
|
|
|
65
65
|
return;
|
|
66
66
|
var directiveArguments = directive.arguments;
|
|
67
67
|
var directiveName = directive.name.value;
|
|
68
|
-
globals.__DEV__ ? globals.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @".concat(directiveName, " directive.")) : globals.invariant(directiveArguments && directiveArguments.length === 1,
|
|
68
|
+
globals.__DEV__ ? globals.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @".concat(directiveName, " directive.")) : globals.invariant(directiveArguments && directiveArguments.length === 1, 42);
|
|
69
69
|
var ifArgument = directiveArguments[0];
|
|
70
|
-
globals.__DEV__ ? globals.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @".concat(directiveName, " directive.")) : globals.invariant(ifArgument.name && ifArgument.name.value === 'if',
|
|
70
|
+
globals.__DEV__ ? globals.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @".concat(directiveName, " directive.")) : globals.invariant(ifArgument.name && ifArgument.name.value === 'if', 43);
|
|
71
71
|
var ifValue = ifArgument.value;
|
|
72
72
|
globals.__DEV__ ? globals.invariant(ifValue &&
|
|
73
73
|
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @".concat(directiveName, " directive must be a variable or a boolean value.")) : globals.invariant(ifValue &&
|
|
74
|
-
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'),
|
|
74
|
+
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 44);
|
|
75
75
|
result.push({ directive: directive, ifArgument: ifArgument });
|
|
76
76
|
});
|
|
77
77
|
}
|
|
@@ -84,14 +84,14 @@ function getFragmentQueryDocument(document, fragmentName) {
|
|
|
84
84
|
document.definitions.forEach(function (definition) {
|
|
85
85
|
if (definition.kind === 'OperationDefinition') {
|
|
86
86
|
throw globals.__DEV__ ? new globals.InvariantError("Found a ".concat(definition.operation, " operation").concat(definition.name ? " named '".concat(definition.name.value, "'") : '', ". ") +
|
|
87
|
-
'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new globals.InvariantError(
|
|
87
|
+
'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new globals.InvariantError(45);
|
|
88
88
|
}
|
|
89
89
|
if (definition.kind === 'FragmentDefinition') {
|
|
90
90
|
fragments.push(definition);
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
if (typeof actualFragmentName === 'undefined') {
|
|
94
|
-
globals.__DEV__ ? globals.invariant(fragments.length === 1, "Found ".concat(fragments.length, " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.")) : globals.invariant(fragments.length === 1,
|
|
94
|
+
globals.__DEV__ ? globals.invariant(fragments.length === 1, "Found ".concat(fragments.length, " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.")) : globals.invariant(fragments.length === 1, 46);
|
|
95
95
|
actualFragmentName = fragments[0].name.value;
|
|
96
96
|
}
|
|
97
97
|
var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
|
|
@@ -132,7 +132,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
132
132
|
return fragmentMap(fragmentName);
|
|
133
133
|
}
|
|
134
134
|
var fragment = fragmentMap && fragmentMap[fragmentName];
|
|
135
|
-
globals.__DEV__ ? globals.invariant(fragment, "No fragment named ".concat(fragmentName)) : globals.invariant(fragment,
|
|
135
|
+
globals.__DEV__ ? globals.invariant(fragment, "No fragment named ".concat(fragmentName)) : globals.invariant(fragment, 47);
|
|
136
136
|
return fragment || null;
|
|
137
137
|
}
|
|
138
138
|
default:
|
|
@@ -222,7 +222,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
|
|
|
222
222
|
else {
|
|
223
223
|
throw globals.__DEV__ ? new globals.InvariantError("The inline argument \"".concat(name.value, "\" of kind \"").concat(value.kind, "\"") +
|
|
224
224
|
'is not supported. Use variables instead of inline arguments to ' +
|
|
225
|
-
'overcome this limitation.') : new globals.InvariantError(
|
|
225
|
+
'overcome this limitation.') : new globals.InvariantError(56);
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
function storeKeyNameFromField(field, variables) {
|
|
@@ -357,16 +357,16 @@ function isInlineFragment(selection) {
|
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
function checkDocument(doc) {
|
|
360
|
-
globals.__DEV__ ? globals.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") : globals.invariant(doc && doc.kind === 'Document',
|
|
360
|
+
globals.__DEV__ ? globals.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") : globals.invariant(doc && doc.kind === 'Document', 48);
|
|
361
361
|
var operations = doc.definitions
|
|
362
362
|
.filter(function (d) { return d.kind !== 'FragmentDefinition'; })
|
|
363
363
|
.map(function (definition) {
|
|
364
364
|
if (definition.kind !== 'OperationDefinition') {
|
|
365
|
-
throw globals.__DEV__ ? new globals.InvariantError("Schema type definitions not allowed in queries. Found: \"".concat(definition.kind, "\"")) : new globals.InvariantError(
|
|
365
|
+
throw globals.__DEV__ ? new globals.InvariantError("Schema type definitions not allowed in queries. Found: \"".concat(definition.kind, "\"")) : new globals.InvariantError(49);
|
|
366
366
|
}
|
|
367
367
|
return definition;
|
|
368
368
|
});
|
|
369
|
-
globals.__DEV__ ? globals.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains ".concat(operations.length, " operations")) : globals.invariant(operations.length <= 1,
|
|
369
|
+
globals.__DEV__ ? globals.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains ".concat(operations.length, " operations")) : globals.invariant(operations.length <= 1, 50);
|
|
370
370
|
return doc;
|
|
371
371
|
}
|
|
372
372
|
function getOperationDefinition(doc) {
|
|
@@ -389,14 +389,14 @@ function getFragmentDefinitions(doc) {
|
|
|
389
389
|
}
|
|
390
390
|
function getQueryDefinition(doc) {
|
|
391
391
|
var queryDef = getOperationDefinition(doc);
|
|
392
|
-
globals.__DEV__ ? globals.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : globals.invariant(queryDef && queryDef.operation === 'query',
|
|
392
|
+
globals.__DEV__ ? globals.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : globals.invariant(queryDef && queryDef.operation === 'query', 51);
|
|
393
393
|
return queryDef;
|
|
394
394
|
}
|
|
395
395
|
function getFragmentDefinition(doc) {
|
|
396
|
-
globals.__DEV__ ? globals.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") : globals.invariant(doc.kind === 'Document',
|
|
397
|
-
globals.__DEV__ ? globals.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : globals.invariant(doc.definitions.length <= 1,
|
|
396
|
+
globals.__DEV__ ? globals.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") : globals.invariant(doc.kind === 'Document', 52);
|
|
397
|
+
globals.__DEV__ ? globals.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : globals.invariant(doc.definitions.length <= 1, 53);
|
|
398
398
|
var fragmentDef = doc.definitions[0];
|
|
399
|
-
globals.__DEV__ ? globals.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : globals.invariant(fragmentDef.kind === 'FragmentDefinition',
|
|
399
|
+
globals.__DEV__ ? globals.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : globals.invariant(fragmentDef.kind === 'FragmentDefinition', 54);
|
|
400
400
|
return fragmentDef;
|
|
401
401
|
}
|
|
402
402
|
function getMainDefinition(queryDoc) {
|
|
@@ -419,7 +419,7 @@ function getMainDefinition(queryDoc) {
|
|
|
419
419
|
if (fragmentDefinition) {
|
|
420
420
|
return fragmentDefinition;
|
|
421
421
|
}
|
|
422
|
-
throw globals.__DEV__ ? new globals.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new globals.InvariantError(
|
|
422
|
+
throw globals.__DEV__ ? new globals.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new globals.InvariantError(55);
|
|
423
423
|
}
|
|
424
424
|
function getDefaultValues(definition) {
|
|
425
425
|
var defaultValues = Object.create(null);
|
|
@@ -1001,6 +1001,18 @@ function makeEmptyData() {
|
|
|
1001
1001
|
};
|
|
1002
1002
|
}
|
|
1003
1003
|
|
|
1004
|
+
function createFulfilledPromise(value) {
|
|
1005
|
+
var promise = Promise.resolve(value);
|
|
1006
|
+
promise.status = 'fulfilled';
|
|
1007
|
+
promise.value = value;
|
|
1008
|
+
return promise;
|
|
1009
|
+
}
|
|
1010
|
+
function createRejectedPromise(reason) {
|
|
1011
|
+
var promise = Promise.reject(reason);
|
|
1012
|
+
promise.status = 'rejected';
|
|
1013
|
+
promise.reason = reason;
|
|
1014
|
+
return promise;
|
|
1015
|
+
}
|
|
1004
1016
|
function isStatefulPromise(promise) {
|
|
1005
1017
|
return 'status' in promise;
|
|
1006
1018
|
}
|
|
@@ -1474,6 +1486,8 @@ exports.cloneDeep = cloneDeep;
|
|
|
1474
1486
|
exports.compact = compact;
|
|
1475
1487
|
exports.concatPagination = concatPagination;
|
|
1476
1488
|
exports.createFragmentMap = createFragmentMap;
|
|
1489
|
+
exports.createFulfilledPromise = createFulfilledPromise;
|
|
1490
|
+
exports.createRejectedPromise = createRejectedPromise;
|
|
1477
1491
|
exports.fixObservableSubclass = fixObservableSubclass;
|
|
1478
1492
|
exports.getDefaultValues = getDefaultValues;
|
|
1479
1493
|
exports.getDirectiveNames = getDirectiveNames;
|