@apollo/client 3.8.0-alpha.8 → 3.8.0-alpha.9
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 +44 -17
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +14 -3
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +14 -3
- package/cache/core/types/DataProxy.d.ts +3 -2
- package/cache/core/types/DataProxy.d.ts.map +1 -1
- package/cache/core/types/DataProxy.js.map +1 -1
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +14 -3
- package/cache/inmemory/policies.js.map +1 -1
- package/core/ApolloClient.d.ts +3 -3
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +10 -4
- package/core/ApolloClient.js.map +1 -1
- package/core/core.cjs +11 -5
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +11 -5
- package/invariantErrorCodes.js +1 -1
- package/package.json +10 -11
- package/react/hooks/hooks.cjs +12 -6
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +12 -6
- package/react/hooks/useMutation.d.ts.map +1 -1
- package/react/hooks/useMutation.js +2 -1
- package/react/hooks/useMutation.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/useSuspenseQuery.d.ts.map +1 -1
- package/react/hooks/useSuspenseQuery.js +9 -4
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/testing/core/itAsync.js.map +1 -1
- package/utilities/graphql/getFromAST.d.ts.map +1 -1
- package/utilities/graphql/getFromAST.js +7 -3
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/utilities.cjs +7 -3
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +7 -3
- package/version.js +1 -1
package/apollo-client.cjs
CHANGED
|
@@ -398,17 +398,21 @@ function checkDocument(doc) {
|
|
|
398
398
|
}
|
|
399
399
|
function getOperationDefinition(doc) {
|
|
400
400
|
checkDocument(doc);
|
|
401
|
-
return doc.definitions.filter(function (definition) {
|
|
401
|
+
return doc.definitions.filter(function (definition) {
|
|
402
|
+
return definition.kind === 'OperationDefinition';
|
|
403
|
+
})[0];
|
|
402
404
|
}
|
|
403
405
|
function getOperationName(doc) {
|
|
404
406
|
return (doc.definitions
|
|
405
407
|
.filter(function (definition) {
|
|
406
|
-
return definition.kind === 'OperationDefinition' && definition.name;
|
|
408
|
+
return definition.kind === 'OperationDefinition' && !!definition.name;
|
|
407
409
|
})
|
|
408
410
|
.map(function (x) { return x.name.value; })[0] || null);
|
|
409
411
|
}
|
|
410
412
|
function getFragmentDefinitions(doc) {
|
|
411
|
-
return doc.definitions.filter(function (definition) {
|
|
413
|
+
return doc.definitions.filter(function (definition) {
|
|
414
|
+
return definition.kind === 'FragmentDefinition';
|
|
415
|
+
});
|
|
412
416
|
}
|
|
413
417
|
function getQueryDefinition(doc) {
|
|
414
418
|
var queryDef = getOperationDefinition(doc);
|
|
@@ -1391,7 +1395,7 @@ var concat = ApolloLink.concat;
|
|
|
1391
1395
|
|
|
1392
1396
|
var execute = ApolloLink.execute;
|
|
1393
1397
|
|
|
1394
|
-
var version = '3.8.0-alpha.
|
|
1398
|
+
var version = '3.8.0-alpha.9';
|
|
1395
1399
|
|
|
1396
1400
|
function asyncIterator(source) {
|
|
1397
1401
|
var _a;
|
|
@@ -3317,9 +3321,20 @@ var Policies = (function () {
|
|
|
3317
3321
|
if (!hasOwn.call(this.typePolicies, typename)) {
|
|
3318
3322
|
var policy_1 = this.typePolicies[typename] = Object.create(null);
|
|
3319
3323
|
policy_1.fields = Object.create(null);
|
|
3320
|
-
var
|
|
3321
|
-
if (
|
|
3322
|
-
|
|
3324
|
+
var supertypes_1 = this.supertypeMap.get(typename);
|
|
3325
|
+
if (!supertypes_1 && this.fuzzySubtypes.size) {
|
|
3326
|
+
supertypes_1 = this.getSupertypeSet(typename, true);
|
|
3327
|
+
this.fuzzySubtypes.forEach(function (regExp, fuzzy) {
|
|
3328
|
+
if (regExp.test(typename)) {
|
|
3329
|
+
var fuzzySupertypes = _this.supertypeMap.get(fuzzy);
|
|
3330
|
+
if (fuzzySupertypes) {
|
|
3331
|
+
fuzzySupertypes.forEach(function (supertype) { return supertypes_1.add(supertype); });
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
});
|
|
3335
|
+
}
|
|
3336
|
+
if (supertypes_1 && supertypes_1.size) {
|
|
3337
|
+
supertypes_1.forEach(function (supertype) {
|
|
3323
3338
|
var _a = _this.getTypePolicy(supertype), fields = _a.fields, rest = tslib.__rest(_a, ["fields"]);
|
|
3324
3339
|
Object.assign(policy_1, rest);
|
|
3325
3340
|
Object.assign(policy_1.fields, fields);
|
|
@@ -6409,12 +6424,18 @@ var ApolloClient = (function () {
|
|
|
6409
6424
|
return this.cache.readFragment(options, optimistic);
|
|
6410
6425
|
};
|
|
6411
6426
|
ApolloClient.prototype.writeQuery = function (options) {
|
|
6412
|
-
this.cache.writeQuery(options);
|
|
6413
|
-
|
|
6427
|
+
var ref = this.cache.writeQuery(options);
|
|
6428
|
+
if (options.broadcast !== false) {
|
|
6429
|
+
this.queryManager.broadcastQueries();
|
|
6430
|
+
}
|
|
6431
|
+
return ref;
|
|
6414
6432
|
};
|
|
6415
6433
|
ApolloClient.prototype.writeFragment = function (options) {
|
|
6416
|
-
this.cache.writeFragment(options);
|
|
6417
|
-
|
|
6434
|
+
var ref = this.cache.writeFragment(options);
|
|
6435
|
+
if (options.broadcast !== false) {
|
|
6436
|
+
this.queryManager.broadcastQueries();
|
|
6437
|
+
}
|
|
6438
|
+
return ref;
|
|
6418
6439
|
};
|
|
6419
6440
|
ApolloClient.prototype.__actionHookForDevTools = function (cb) {
|
|
6420
6441
|
this.devToolsHookCb = cb;
|
|
@@ -6800,7 +6821,7 @@ var InternalState = (function () {
|
|
|
6800
6821
|
}
|
|
6801
6822
|
};
|
|
6802
6823
|
var subscription = obsQuery.subscribe(onNext, onError);
|
|
6803
|
-
return function () { return subscription.unsubscribe(); };
|
|
6824
|
+
return function () { return setTimeout(function () { return subscription.unsubscribe(); }); };
|
|
6804
6825
|
}, [
|
|
6805
6826
|
obsQuery,
|
|
6806
6827
|
this.renderPromises,
|
|
@@ -7067,8 +7088,9 @@ function useMutation(mutation, options) {
|
|
|
7067
7088
|
}
|
|
7068
7089
|
var execute = React.useCallback(function (executeOptions) {
|
|
7069
7090
|
if (executeOptions === void 0) { executeOptions = {}; }
|
|
7070
|
-
var _a = ref.current,
|
|
7091
|
+
var _a = ref.current, options = _a.options, mutation = _a.mutation;
|
|
7071
7092
|
var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
|
|
7093
|
+
var client = executeOptions.client || ref.current.client;
|
|
7072
7094
|
if (!ref.current.result.loading && !baseOptions.ignoreResults && ref.current.isMounted) {
|
|
7073
7095
|
setResult(ref.current.result = {
|
|
7074
7096
|
loading: true,
|
|
@@ -7481,6 +7503,7 @@ function useIsDeferred(query) {
|
|
|
7481
7503
|
function useObservableQueryResult(observable) {
|
|
7482
7504
|
var resultRef = React.useRef();
|
|
7483
7505
|
var isMountedRef = React.useRef(false);
|
|
7506
|
+
var subscribeTimeoutRef = React.useRef();
|
|
7484
7507
|
if (!resultRef.current) {
|
|
7485
7508
|
resultRef.current = observable.getCurrentResult();
|
|
7486
7509
|
}
|
|
@@ -7491,6 +7514,7 @@ function useObservableQueryResult(observable) {
|
|
|
7491
7514
|
};
|
|
7492
7515
|
}, []);
|
|
7493
7516
|
return useSyncExternalStore(React.useCallback(function (forceUpdate) {
|
|
7517
|
+
clearTimeout(subscribeTimeoutRef.current);
|
|
7494
7518
|
function handleUpdate() {
|
|
7495
7519
|
var previousResult = resultRef.current;
|
|
7496
7520
|
var result = observable.getCurrentResult();
|
|
@@ -7504,12 +7528,15 @@ function useObservableQueryResult(observable) {
|
|
|
7504
7528
|
forceUpdate();
|
|
7505
7529
|
}
|
|
7506
7530
|
}
|
|
7507
|
-
var subscription
|
|
7508
|
-
|
|
7509
|
-
|
|
7531
|
+
var subscription;
|
|
7532
|
+
subscribeTimeoutRef.current = setTimeout(function () {
|
|
7533
|
+
subscription = observable.subscribe({
|
|
7534
|
+
next: handleUpdate,
|
|
7535
|
+
error: handleUpdate,
|
|
7536
|
+
});
|
|
7510
7537
|
});
|
|
7511
7538
|
return function () {
|
|
7512
|
-
subscription.unsubscribe();
|
|
7539
|
+
subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
|
|
7513
7540
|
};
|
|
7514
7541
|
}, [observable]), function () { return resultRef.current; }, function () { return resultRef.current; });
|
|
7515
7542
|
}
|