@apollo/client 3.7.0-beta.7 → 3.7.0-beta.8
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 +142 -115
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +160 -37
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +160 -37
- package/cache/core/cache.d.ts +1 -1
- package/cache/core/cache.d.ts.map +1 -1
- package/cache/core/cache.js +3 -3
- package/cache/core/cache.js.map +1 -1
- package/cache/index.d.ts +2 -1
- package/cache/index.d.ts.map +1 -1
- package/cache/index.js +1 -0
- package/cache/index.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.d.ts +8 -0
- package/cache/inmemory/fragmentRegistry.d.ts.map +1 -0
- package/cache/inmemory/fragmentRegistry.js +113 -0
- package/cache/inmemory/fragmentRegistry.js.map +1 -0
- package/cache/inmemory/helpers.d.ts +9 -3
- package/cache/inmemory/helpers.d.ts.map +1 -1
- package/cache/inmemory/helpers.js +23 -6
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +1 -0
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js +9 -1
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +2 -1
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +10 -14
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +2 -0
- package/cache/inmemory/types.d.ts.map +1 -1
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +5 -3
- package/cache/inmemory/writeToStore.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.js +12 -19
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.js +2 -2
- package/core/LocalState.js +1 -1
- package/core/ObservableQuery.js +1 -1
- package/core/QueryInfo.d.ts +1 -1
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js +2 -2
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +21 -19
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +28 -26
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +28 -26
- package/invariantErrorCodes.js +59 -49
- package/link/batch-http/batch-http.cjs +2 -2
- package/link/batch-http/batch-http.cjs.map +1 -1
- package/link/batch-http/batch-http.cjs.native.js +2 -2
- package/link/batch-http/batchHttpLink.d.ts.map +1 -1
- package/link/batch-http/batchHttpLink.js +2 -2
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/core/ApolloLink.js +1 -1
- package/link/core/core.cjs +1 -1
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.d.ts.map +1 -1
- package/link/http/createHttpLink.js +2 -2
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/http.cjs +21 -11
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +21 -11
- package/link/http/selectHttpOptionsAndBody.d.ts +2 -0
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
- package/link/http/selectHttpOptionsAndBody.js +17 -7
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.js +2 -2
- package/link/persisted-queries/persisted-queries.cjs +2 -2
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +2 -2
- package/link/utils/utils.cjs +1 -1
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +1 -1
- package/link/utils/validateOperation.js +1 -1
- package/package.json +13 -13
- 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 +4 -2
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +4 -2
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useFragment.d.ts +1 -3
- package/react/hooks/useFragment.d.ts.map +1 -1
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +1 -1
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts.map +1 -1
- package/react/hooks/useSubscription.js +2 -0
- package/react/hooks/useSubscription.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/types/types.d.ts +1 -1
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +2 -2
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +2 -2
- package/testing/core/mocking/mockLink.js +2 -2
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/utilities/globals/globals.cjs +1 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +1 -1
- package/utilities/globals/index.js +1 -1
- package/utilities/graphql/directives.d.ts +3 -1
- package/utilities/graphql/directives.d.ts.map +1 -1
- package/utilities/graphql/directives.js +12 -11
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/fragments.d.ts +2 -1
- package/utilities/graphql/fragments.d.ts.map +1 -1
- package/utilities/graphql/fragments.js +9 -5
- package/utilities/graphql/fragments.js.map +1 -1
- package/utilities/graphql/getFromAST.js +8 -8
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/graphql/transform.d.ts.map +1 -1
- package/utilities/graphql/transform.js +3 -5
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +2 -2
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +1 -1
- package/utilities/index.js.map +1 -1
- package/utilities/utilities.cjs +35 -30
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +35 -30
- package/version.js +1 -1
|
@@ -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
|
-
__DEV__ ? globals.invariant(evaledValue !== void 0, "Invalid variable referenced in @".concat(directive.name.value, " directive.")) : globals.invariant(evaledValue !== void 0,
|
|
21
|
+
__DEV__ ? globals.invariant(evaledValue !== void 0, "Invalid variable referenced in @".concat(directive.name.value, " directive.")) : globals.invariant(evaledValue !== void 0, 39);
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
24
|
evaledValue = ifArgument.value.value;
|
|
@@ -35,22 +35,23 @@ function getDirectiveNames(root) {
|
|
|
35
35
|
});
|
|
36
36
|
return names;
|
|
37
37
|
}
|
|
38
|
-
function hasDirectives(names, root)
|
|
38
|
+
var hasAnyDirectives = function (names, root) { return hasDirectives(names, root, false); };
|
|
39
|
+
var hasAllDirectives = function (names, root) { return hasDirectives(names, root, true); };
|
|
40
|
+
function hasDirectives(names, root, all) {
|
|
39
41
|
var nameSet = new Set(names);
|
|
40
|
-
var
|
|
42
|
+
var uniqueCount = nameSet.size;
|
|
41
43
|
graphql.visit(root, {
|
|
42
44
|
Directive: function (node) {
|
|
43
|
-
if (nameSet.delete(node.name.value)
|
|
45
|
+
if (nameSet.delete(node.name.value) &&
|
|
46
|
+
(!all || !nameSet.size)) {
|
|
44
47
|
return graphql.BREAK;
|
|
45
48
|
}
|
|
46
49
|
},
|
|
47
50
|
});
|
|
48
|
-
return nameSet.size <
|
|
51
|
+
return all ? !nameSet.size : nameSet.size < uniqueCount;
|
|
49
52
|
}
|
|
50
53
|
function hasClientExports(document) {
|
|
51
|
-
return (document
|
|
52
|
-
hasDirectives(['client'], document) &&
|
|
53
|
-
hasDirectives(['export'], document));
|
|
54
|
+
return document && hasDirectives(['client', 'export'], document, true);
|
|
54
55
|
}
|
|
55
56
|
function isInclusionDirective(_a) {
|
|
56
57
|
var value = _a.name.value;
|
|
@@ -64,13 +65,13 @@ function getInclusionDirectives(directives) {
|
|
|
64
65
|
return;
|
|
65
66
|
var directiveArguments = directive.arguments;
|
|
66
67
|
var directiveName = directive.name.value;
|
|
67
|
-
__DEV__ ? globals.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @".concat(directiveName, " directive.")) : globals.invariant(directiveArguments && directiveArguments.length === 1,
|
|
68
|
+
__DEV__ ? globals.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @".concat(directiveName, " directive.")) : globals.invariant(directiveArguments && directiveArguments.length === 1, 40);
|
|
68
69
|
var ifArgument = directiveArguments[0];
|
|
69
|
-
__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
|
+
__DEV__ ? globals.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @".concat(directiveName, " directive.")) : globals.invariant(ifArgument.name && ifArgument.name.value === 'if', 41);
|
|
70
71
|
var ifValue = ifArgument.value;
|
|
71
72
|
__DEV__ ? globals.invariant(ifValue &&
|
|
72
73
|
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @".concat(directiveName, " directive must be a variable or a boolean value.")) : globals.invariant(ifValue &&
|
|
73
|
-
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'),
|
|
74
|
+
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 42);
|
|
74
75
|
result.push({ directive: directive, ifArgument: ifArgument });
|
|
75
76
|
});
|
|
76
77
|
}
|
|
@@ -83,14 +84,14 @@ function getFragmentQueryDocument(document, fragmentName) {
|
|
|
83
84
|
document.definitions.forEach(function (definition) {
|
|
84
85
|
if (definition.kind === 'OperationDefinition') {
|
|
85
86
|
throw __DEV__ ? new globals.InvariantError("Found a ".concat(definition.operation, " operation").concat(definition.name ? " named '".concat(definition.name.value, "'") : '', ". ") +
|
|
86
|
-
'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(43);
|
|
87
88
|
}
|
|
88
89
|
if (definition.kind === 'FragmentDefinition') {
|
|
89
90
|
fragments.push(definition);
|
|
90
91
|
}
|
|
91
92
|
});
|
|
92
93
|
if (typeof actualFragmentName === 'undefined') {
|
|
93
|
-
__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
|
+
__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, 44);
|
|
94
95
|
actualFragmentName = fragments[0].name.value;
|
|
95
96
|
}
|
|
96
97
|
var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
|
|
@@ -126,9 +127,13 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
126
127
|
case 'InlineFragment':
|
|
127
128
|
return selection;
|
|
128
129
|
case 'FragmentSpread': {
|
|
129
|
-
var
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
var fragmentName = selection.name.value;
|
|
131
|
+
if (typeof fragmentMap === "function") {
|
|
132
|
+
return fragmentMap(fragmentName);
|
|
133
|
+
}
|
|
134
|
+
var fragment = fragmentMap && fragmentMap[fragmentName];
|
|
135
|
+
__DEV__ ? globals.invariant(fragment, "No fragment named ".concat(fragmentName)) : globals.invariant(fragment, 45);
|
|
136
|
+
return fragment || null;
|
|
132
137
|
}
|
|
133
138
|
default:
|
|
134
139
|
return null;
|
|
@@ -211,7 +216,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
|
|
|
211
216
|
else {
|
|
212
217
|
throw __DEV__ ? new globals.InvariantError("The inline argument \"".concat(name.value, "\" of kind \"").concat(value.kind, "\"") +
|
|
213
218
|
'is not supported. Use variables instead of inline arguments to ' +
|
|
214
|
-
'overcome this limitation.') : new globals.InvariantError(
|
|
219
|
+
'overcome this limitation.') : new globals.InvariantError(54);
|
|
215
220
|
}
|
|
216
221
|
}
|
|
217
222
|
function storeKeyNameFromField(field, variables) {
|
|
@@ -345,16 +350,16 @@ function isInlineFragment(selection) {
|
|
|
345
350
|
}
|
|
346
351
|
|
|
347
352
|
function checkDocument(doc) {
|
|
348
|
-
__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',
|
|
353
|
+
__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', 46);
|
|
349
354
|
var operations = doc.definitions
|
|
350
355
|
.filter(function (d) { return d.kind !== 'FragmentDefinition'; })
|
|
351
356
|
.map(function (definition) {
|
|
352
357
|
if (definition.kind !== 'OperationDefinition') {
|
|
353
|
-
throw __DEV__ ? new globals.InvariantError("Schema type definitions not allowed in queries. Found: \"".concat(definition.kind, "\"")) : new globals.InvariantError(
|
|
358
|
+
throw __DEV__ ? new globals.InvariantError("Schema type definitions not allowed in queries. Found: \"".concat(definition.kind, "\"")) : new globals.InvariantError(47);
|
|
354
359
|
}
|
|
355
360
|
return definition;
|
|
356
361
|
});
|
|
357
|
-
__DEV__ ? globals.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains ".concat(operations.length, " operations")) : globals.invariant(operations.length <= 1,
|
|
362
|
+
__DEV__ ? globals.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains ".concat(operations.length, " operations")) : globals.invariant(operations.length <= 1, 48);
|
|
358
363
|
return doc;
|
|
359
364
|
}
|
|
360
365
|
function getOperationDefinition(doc) {
|
|
@@ -373,14 +378,14 @@ function getFragmentDefinitions(doc) {
|
|
|
373
378
|
}
|
|
374
379
|
function getQueryDefinition(doc) {
|
|
375
380
|
var queryDef = getOperationDefinition(doc);
|
|
376
|
-
__DEV__ ? globals.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : globals.invariant(queryDef && queryDef.operation === 'query',
|
|
381
|
+
__DEV__ ? globals.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : globals.invariant(queryDef && queryDef.operation === 'query', 49);
|
|
377
382
|
return queryDef;
|
|
378
383
|
}
|
|
379
384
|
function getFragmentDefinition(doc) {
|
|
380
|
-
__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',
|
|
381
|
-
__DEV__ ? globals.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : globals.invariant(doc.definitions.length <= 1,
|
|
385
|
+
__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', 50);
|
|
386
|
+
__DEV__ ? globals.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : globals.invariant(doc.definitions.length <= 1, 51);
|
|
382
387
|
var fragmentDef = doc.definitions[0];
|
|
383
|
-
__DEV__ ? globals.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : globals.invariant(fragmentDef.kind === 'FragmentDefinition',
|
|
388
|
+
__DEV__ ? globals.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : globals.invariant(fragmentDef.kind === 'FragmentDefinition', 52);
|
|
384
389
|
return fragmentDef;
|
|
385
390
|
}
|
|
386
391
|
function getMainDefinition(queryDoc) {
|
|
@@ -403,7 +408,7 @@ function getMainDefinition(queryDoc) {
|
|
|
403
408
|
if (fragmentDefinition) {
|
|
404
409
|
return fragmentDefinition;
|
|
405
410
|
}
|
|
406
|
-
throw __DEV__ ? new globals.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new globals.InvariantError(
|
|
411
|
+
throw __DEV__ ? new globals.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new globals.InvariantError(53);
|
|
407
412
|
}
|
|
408
413
|
function getDefaultValues(definition) {
|
|
409
414
|
var defaultValues = Object.create(null);
|
|
@@ -436,11 +441,9 @@ var TYPENAME_FIELD = {
|
|
|
436
441
|
value: '__typename',
|
|
437
442
|
},
|
|
438
443
|
};
|
|
439
|
-
function isEmpty(op,
|
|
440
|
-
return op.selectionSet.selections.every(function (selection) {
|
|
441
|
-
|
|
442
|
-
isEmpty(fragments[selection.name.value], fragments);
|
|
443
|
-
});
|
|
444
|
+
function isEmpty(op, fragmentMap) {
|
|
445
|
+
return !op || op.selectionSet.selections.every(function (selection) { return selection.kind === 'FragmentSpread' &&
|
|
446
|
+
isEmpty(fragmentMap[selection.name.value], fragmentMap); });
|
|
444
447
|
}
|
|
445
448
|
function nullIfDocIsEmpty(doc) {
|
|
446
449
|
return isEmpty(getOperationDefinition(doc) || getFragmentDefinition(doc), createFragmentMap(getFragmentDefinitions(doc)))
|
|
@@ -1260,6 +1263,8 @@ exports.getQueryDefinition = getQueryDefinition;
|
|
|
1260
1263
|
exports.getStoreKeyName = getStoreKeyName;
|
|
1261
1264
|
exports.getTypenameFromResult = getTypenameFromResult;
|
|
1262
1265
|
exports.graphQLResultHasError = graphQLResultHasError;
|
|
1266
|
+
exports.hasAllDirectives = hasAllDirectives;
|
|
1267
|
+
exports.hasAnyDirectives = hasAnyDirectives;
|
|
1263
1268
|
exports.hasClientExports = hasClientExports;
|
|
1264
1269
|
exports.hasDirectives = hasDirectives;
|
|
1265
1270
|
exports.isDocumentNode = isDocumentNode;
|
package/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export var version = '3.7.0-beta.
|
|
1
|
+
export var version = '3.7.0-beta.8';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|