@apollo/client 3.5.0-beta.12 → 3.5.0-beta.16
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 +160 -120
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -0
- package/cache/cache.cjs +86 -65
- package/cache/cache.cjs.map +1 -1
- package/cache/core/cache.d.ts +4 -4
- package/cache/core/cache.d.ts.map +1 -1
- package/cache/core/cache.js +24 -13
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +10 -10
- package/cache/core/types/Cache.d.ts.map +1 -1
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/common.d.ts +8 -5
- package/cache/core/types/common.d.ts.map +1 -1
- package/cache/core/types/common.js +6 -11
- package/cache/core/types/common.js.map +1 -1
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +4 -4
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js +3 -1
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +2 -2
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +54 -42
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/writeToStore.js +1 -1
- package/core/ApolloClient.js +2 -2
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.js +1 -1
- package/core/ObservableQuery.d.ts +2 -1
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +3 -3
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.js +8 -8
- package/core/core.cjs +15 -15
- package/core/core.cjs.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/invariantErrorCodes.js +52 -65
- package/link/core/ApolloLink.js +1 -1
- package/link/core/core.cjs +1 -1
- package/link/core/core.cjs.map +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/http.cjs +2 -2
- package/link/http/http.cjs.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/utils/utils.cjs +1 -1
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/validateOperation.js +1 -1
- package/package.json +8 -8
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloContext.d.ts.map +1 -1
- package/react/context/ApolloContext.js +11 -5
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/context.cjs +12 -6
- package/react/context/context.cjs.map +1 -1
- package/react/hoc/hoc-utils.js +1 -1
- package/react/hoc/hoc.cjs +10 -7
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/subscription-hoc.d.ts.map +1 -1
- package/react/hoc/subscription-hoc.js +8 -5
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/hoc/withApollo.js +1 -1
- package/react/hooks/hooks.cjs +1 -1
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useQuery.d.ts +1 -1
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js.map +1 -1
- package/react/parser/index.js +5 -5
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs +5 -5
- package/react/parser/parser.cjs.map +1 -1
- package/testing/core/core.cjs +288 -0
- package/testing/core/core.cjs.map +1 -0
- package/{utilities/testing → testing/core}/index.d.ts +0 -1
- package/testing/core/index.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/index.js +0 -1
- package/testing/core/index.js.map +1 -0
- package/{utilities/testing → testing/core}/itAsync.d.ts +0 -0
- package/testing/core/itAsync.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/itAsync.js +0 -0
- package/testing/core/itAsync.js.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockClient.d.ts +0 -0
- package/testing/core/mocking/mockClient.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockClient.js +0 -0
- package/testing/core/mocking/mockClient.js.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockFetch.d.ts +0 -0
- package/testing/core/mocking/mockFetch.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockFetch.js +0 -0
- package/testing/core/mocking/mockFetch.js.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockLink.d.ts +0 -0
- package/testing/core/mocking/mockLink.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockLink.js +3 -3
- package/testing/core/mocking/mockLink.js.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockQueryManager.d.ts +1 -1
- package/testing/core/mocking/mockQueryManager.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockQueryManager.js +1 -1
- package/testing/core/mocking/mockQueryManager.js.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockSubscriptionLink.d.ts +0 -0
- package/testing/core/mocking/mockSubscriptionLink.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockSubscriptionLink.js +1 -1
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockWatchQuery.d.ts +1 -1
- package/testing/core/mocking/mockWatchQuery.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockWatchQuery.js +0 -0
- package/testing/core/mocking/mockWatchQuery.js.map +1 -0
- package/{utilities/testing → testing/core}/observableToPromise.d.ts +2 -3
- package/testing/core/observableToPromise.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/observableToPromise.js +0 -0
- package/testing/core/observableToPromise.js.map +1 -0
- package/testing/core/package.json +8 -0
- package/testing/core/subscribeAndCount.d.ts +4 -0
- package/testing/core/subscribeAndCount.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/subscribeAndCount.js +1 -1
- package/testing/core/subscribeAndCount.js.map +1 -0
- package/{utilities/testing → testing/core}/withConsoleSpy.d.ts +0 -0
- package/testing/core/withConsoleSpy.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/withConsoleSpy.js +0 -0
- package/testing/core/withConsoleSpy.js.map +1 -0
- package/{utilities/testing → testing/core}/wrap.d.ts +0 -0
- package/testing/core/wrap.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/wrap.js +0 -0
- package/testing/core/wrap.js.map +1 -0
- package/testing/index.d.ts +2 -1
- package/testing/index.d.ts.map +1 -1
- package/testing/index.js +2 -1
- package/testing/index.js.map +1 -1
- package/{utilities/testing/mocking → testing/react}/MockedProvider.d.ts +5 -5
- package/testing/react/MockedProvider.d.ts.map +1 -0
- package/{utilities/testing/mocking → testing/react}/MockedProvider.js +4 -4
- package/testing/react/MockedProvider.js.map +1 -0
- package/testing/testing.cjs +6 -330
- package/testing/testing.cjs.map +1 -1
- package/utilities/common/canUse.d.ts +1 -0
- package/utilities/common/canUse.d.ts.map +1 -1
- package/utilities/common/canUse.js +2 -0
- package/utilities/common/canUse.js.map +1 -1
- package/utilities/common/maybeDeepFreeze.d.ts.map +1 -1
- package/utilities/common/maybeDeepFreeze.js +14 -3
- package/utilities/common/maybeDeepFreeze.js.map +1 -1
- package/utilities/globals/globals.cjs +1 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/index.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/observables/subclassing.d.ts.map +1 -1
- package/utilities/observables/subclassing.js +2 -1
- package/utilities/observables/subclassing.js.map +1 -1
- package/utilities/policies/pagination.d.ts +1 -1
- package/utilities/policies/pagination.d.ts.map +1 -1
- package/utilities/policies/pagination.js +7 -2
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/utilities.cjs +45 -26
- package/utilities/utilities.cjs.map +1 -1
- package/version.js +1 -1
- package/utilities/testing/index.d.ts.map +0 -1
- package/utilities/testing/index.js.map +0 -1
- package/utilities/testing/itAsync.d.ts.map +0 -1
- package/utilities/testing/itAsync.js.map +0 -1
- package/utilities/testing/mocking/MockedProvider.d.ts.map +0 -1
- package/utilities/testing/mocking/MockedProvider.js.map +0 -1
- package/utilities/testing/mocking/mockClient.d.ts.map +0 -1
- package/utilities/testing/mocking/mockClient.js.map +0 -1
- package/utilities/testing/mocking/mockFetch.d.ts.map +0 -1
- package/utilities/testing/mocking/mockFetch.js.map +0 -1
- package/utilities/testing/mocking/mockLink.d.ts.map +0 -1
- package/utilities/testing/mocking/mockLink.js.map +0 -1
- package/utilities/testing/mocking/mockQueryManager.d.ts.map +0 -1
- package/utilities/testing/mocking/mockQueryManager.js.map +0 -1
- package/utilities/testing/mocking/mockSubscriptionLink.d.ts.map +0 -1
- package/utilities/testing/mocking/mockSubscriptionLink.js.map +0 -1
- package/utilities/testing/mocking/mockWatchQuery.d.ts.map +0 -1
- package/utilities/testing/mocking/mockWatchQuery.js.map +0 -1
- package/utilities/testing/observableToPromise.d.ts.map +0 -1
- package/utilities/testing/observableToPromise.js.map +0 -1
- package/utilities/testing/subscribeAndCount.d.ts +0 -5
- package/utilities/testing/subscribeAndCount.d.ts.map +0 -1
- package/utilities/testing/subscribeAndCount.js.map +0 -1
- package/utilities/testing/withConsoleSpy.d.ts.map +0 -1
- package/utilities/testing/withConsoleSpy.js.map +0 -1
- package/utilities/testing/wrap.d.ts.map +0 -1
- package/utilities/testing/wrap.js.map +0 -1
package/apollo-client.cjs
CHANGED
|
@@ -45,7 +45,7 @@ function shouldInclude(_a, variables) {
|
|
|
45
45
|
var evaledValue = false;
|
|
46
46
|
if (ifArgument.value.kind === 'Variable') {
|
|
47
47
|
evaledValue = variables && variables[ifArgument.value.name.value];
|
|
48
|
-
__DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.") : tsInvariant.invariant(evaledValue !== void 0,
|
|
48
|
+
__DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.") : tsInvariant.invariant(evaledValue !== void 0, 37);
|
|
49
49
|
}
|
|
50
50
|
else {
|
|
51
51
|
evaledValue = ifArgument.value.value;
|
|
@@ -82,13 +82,13 @@ function getInclusionDirectives(directives) {
|
|
|
82
82
|
return;
|
|
83
83
|
var directiveArguments = directive.arguments;
|
|
84
84
|
var directiveName = directive.name.value;
|
|
85
|
-
__DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.") : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1,
|
|
85
|
+
__DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.") : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, 38);
|
|
86
86
|
var ifArgument = directiveArguments[0];
|
|
87
|
-
__DEV__ ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive.") : tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if',
|
|
87
|
+
__DEV__ ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive.") : tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', 39);
|
|
88
88
|
var ifValue = ifArgument.value;
|
|
89
89
|
__DEV__ ? tsInvariant.invariant(ifValue &&
|
|
90
90
|
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @" + directiveName + " directive must be a variable or a boolean value.") : tsInvariant.invariant(ifValue &&
|
|
91
|
-
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'),
|
|
91
|
+
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 40);
|
|
92
92
|
result.push({ directive: directive, ifArgument: ifArgument });
|
|
93
93
|
});
|
|
94
94
|
}
|
|
@@ -101,14 +101,14 @@ function getFragmentQueryDocument(document, fragmentName) {
|
|
|
101
101
|
document.definitions.forEach(function (definition) {
|
|
102
102
|
if (definition.kind === 'OperationDefinition') {
|
|
103
103
|
throw __DEV__ ? new tsInvariant.InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " +
|
|
104
|
-
'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new tsInvariant.InvariantError(
|
|
104
|
+
'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new tsInvariant.InvariantError(41);
|
|
105
105
|
}
|
|
106
106
|
if (definition.kind === 'FragmentDefinition') {
|
|
107
107
|
fragments.push(definition);
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
if (typeof actualFragmentName === 'undefined') {
|
|
111
|
-
__DEV__ ? tsInvariant.invariant(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.") : tsInvariant.invariant(fragments.length === 1,
|
|
111
|
+
__DEV__ ? tsInvariant.invariant(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.") : tsInvariant.invariant(fragments.length === 1, 42);
|
|
112
112
|
actualFragmentName = fragments[0].name.value;
|
|
113
113
|
}
|
|
114
114
|
var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
|
|
@@ -145,7 +145,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
145
145
|
return selection;
|
|
146
146
|
case 'FragmentSpread': {
|
|
147
147
|
var fragment = fragmentMap && fragmentMap[selection.name.value];
|
|
148
|
-
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value + ".") : tsInvariant.invariant(fragment,
|
|
148
|
+
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value + ".") : tsInvariant.invariant(fragment, 43);
|
|
149
149
|
return fragment;
|
|
150
150
|
}
|
|
151
151
|
default:
|
|
@@ -229,7 +229,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
|
|
|
229
229
|
else {
|
|
230
230
|
throw __DEV__ ? new tsInvariant.InvariantError("The inline argument \"" + name.value + "\" of kind \"" + value.kind + "\"" +
|
|
231
231
|
'is not supported. Use variables instead of inline arguments to ' +
|
|
232
|
-
'overcome this limitation.') : new tsInvariant.InvariantError(
|
|
232
|
+
'overcome this limitation.') : new tsInvariant.InvariantError(52);
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
function storeKeyNameFromField(field, variables) {
|
|
@@ -363,16 +363,16 @@ function isInlineFragment(selection) {
|
|
|
363
363
|
}
|
|
364
364
|
|
|
365
365
|
function checkDocument(doc) {
|
|
366
|
-
__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',
|
|
366
|
+
__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', 44);
|
|
367
367
|
var operations = doc.definitions
|
|
368
368
|
.filter(function (d) { return d.kind !== 'FragmentDefinition'; })
|
|
369
369
|
.map(function (definition) {
|
|
370
370
|
if (definition.kind !== 'OperationDefinition') {
|
|
371
|
-
throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"") : new tsInvariant.InvariantError(
|
|
371
|
+
throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"") : new tsInvariant.InvariantError(45);
|
|
372
372
|
}
|
|
373
373
|
return definition;
|
|
374
374
|
});
|
|
375
|
-
__DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations") : tsInvariant.invariant(operations.length <= 1,
|
|
375
|
+
__DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations") : tsInvariant.invariant(operations.length <= 1, 46);
|
|
376
376
|
return doc;
|
|
377
377
|
}
|
|
378
378
|
function getOperationDefinition(doc) {
|
|
@@ -391,14 +391,14 @@ function getFragmentDefinitions(doc) {
|
|
|
391
391
|
}
|
|
392
392
|
function getQueryDefinition(doc) {
|
|
393
393
|
var queryDef = getOperationDefinition(doc);
|
|
394
|
-
__DEV__ ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : tsInvariant.invariant(queryDef && queryDef.operation === 'query',
|
|
394
|
+
__DEV__ ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : tsInvariant.invariant(queryDef && queryDef.operation === 'query', 47);
|
|
395
395
|
return queryDef;
|
|
396
396
|
}
|
|
397
397
|
function getFragmentDefinition(doc) {
|
|
398
|
-
__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',
|
|
399
|
-
__DEV__ ? tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : tsInvariant.invariant(doc.definitions.length <= 1,
|
|
398
|
+
__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', 48);
|
|
399
|
+
__DEV__ ? tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : tsInvariant.invariant(doc.definitions.length <= 1, 49);
|
|
400
400
|
var fragmentDef = doc.definitions[0];
|
|
401
|
-
__DEV__ ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition',
|
|
401
|
+
__DEV__ ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 50);
|
|
402
402
|
return fragmentDef;
|
|
403
403
|
}
|
|
404
404
|
function getMainDefinition(queryDoc) {
|
|
@@ -421,7 +421,7 @@ function getMainDefinition(queryDoc) {
|
|
|
421
421
|
if (fragmentDefinition) {
|
|
422
422
|
return fragmentDefinition;
|
|
423
423
|
}
|
|
424
|
-
throw __DEV__ ? new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new tsInvariant.InvariantError(
|
|
424
|
+
throw __DEV__ ? new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new tsInvariant.InvariantError(51);
|
|
425
425
|
}
|
|
426
426
|
function getDefaultValues(definition) {
|
|
427
427
|
var defaultValues = Object.create(null);
|
|
@@ -810,9 +810,7 @@ function cloneDeepHelper(val, seen) {
|
|
|
810
810
|
function deepFreeze(value) {
|
|
811
811
|
var workSet = new Set([value]);
|
|
812
812
|
workSet.forEach(function (obj) {
|
|
813
|
-
if (isNonNullObject(obj)) {
|
|
814
|
-
if (!Object.isFrozen(obj))
|
|
815
|
-
Object.freeze(obj);
|
|
813
|
+
if (isNonNullObject(obj) && shallowFreeze(obj) === obj) {
|
|
816
814
|
Object.getOwnPropertyNames(obj).forEach(function (name) {
|
|
817
815
|
if (isNonNullObject(obj[name]))
|
|
818
816
|
workSet.add(obj[name]);
|
|
@@ -821,6 +819,19 @@ function deepFreeze(value) {
|
|
|
821
819
|
});
|
|
822
820
|
return value;
|
|
823
821
|
}
|
|
822
|
+
function shallowFreeze(obj) {
|
|
823
|
+
if (__DEV__ && !Object.isFrozen(obj)) {
|
|
824
|
+
try {
|
|
825
|
+
Object.freeze(obj);
|
|
826
|
+
}
|
|
827
|
+
catch (e) {
|
|
828
|
+
if (e instanceof TypeError)
|
|
829
|
+
return null;
|
|
830
|
+
throw e;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
return obj;
|
|
834
|
+
}
|
|
824
835
|
function maybeDeepFreeze(obj) {
|
|
825
836
|
if (__DEV__) {
|
|
826
837
|
deepFreeze(obj);
|
|
@@ -882,11 +893,17 @@ function asyncMap(observable, mapFn, catchFn) {
|
|
|
882
893
|
});
|
|
883
894
|
}
|
|
884
895
|
|
|
896
|
+
var canUseWeakMap = typeof WeakMap === 'function' && !(typeof navigator === 'object' &&
|
|
897
|
+
navigator.product === 'ReactNative');
|
|
898
|
+
var canUseWeakSet = typeof WeakSet === 'function';
|
|
899
|
+
var canUseSymbol = typeof Symbol === 'function' &&
|
|
900
|
+
typeof Symbol.for === 'function';
|
|
901
|
+
|
|
885
902
|
function fixObservableSubclass(subclass) {
|
|
886
903
|
function set(key) {
|
|
887
904
|
Object.defineProperty(subclass, key, { value: zenObservableTs.Observable });
|
|
888
905
|
}
|
|
889
|
-
if (
|
|
906
|
+
if (canUseSymbol && Symbol.species) {
|
|
890
907
|
set(Symbol.species);
|
|
891
908
|
}
|
|
892
909
|
set("@@species");
|
|
@@ -1032,10 +1049,6 @@ function graphQLResultHasError(result) {
|
|
|
1032
1049
|
return (result.errors && result.errors.length > 0) || false;
|
|
1033
1050
|
}
|
|
1034
1051
|
|
|
1035
|
-
var canUseWeakMap = typeof WeakMap === 'function' && !(typeof navigator === 'object' &&
|
|
1036
|
-
navigator.product === 'ReactNative');
|
|
1037
|
-
var canUseWeakSet = typeof WeakSet === 'function';
|
|
1038
|
-
|
|
1039
1052
|
function compact() {
|
|
1040
1053
|
var objects = [];
|
|
1041
1054
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -1124,7 +1137,7 @@ function validateOperation(operation) {
|
|
|
1124
1137
|
for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
|
|
1125
1138
|
var key = _a[_i];
|
|
1126
1139
|
if (OPERATION_FIELDS.indexOf(key) < 0) {
|
|
1127
|
-
throw __DEV__ ? new tsInvariant.InvariantError("illegal argument: " + key) : new tsInvariant.InvariantError(
|
|
1140
|
+
throw __DEV__ ? new tsInvariant.InvariantError("illegal argument: " + key) : new tsInvariant.InvariantError(24);
|
|
1128
1141
|
}
|
|
1129
1142
|
}
|
|
1130
1143
|
return operation;
|
|
@@ -1247,7 +1260,7 @@ var ApolloLink = (function () {
|
|
|
1247
1260
|
return ApolloLink.concat(this, next);
|
|
1248
1261
|
};
|
|
1249
1262
|
ApolloLink.prototype.request = function (operation, forward) {
|
|
1250
|
-
throw __DEV__ ? new tsInvariant.InvariantError('request is not implemented') : new tsInvariant.InvariantError(
|
|
1263
|
+
throw __DEV__ ? new tsInvariant.InvariantError('request is not implemented') : new tsInvariant.InvariantError(19);
|
|
1251
1264
|
};
|
|
1252
1265
|
ApolloLink.prototype.onError = function (error, observer) {
|
|
1253
1266
|
if (observer && observer.error) {
|
|
@@ -1273,7 +1286,7 @@ var concat = ApolloLink.concat;
|
|
|
1273
1286
|
|
|
1274
1287
|
var execute = ApolloLink.execute;
|
|
1275
1288
|
|
|
1276
|
-
var version = '3.5.0-beta.
|
|
1289
|
+
var version = '3.5.0-beta.16';
|
|
1277
1290
|
|
|
1278
1291
|
var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
1279
1292
|
function parseAndCheckHttpResponse(operations) {
|
|
@@ -1313,7 +1326,7 @@ var serializeFetchParameter = function (p, label) {
|
|
|
1313
1326
|
serialized = JSON.stringify(p);
|
|
1314
1327
|
}
|
|
1315
1328
|
catch (e) {
|
|
1316
|
-
var parseError = __DEV__ ? new tsInvariant.InvariantError("Network request failed. " + label + " is not serializable: " + e.message) : new tsInvariant.InvariantError(
|
|
1329
|
+
var parseError = __DEV__ ? new tsInvariant.InvariantError("Network request failed. " + label + " is not serializable: " + e.message) : new tsInvariant.InvariantError(21);
|
|
1317
1330
|
parseError.parseError = e;
|
|
1318
1331
|
throw parseError;
|
|
1319
1332
|
}
|
|
@@ -1374,7 +1387,7 @@ function headersToLowerCase(headers) {
|
|
|
1374
1387
|
|
|
1375
1388
|
var checkFetcher = function (fetcher) {
|
|
1376
1389
|
if (!fetcher && typeof fetch === 'undefined') {
|
|
1377
|
-
throw __DEV__ ? new tsInvariant.InvariantError("\n\"fetch\" has not been found globally and no fetcher has been configured. To fix this, install a fetch package (like https://www.npmjs.com/package/cross-fetch), instantiate the fetcher, and pass it into your HttpLink constructor. For example:\n\nimport fetch from 'cross-fetch';\nimport { ApolloClient, HttpLink } from '@apollo/client';\nconst client = new ApolloClient({\n link: new HttpLink({ uri: '/graphql', fetch })\n});\n ") : new tsInvariant.InvariantError(
|
|
1390
|
+
throw __DEV__ ? new tsInvariant.InvariantError("\n\"fetch\" has not been found globally and no fetcher has been configured. To fix this, install a fetch package (like https://www.npmjs.com/package/cross-fetch), instantiate the fetcher, and pass it into your HttpLink constructor. For example:\n\nimport fetch from 'cross-fetch';\nimport { ApolloClient, HttpLink } from '@apollo/client';\nconst client = new ApolloClient({\n link: new HttpLink({ uri: '/graphql', fetch })\n});\n ") : new tsInvariant.InvariantError(20);
|
|
1378
1391
|
}
|
|
1379
1392
|
};
|
|
1380
1393
|
|
|
@@ -1566,9 +1579,12 @@ var ApolloCache = (function () {
|
|
|
1566
1579
|
this.getFragmentDoc = optimism.wrap(getFragmentQueryDocument);
|
|
1567
1580
|
}
|
|
1568
1581
|
ApolloCache.prototype.batch = function (options) {
|
|
1582
|
+
var _this = this;
|
|
1569
1583
|
var optimisticId = typeof options.optimistic === "string" ? options.optimistic :
|
|
1570
1584
|
options.optimistic === false ? null : void 0;
|
|
1571
|
-
|
|
1585
|
+
var updateResult;
|
|
1586
|
+
this.performTransaction(function () { return updateResult = options.update(_this); }, optimisticId);
|
|
1587
|
+
return updateResult;
|
|
1572
1588
|
};
|
|
1573
1589
|
ApolloCache.prototype.recordOptimisticTransaction = function (transaction, optimisticId) {
|
|
1574
1590
|
this.performTransaction(transaction, optimisticId);
|
|
@@ -1612,20 +1628,28 @@ var ApolloCache = (function () {
|
|
|
1612
1628
|
}));
|
|
1613
1629
|
};
|
|
1614
1630
|
ApolloCache.prototype.updateQuery = function (options, update) {
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1631
|
+
return this.batch({
|
|
1632
|
+
update: function (cache) {
|
|
1633
|
+
var value = cache.readQuery(options);
|
|
1634
|
+
var data = update(value);
|
|
1635
|
+
if (data === void 0 || data === null)
|
|
1636
|
+
return value;
|
|
1637
|
+
cache.writeQuery(tslib.__assign(tslib.__assign({}, options), { data: data }));
|
|
1638
|
+
return data;
|
|
1639
|
+
},
|
|
1640
|
+
});
|
|
1621
1641
|
};
|
|
1622
1642
|
ApolloCache.prototype.updateFragment = function (options, update) {
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1643
|
+
return this.batch({
|
|
1644
|
+
update: function (cache) {
|
|
1645
|
+
var value = cache.readFragment(options);
|
|
1646
|
+
var data = update(value);
|
|
1647
|
+
if (data === void 0 || data === null)
|
|
1648
|
+
return value;
|
|
1649
|
+
cache.writeFragment(tslib.__assign(tslib.__assign({}, options), { data: data }));
|
|
1650
|
+
return data;
|
|
1651
|
+
},
|
|
1652
|
+
});
|
|
1629
1653
|
};
|
|
1630
1654
|
return ApolloCache;
|
|
1631
1655
|
}());
|
|
@@ -1634,19 +1658,15 @@ exports.Cache = void 0;
|
|
|
1634
1658
|
(function (Cache) {
|
|
1635
1659
|
})(exports.Cache || (exports.Cache = {}));
|
|
1636
1660
|
|
|
1637
|
-
var MissingFieldError = (function (
|
|
1638
|
-
tslib.__extends(MissingFieldError, _super);
|
|
1661
|
+
var MissingFieldError = (function () {
|
|
1639
1662
|
function MissingFieldError(message, path, query, variables) {
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
_this.variables = variables;
|
|
1645
|
-
_this.__proto__ = MissingFieldError.prototype;
|
|
1646
|
-
return _this;
|
|
1663
|
+
this.message = message;
|
|
1664
|
+
this.path = path;
|
|
1665
|
+
this.query = query;
|
|
1666
|
+
this.variables = variables;
|
|
1647
1667
|
}
|
|
1648
1668
|
return MissingFieldError;
|
|
1649
|
-
}(
|
|
1669
|
+
}());
|
|
1650
1670
|
|
|
1651
1671
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
1652
1672
|
function getTypenameFromStoreObject(store, objectOrReference) {
|
|
@@ -2257,9 +2277,6 @@ function resetCanonicalStringify() {
|
|
|
2257
2277
|
stringifyCache = new (canUseWeakMap ? WeakMap : Map)();
|
|
2258
2278
|
}
|
|
2259
2279
|
|
|
2260
|
-
function missingFromInvariant(err, context) {
|
|
2261
|
-
return new MissingFieldError(err.message, context.path.slice(), context.query, context.variables);
|
|
2262
|
-
}
|
|
2263
2280
|
function execSelectionSetKeyArgs(options) {
|
|
2264
2281
|
return [
|
|
2265
2282
|
options.selectionSet,
|
|
@@ -2318,6 +2335,7 @@ var StoreReader = (function () {
|
|
|
2318
2335
|
var policies = this.config.cache.policies;
|
|
2319
2336
|
variables = tslib.__assign(tslib.__assign({}, getDefaultValues(getQueryDefinition(query))), variables);
|
|
2320
2337
|
var rootRef = makeReference(rootId);
|
|
2338
|
+
var merger = new DeepMerger;
|
|
2321
2339
|
var execResult = this.executeSelectionSet({
|
|
2322
2340
|
selectionSet: getMainDefinition(query).selectionSet,
|
|
2323
2341
|
objectOrReference: rootRef,
|
|
@@ -2330,17 +2348,22 @@ var StoreReader = (function () {
|
|
|
2330
2348
|
varString: canonicalStringify(variables),
|
|
2331
2349
|
canonizeResults: canonizeResults,
|
|
2332
2350
|
fragmentMap: createFragmentMap(getFragmentDefinitions(query)),
|
|
2333
|
-
|
|
2351
|
+
merge: function (a, b) {
|
|
2352
|
+
return merger.merge(a, b);
|
|
2353
|
+
},
|
|
2334
2354
|
},
|
|
2335
2355
|
});
|
|
2336
|
-
var
|
|
2337
|
-
if (
|
|
2338
|
-
|
|
2356
|
+
var missing;
|
|
2357
|
+
if (execResult.missing) {
|
|
2358
|
+
missing = [new MissingFieldError(firstMissing(execResult.missing), execResult.missing, query, variables)];
|
|
2359
|
+
if (!returnPartialData) {
|
|
2360
|
+
throw missing[0];
|
|
2361
|
+
}
|
|
2339
2362
|
}
|
|
2340
2363
|
return {
|
|
2341
2364
|
result: execResult.result,
|
|
2342
|
-
|
|
2343
|
-
|
|
2365
|
+
complete: !missing,
|
|
2366
|
+
missing: missing,
|
|
2344
2367
|
};
|
|
2345
2368
|
};
|
|
2346
2369
|
StoreReader.prototype.isFresh = function (result, parent, selectionSet, context) {
|
|
@@ -2361,30 +2384,28 @@ var StoreReader = (function () {
|
|
|
2361
2384
|
!context.store.has(objectOrReference.__ref)) {
|
|
2362
2385
|
return {
|
|
2363
2386
|
result: this.canon.empty,
|
|
2364
|
-
missing:
|
|
2387
|
+
missing: "Dangling reference to missing " + objectOrReference.__ref + " object",
|
|
2365
2388
|
};
|
|
2366
2389
|
}
|
|
2367
2390
|
var variables = context.variables, policies = context.policies, store = context.store;
|
|
2368
|
-
var objectsToMerge = [];
|
|
2369
|
-
var finalResult = { result: null };
|
|
2370
2391
|
var typename = store.getFieldValue(objectOrReference, "__typename");
|
|
2392
|
+
var result = {};
|
|
2393
|
+
var missing;
|
|
2371
2394
|
if (this.config.addTypename &&
|
|
2372
2395
|
typeof typename === "string" &&
|
|
2373
2396
|
!policies.rootIdsByTypename[typename]) {
|
|
2374
|
-
|
|
2397
|
+
result = { __typename: typename };
|
|
2375
2398
|
}
|
|
2376
|
-
function
|
|
2377
|
-
return finalResult.missing || (finalResult.missing = []);
|
|
2378
|
-
}
|
|
2379
|
-
function handleMissing(result) {
|
|
2399
|
+
function handleMissing(result, resultName) {
|
|
2380
2400
|
var _a;
|
|
2381
|
-
if (result.missing)
|
|
2382
|
-
|
|
2401
|
+
if (result.missing) {
|
|
2402
|
+
missing = context.merge(missing, (_a = {}, _a[resultName] = result.missing, _a));
|
|
2403
|
+
}
|
|
2383
2404
|
return result.result;
|
|
2384
2405
|
}
|
|
2385
2406
|
var workSet = new Set(selectionSet.selections);
|
|
2386
2407
|
workSet.forEach(function (selection) {
|
|
2387
|
-
var _a;
|
|
2408
|
+
var _a, _b;
|
|
2388
2409
|
if (!shouldInclude(selection, variables))
|
|
2389
2410
|
return;
|
|
2390
2411
|
if (isField(selection)) {
|
|
@@ -2395,12 +2416,13 @@ var StoreReader = (function () {
|
|
|
2395
2416
|
from: objectOrReference,
|
|
2396
2417
|
}, context);
|
|
2397
2418
|
var resultName = resultKeyNameFromField(selection);
|
|
2398
|
-
context.path.push(resultName);
|
|
2399
2419
|
if (fieldValue === void 0) {
|
|
2400
2420
|
if (!addTypenameToDocument.added(selection)) {
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2421
|
+
missing = context.merge(missing, (_a = {},
|
|
2422
|
+
_a[resultName] = "Can't find field '" + selection.name.value + "' on " + (isReference(objectOrReference)
|
|
2423
|
+
? objectOrReference.__ref + " object"
|
|
2424
|
+
: "object " + JSON.stringify(objectOrReference, null, 2)),
|
|
2425
|
+
_a));
|
|
2404
2426
|
}
|
|
2405
2427
|
}
|
|
2406
2428
|
else if (Array.isArray(fieldValue)) {
|
|
@@ -2409,7 +2431,7 @@ var StoreReader = (function () {
|
|
|
2409
2431
|
array: fieldValue,
|
|
2410
2432
|
enclosingRef: enclosingRef,
|
|
2411
2433
|
context: context,
|
|
2412
|
-
}));
|
|
2434
|
+
}), resultName);
|
|
2413
2435
|
}
|
|
2414
2436
|
else if (!selection.selectionSet) {
|
|
2415
2437
|
if (context.canonizeResults) {
|
|
@@ -2422,12 +2444,11 @@ var StoreReader = (function () {
|
|
|
2422
2444
|
objectOrReference: fieldValue,
|
|
2423
2445
|
enclosingRef: isReference(fieldValue) ? fieldValue : enclosingRef,
|
|
2424
2446
|
context: context,
|
|
2425
|
-
}));
|
|
2447
|
+
}), resultName);
|
|
2426
2448
|
}
|
|
2427
2449
|
if (fieldValue !== void 0) {
|
|
2428
|
-
|
|
2450
|
+
result = context.merge(result, (_b = {}, _b[resultName] = fieldValue, _b));
|
|
2429
2451
|
}
|
|
2430
|
-
tsInvariant.invariant(context.path.pop() === resultName);
|
|
2431
2452
|
}
|
|
2432
2453
|
else {
|
|
2433
2454
|
var fragment = getFragmentFromSelection(selection, context.fragmentMap);
|
|
@@ -2436,23 +2457,24 @@ var StoreReader = (function () {
|
|
|
2436
2457
|
}
|
|
2437
2458
|
}
|
|
2438
2459
|
});
|
|
2439
|
-
var
|
|
2440
|
-
|
|
2441
|
-
? this.canon.admit(
|
|
2442
|
-
: maybeDeepFreeze(
|
|
2443
|
-
|
|
2444
|
-
|
|
2460
|
+
var finalResult = { result: result, missing: missing };
|
|
2461
|
+
var frozen = context.canonizeResults
|
|
2462
|
+
? this.canon.admit(finalResult)
|
|
2463
|
+
: maybeDeepFreeze(finalResult);
|
|
2464
|
+
if (frozen.result) {
|
|
2465
|
+
this.knownResults.set(frozen.result, selectionSet);
|
|
2466
|
+
}
|
|
2467
|
+
return frozen;
|
|
2445
2468
|
};
|
|
2446
2469
|
StoreReader.prototype.execSubSelectedArrayImpl = function (_a) {
|
|
2447
2470
|
var _this = this;
|
|
2448
2471
|
var field = _a.field, array = _a.array, enclosingRef = _a.enclosingRef, context = _a.context;
|
|
2449
2472
|
var missing;
|
|
2450
2473
|
function handleMissing(childResult, i) {
|
|
2474
|
+
var _a;
|
|
2451
2475
|
if (childResult.missing) {
|
|
2452
|
-
missing = missing
|
|
2453
|
-
missing.push.apply(missing, childResult.missing);
|
|
2476
|
+
missing = context.merge(missing, (_a = {}, _a[i] = childResult.missing, _a));
|
|
2454
2477
|
}
|
|
2455
|
-
tsInvariant.invariant(context.path.pop() === i);
|
|
2456
2478
|
return childResult.result;
|
|
2457
2479
|
}
|
|
2458
2480
|
if (field.selectionSet) {
|
|
@@ -2462,7 +2484,6 @@ var StoreReader = (function () {
|
|
|
2462
2484
|
if (item === null) {
|
|
2463
2485
|
return null;
|
|
2464
2486
|
}
|
|
2465
|
-
context.path.push(i);
|
|
2466
2487
|
if (Array.isArray(item)) {
|
|
2467
2488
|
return handleMissing(_this.executeSubSelectedArray({
|
|
2468
2489
|
field: field,
|
|
@@ -2482,7 +2503,6 @@ var StoreReader = (function () {
|
|
|
2482
2503
|
if (__DEV__) {
|
|
2483
2504
|
assertSelectionSetForIdValue(context.store, field, item);
|
|
2484
2505
|
}
|
|
2485
|
-
tsInvariant.invariant(context.path.pop() === i);
|
|
2486
2506
|
return item;
|
|
2487
2507
|
});
|
|
2488
2508
|
return {
|
|
@@ -2492,12 +2512,24 @@ var StoreReader = (function () {
|
|
|
2492
2512
|
};
|
|
2493
2513
|
return StoreReader;
|
|
2494
2514
|
}());
|
|
2515
|
+
function firstMissing(tree) {
|
|
2516
|
+
try {
|
|
2517
|
+
JSON.stringify(tree, function (_, value) {
|
|
2518
|
+
if (typeof value === "string")
|
|
2519
|
+
throw value;
|
|
2520
|
+
return value;
|
|
2521
|
+
});
|
|
2522
|
+
}
|
|
2523
|
+
catch (result) {
|
|
2524
|
+
return result;
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2495
2527
|
function assertSelectionSetForIdValue(store, field, fieldValue) {
|
|
2496
2528
|
if (!field.selectionSet) {
|
|
2497
2529
|
var workSet_1 = new Set([fieldValue]);
|
|
2498
2530
|
workSet_1.forEach(function (value) {
|
|
2499
2531
|
if (isNonNullObject(value)) {
|
|
2500
|
-
__DEV__ ? tsInvariant.invariant(!isReference(value), "Missing selection set for object of type " + getTypenameFromStoreObject(store, value) + " returned for query field " + field.name.value) : tsInvariant.invariant(!isReference(value),
|
|
2532
|
+
__DEV__ ? tsInvariant.invariant(!isReference(value), "Missing selection set for object of type " + getTypenameFromStoreObject(store, value) + " returned for query field " + field.name.value) : tsInvariant.invariant(!isReference(value), 5);
|
|
2501
2533
|
Object.values(value).forEach(workSet_1.add, workSet_1);
|
|
2502
2534
|
}
|
|
2503
2535
|
});
|
|
@@ -2536,7 +2568,7 @@ var StoreWriter = (function () {
|
|
|
2536
2568
|
context: context,
|
|
2537
2569
|
});
|
|
2538
2570
|
if (!isReference(ref)) {
|
|
2539
|
-
throw __DEV__ ? new tsInvariant.InvariantError("Could not identify object " + JSON.stringify(result)) : new tsInvariant.InvariantError(
|
|
2571
|
+
throw __DEV__ ? new tsInvariant.InvariantError("Could not identify object " + JSON.stringify(result)) : new tsInvariant.InvariantError(6);
|
|
2540
2572
|
}
|
|
2541
2573
|
context.incomingById.forEach(function (_a, dataId) {
|
|
2542
2574
|
var fields = _a.fields, mergeTree = _a.mergeTree, selections = _a.selections;
|
|
@@ -3623,6 +3655,7 @@ var InMemoryCache = (function (_super) {
|
|
|
3623
3655
|
InMemoryCache.prototype.batch = function (options) {
|
|
3624
3656
|
var _this = this;
|
|
3625
3657
|
var update = options.update, _a = options.optimistic, optimistic = _a === void 0 ? true : _a, removeOptimistic = options.removeOptimistic, onWatchUpdated = options.onWatchUpdated;
|
|
3658
|
+
var updateResult;
|
|
3626
3659
|
var perform = function (layer) {
|
|
3627
3660
|
var _a = _this, data = _a.data, optimisticData = _a.optimisticData;
|
|
3628
3661
|
++_this.txCount;
|
|
@@ -3630,7 +3663,7 @@ var InMemoryCache = (function (_super) {
|
|
|
3630
3663
|
_this.data = _this.optimisticData = layer;
|
|
3631
3664
|
}
|
|
3632
3665
|
try {
|
|
3633
|
-
update(_this);
|
|
3666
|
+
return updateResult = update(_this);
|
|
3634
3667
|
}
|
|
3635
3668
|
finally {
|
|
3636
3669
|
--_this.txCount;
|
|
@@ -3672,6 +3705,7 @@ var InMemoryCache = (function (_super) {
|
|
|
3672
3705
|
else {
|
|
3673
3706
|
this.broadcastWatches(options);
|
|
3674
3707
|
}
|
|
3708
|
+
return updateResult;
|
|
3675
3709
|
};
|
|
3676
3710
|
InMemoryCache.prototype.performTransaction = function (update, optimisticId) {
|
|
3677
3711
|
return this.batch({
|
|
@@ -4079,7 +4113,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4079
4113
|
pollingInfo.interval === pollInterval) {
|
|
4080
4114
|
return;
|
|
4081
4115
|
}
|
|
4082
|
-
__DEV__ ? tsInvariant.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : tsInvariant.invariant(pollInterval,
|
|
4116
|
+
__DEV__ ? tsInvariant.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : tsInvariant.invariant(pollInterval, 10);
|
|
4083
4117
|
var info = pollingInfo || (this.pollingInfo = {});
|
|
4084
4118
|
info.interval = pollInterval;
|
|
4085
4119
|
var maybeFetch = function () {
|
|
@@ -4194,8 +4228,8 @@ function defaultSubscriptionObserverErrorCallback(error) {
|
|
|
4194
4228
|
__DEV__ && tsInvariant.invariant.error('Unhandled error', error.message, error.stack);
|
|
4195
4229
|
}
|
|
4196
4230
|
function logMissingFieldErrors(missing) {
|
|
4197
|
-
if (__DEV__ &&
|
|
4198
|
-
__DEV__ && tsInvariant.invariant.debug("Missing cache result fields: " +
|
|
4231
|
+
if (__DEV__ && missing) {
|
|
4232
|
+
__DEV__ && tsInvariant.invariant.debug("Missing cache result fields: " + JSON.stringify(missing), missing);
|
|
4199
4233
|
}
|
|
4200
4234
|
}
|
|
4201
4235
|
function applyNextFetchPolicy(options) {
|
|
@@ -4376,7 +4410,7 @@ var LocalState = (function () {
|
|
|
4376
4410
|
}
|
|
4377
4411
|
else {
|
|
4378
4412
|
fragment = fragmentMap[selection.name.value];
|
|
4379
|
-
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value) : tsInvariant.invariant(fragment,
|
|
4413
|
+
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value) : tsInvariant.invariant(fragment, 9);
|
|
4380
4414
|
}
|
|
4381
4415
|
if (fragment && fragment.typeCondition) {
|
|
4382
4416
|
typeCondition = fragment.typeCondition.name.value;
|
|
@@ -4762,7 +4796,7 @@ var QueryManager = (function () {
|
|
|
4762
4796
|
this.queries.forEach(function (_info, queryId) {
|
|
4763
4797
|
_this.stopQueryNoBroadcast(queryId);
|
|
4764
4798
|
});
|
|
4765
|
-
this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('QueryManager stopped while query was in flight') : new tsInvariant.InvariantError(
|
|
4799
|
+
this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('QueryManager stopped while query was in flight') : new tsInvariant.InvariantError(11));
|
|
4766
4800
|
};
|
|
4767
4801
|
QueryManager.prototype.cancelPendingFetches = function (error) {
|
|
4768
4802
|
this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
|
|
@@ -4775,10 +4809,10 @@ var QueryManager = (function () {
|
|
|
4775
4809
|
return tslib.__generator(this, function (_f) {
|
|
4776
4810
|
switch (_f.label) {
|
|
4777
4811
|
case 0:
|
|
4778
|
-
__DEV__ ? tsInvariant.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : tsInvariant.invariant(mutation,
|
|
4812
|
+
__DEV__ ? tsInvariant.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : tsInvariant.invariant(mutation, 12);
|
|
4779
4813
|
__DEV__ ? tsInvariant.invariant(fetchPolicy === 'network-only' ||
|
|
4780
4814
|
fetchPolicy === 'no-cache', "Mutations support only 'network-only' or 'no-cache' fetchPolicy strings. The default `network-only` behavior automatically writes mutation results to the cache. Passing `no-cache` skips the cache write.") : tsInvariant.invariant(fetchPolicy === 'network-only' ||
|
|
4781
|
-
fetchPolicy === 'no-cache',
|
|
4815
|
+
fetchPolicy === 'no-cache', 13);
|
|
4782
4816
|
mutationId = this.generateMutationId();
|
|
4783
4817
|
mutation = this.transform(mutation).document;
|
|
4784
4818
|
variables = this.getVariables(mutation, variables);
|
|
@@ -5063,10 +5097,10 @@ var QueryManager = (function () {
|
|
|
5063
5097
|
var _this = this;
|
|
5064
5098
|
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
5065
5099
|
__DEV__ ? tsInvariant.invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
|
|
5066
|
-
'in the query option.') : tsInvariant.invariant(options.query,
|
|
5067
|
-
__DEV__ ? tsInvariant.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : tsInvariant.invariant(options.query.kind === 'Document',
|
|
5068
|
-
__DEV__ ? tsInvariant.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : tsInvariant.invariant(!options.returnPartialData,
|
|
5069
|
-
__DEV__ ? tsInvariant.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : tsInvariant.invariant(!options.pollInterval,
|
|
5100
|
+
'in the query option.') : tsInvariant.invariant(options.query, 14);
|
|
5101
|
+
__DEV__ ? tsInvariant.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : tsInvariant.invariant(options.query.kind === 'Document', 15);
|
|
5102
|
+
__DEV__ ? tsInvariant.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : tsInvariant.invariant(!options.returnPartialData, 16);
|
|
5103
|
+
__DEV__ ? tsInvariant.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : tsInvariant.invariant(!options.pollInterval, 17);
|
|
5070
5104
|
return this.fetchQuery(queryId, options).finally(function () { return _this.stopQuery(queryId); });
|
|
5071
5105
|
};
|
|
5072
5106
|
QueryManager.prototype.generateQueryId = function () {
|
|
@@ -5088,7 +5122,7 @@ var QueryManager = (function () {
|
|
|
5088
5122
|
queryInfo.stop();
|
|
5089
5123
|
};
|
|
5090
5124
|
QueryManager.prototype.clearStore = function () {
|
|
5091
|
-
this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('Store reset while query was in flight (not completed in link chain)') : new tsInvariant.InvariantError(
|
|
5125
|
+
this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('Store reset while query was in flight (not completed in link chain)') : new tsInvariant.InvariantError(18));
|
|
5092
5126
|
this.queries.forEach(function (queryInfo) {
|
|
5093
5127
|
if (queryInfo.observableQuery) {
|
|
5094
5128
|
queryInfo.networkStatus = exports.NetworkStatus.loading;
|
|
@@ -5581,7 +5615,7 @@ var ApolloClient = (function () {
|
|
|
5581
5615
|
if (!cache) {
|
|
5582
5616
|
throw __DEV__ ? new tsInvariant.InvariantError("To initialize Apollo Client, you must specify a 'cache' property " +
|
|
5583
5617
|
"in the options object. \n" +
|
|
5584
|
-
"For more information, please visit: https://go.apollo.dev/c/docs") : new tsInvariant.InvariantError(
|
|
5618
|
+
"For more information, please visit: https://go.apollo.dev/c/docs") : new tsInvariant.InvariantError(7);
|
|
5585
5619
|
}
|
|
5586
5620
|
this.link = link;
|
|
5587
5621
|
this.cache = cache;
|
|
@@ -5677,7 +5711,7 @@ var ApolloClient = (function () {
|
|
|
5677
5711
|
__DEV__ ? tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 'The cache-and-network fetchPolicy does not work with client.query, because ' +
|
|
5678
5712
|
'client.query can only return a single result. Please use client.watchQuery ' +
|
|
5679
5713
|
'to receive multiple results from the cache and the network, or consider ' +
|
|
5680
|
-
'using a different fetchPolicy, such as cache-first or network-only.') : tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network',
|
|
5714
|
+
'using a different fetchPolicy, such as cache-first or network-only.') : tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 8);
|
|
5681
5715
|
if (this.disableNetworkFetches && options.fetchPolicy === 'network-only') {
|
|
5682
5716
|
options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: 'cache-first' });
|
|
5683
5717
|
}
|
|
@@ -5788,13 +5822,19 @@ var ApolloClient = (function () {
|
|
|
5788
5822
|
return ApolloClient;
|
|
5789
5823
|
}());
|
|
5790
5824
|
|
|
5791
|
-
var
|
|
5825
|
+
var contextKey = canUseSymbol
|
|
5826
|
+
? Symbol.for('__APOLLO_CONTEXT__')
|
|
5827
|
+
: '__APOLLO_CONTEXT__';
|
|
5792
5828
|
function getApolloContext() {
|
|
5793
|
-
var context =
|
|
5829
|
+
var context = React__namespace.createContext[contextKey];
|
|
5794
5830
|
if (!context) {
|
|
5795
|
-
|
|
5831
|
+
Object.defineProperty(React__namespace.createContext, contextKey, {
|
|
5832
|
+
value: context = React__namespace.createContext({}),
|
|
5833
|
+
enumerable: false,
|
|
5834
|
+
writable: false,
|
|
5835
|
+
configurable: true,
|
|
5836
|
+
});
|
|
5796
5837
|
context.displayName = 'ApolloContext';
|
|
5797
|
-
cache$1.set(React__namespace.createContext, context);
|
|
5798
5838
|
}
|
|
5799
5839
|
return context;
|
|
5800
5840
|
}
|
|
@@ -5803,7 +5843,7 @@ var ApolloConsumer = function (props) {
|
|
|
5803
5843
|
var ApolloContext = getApolloContext();
|
|
5804
5844
|
return React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
|
|
5805
5845
|
__DEV__ ? tsInvariant.invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
|
|
5806
|
-
'Wrap the root component in an <ApolloProvider>.') : tsInvariant.invariant(context && context.client,
|
|
5846
|
+
'Wrap the root component in an <ApolloProvider>.') : tsInvariant.invariant(context && context.client, 25);
|
|
5807
5847
|
return props.children(context.client);
|
|
5808
5848
|
});
|
|
5809
5849
|
};
|
|
@@ -5817,7 +5857,7 @@ var ApolloProvider = function (_a) {
|
|
|
5817
5857
|
context = Object.assign({}, context, { client: client });
|
|
5818
5858
|
}
|
|
5819
5859
|
__DEV__ ? tsInvariant.invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
|
|
5820
|
-
'sure you pass in your client via the "client" prop.') : tsInvariant.invariant(context.client,
|
|
5860
|
+
'sure you pass in your client via the "client" prop.') : tsInvariant.invariant(context.client, 26);
|
|
5821
5861
|
return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
|
|
5822
5862
|
});
|
|
5823
5863
|
};
|
|
@@ -5827,7 +5867,7 @@ function useApolloClient(override) {
|
|
|
5827
5867
|
var client = override || context.client;
|
|
5828
5868
|
__DEV__ ? tsInvariant.invariant(!!client, 'Could not find "client" in the context or passed in as an option. ' +
|
|
5829
5869
|
'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient' +
|
|
5830
|
-
'ApolloClient instance in via options.') : tsInvariant.invariant(!!client,
|
|
5870
|
+
'ApolloClient instance in via options.') : tsInvariant.invariant(!!client, 29);
|
|
5831
5871
|
return client;
|
|
5832
5872
|
}
|
|
5833
5873
|
|
|
@@ -5860,7 +5900,7 @@ function parser(document) {
|
|
|
5860
5900
|
var variables, type, name;
|
|
5861
5901
|
__DEV__ ? tsInvariant.invariant(!!document && !!document.kind, "Argument of " + document + " passed to parser was not a valid GraphQL " +
|
|
5862
5902
|
"DocumentNode. You may need to use 'graphql-tag' or another method " +
|
|
5863
|
-
"to convert your operation into a document") : tsInvariant.invariant(!!document && !!document.kind,
|
|
5903
|
+
"to convert your operation into a document") : tsInvariant.invariant(!!document && !!document.kind, 30);
|
|
5864
5904
|
var fragments = document.definitions.filter(function (x) { return x.kind === 'FragmentDefinition'; });
|
|
5865
5905
|
var queries = document.definitions.filter(function (x) {
|
|
5866
5906
|
return x.kind === 'OperationDefinition' && x.operation === 'query';
|
|
@@ -5874,11 +5914,11 @@ function parser(document) {
|
|
|
5874
5914
|
__DEV__ ? tsInvariant.invariant(!fragments.length ||
|
|
5875
5915
|
(queries.length || mutations.length || subscriptions.length), "Passing only a fragment to 'graphql' is not yet supported. " +
|
|
5876
5916
|
"You must include a query, subscription or mutation as well") : tsInvariant.invariant(!fragments.length ||
|
|
5877
|
-
(queries.length || mutations.length || subscriptions.length),
|
|
5917
|
+
(queries.length || mutations.length || subscriptions.length), 31);
|
|
5878
5918
|
__DEV__ ? tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1, "react-apollo only supports a query, subscription, or a mutation per HOC. " +
|
|
5879
5919
|
(document + " had " + queries.length + " queries, " + subscriptions.length + " ") +
|
|
5880
5920
|
("subscriptions and " + mutations.length + " mutations. ") +
|
|
5881
|
-
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1,
|
|
5921
|
+
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1, 32);
|
|
5882
5922
|
type = queries.length ? exports.DocumentType.Query : exports.DocumentType.Mutation;
|
|
5883
5923
|
if (!queries.length && !mutations.length)
|
|
5884
5924
|
type = exports.DocumentType.Subscription;
|
|
@@ -5889,7 +5929,7 @@ function parser(document) {
|
|
|
5889
5929
|
: subscriptions;
|
|
5890
5930
|
__DEV__ ? tsInvariant.invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. " + document + " had " +
|
|
5891
5931
|
(definitions.length + " definitions. ") +
|
|
5892
|
-
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(definitions.length === 1,
|
|
5932
|
+
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(definitions.length === 1, 33);
|
|
5893
5933
|
var definition = definitions[0];
|
|
5894
5934
|
variables = definition.variableDefinitions || [];
|
|
5895
5935
|
if (definition.name && definition.name.kind === 'Name') {
|
|
@@ -5907,7 +5947,7 @@ function verifyDocumentType(document, type) {
|
|
|
5907
5947
|
var requiredOperationName = operationName(type);
|
|
5908
5948
|
var usedOperationName = operationName(operation.type);
|
|
5909
5949
|
__DEV__ ? tsInvariant.invariant(operation.type === type, "Running a " + requiredOperationName + " requires a graphql " +
|
|
5910
|
-
(requiredOperationName + ", but a " + usedOperationName + " was used instead.")) : tsInvariant.invariant(operation.type === type,
|
|
5950
|
+
(requiredOperationName + ", but a " + usedOperationName + " was used instead.")) : tsInvariant.invariant(operation.type === type, 34);
|
|
5911
5951
|
}
|
|
5912
5952
|
|
|
5913
5953
|
function useQuery(query, options) {
|