@apollo/client 3.9.0-alpha.2 → 3.9.0-alpha.3
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 +126 -77
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +46 -11
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +46 -11
- package/cache/core/types/common.d.ts +2 -2
- package/cache/core/types/common.d.ts.map +1 -1
- package/cache/core/types/common.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts.map +1 -1
- package/cache/inmemory/entityStore.js +35 -0
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.js +4 -4
- package/cache/inmemory/readFromStore.js +2 -2
- package/cache/inmemory/writeToStore.js +4 -4
- package/core/ApolloClient.d.ts +2 -0
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +12 -4
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.js +2 -2
- package/core/ObservableQuery.js +5 -5
- package/core/QueryManager.d.ts +4 -2
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +13 -12
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +32 -23
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +32 -23
- package/dev/dev.cjs +98 -83
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +98 -83
- package/dev/loadErrorMessageHandler.js +1 -1
- package/dev/loadErrorMessageHandler.js.map +1 -1
- package/invariantErrorCodes.js +96 -81
- package/link/core/ApolloLink.js +2 -2
- package/link/core/core.cjs +2 -2
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +2 -2
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.js +1 -1
- package/link/http/http.cjs +3 -3
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +3 -3
- 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/toPromise.js +1 -1
- package/link/utils/utils.cjs +2 -2
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +2 -2
- package/link/utils/validateOperation.js +1 -1
- package/package.json +26 -25
- package/react/cache/QueryReference.d.ts.map +1 -1
- package/react/cache/QueryReference.js +7 -2
- package/react/cache/QueryReference.js.map +1 -1
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/context.cjs +3 -3
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +3 -3
- 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 +15 -10
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +15 -10
- package/react/hooks/index.d.ts +1 -0
- package/react/hooks/index.d.ts.map +1 -1
- package/react/hooks/index.js.map +1 -1
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useQuery.js +1 -1
- package/react/hooks/useReadQuery.d.ts +7 -4
- package/react/hooks/useReadQuery.d.ts.map +1 -1
- package/react/hooks/useReadQuery.js +1 -1
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.js +2 -2
- package/react/hooks/useSuspenseQuery.js +2 -2
- package/react/hooks/useSyncExternalStore.js +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/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/react/MockedProvider.d.ts +1 -0
- package/testing/react/MockedProvider.d.ts.map +1 -1
- package/testing/react/MockedProvider.js +2 -1
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +2 -1
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +2 -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/graphql/DocumentTransform.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.d.ts +5 -0
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.js +2 -2
- package/utilities/index.d.ts +1 -1
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js.map +1 -1
- package/utilities/subscriptions/relay/index.d.ts +6 -0
- package/utilities/subscriptions/relay/index.d.ts.map +1 -0
- package/utilities/subscriptions/relay/index.js +43 -0
- package/utilities/subscriptions/relay/index.js.map +1 -0
- package/utilities/subscriptions/relay/package.json +8 -0
- package/utilities/subscriptions/relay/relay.cjs +368 -0
- package/utilities/subscriptions/relay/relay.cjs.map +1 -0
- package/utilities/subscriptions/relay/relay.cjs.native.js +368 -0
- package/utilities/subscriptions/shared.d.ts +9 -0
- package/utilities/subscriptions/shared.d.ts.map +1 -0
- package/utilities/subscriptions/shared.js +7 -0
- package/utilities/subscriptions/shared.js.map +1 -0
- package/utilities/subscriptions/urql/index.d.ts +7 -0
- package/utilities/subscriptions/urql/index.d.ts.map +1 -0
- package/utilities/subscriptions/urql/index.js +40 -0
- package/utilities/subscriptions/urql/index.js.map +1 -0
- package/utilities/subscriptions/urql/package.json +8 -0
- package/utilities/subscriptions/urql/urql.cjs +364 -0
- package/utilities/subscriptions/urql/urql.cjs.map +1 -0
- package/utilities/subscriptions/urql/urql.cjs.native.js +364 -0
- package/utilities/utilities.cjs +19 -19
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +19 -19
- package/version.js +1 -1
package/core/core.cjs
CHANGED
|
@@ -19,7 +19,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
19
19
|
|
|
20
20
|
var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
21
21
|
|
|
22
|
-
var version = "3.9.0-alpha.
|
|
22
|
+
var version = "3.9.0-alpha.3";
|
|
23
23
|
|
|
24
24
|
function isNonNullObject(obj) {
|
|
25
25
|
return obj !== null && typeof obj === "object";
|
|
@@ -369,7 +369,7 @@ var ObservableQuery = (function (_super) {
|
|
|
369
369
|
var vars = queryDef.variableDefinitions;
|
|
370
370
|
if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
|
|
371
371
|
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
372
|
-
|
|
372
|
+
20,
|
|
373
373
|
variables,
|
|
374
374
|
((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || queryDef
|
|
375
375
|
);
|
|
@@ -467,7 +467,7 @@ var ObservableQuery = (function (_super) {
|
|
|
467
467
|
options.onError(err);
|
|
468
468
|
return;
|
|
469
469
|
}
|
|
470
|
-
globalThis.__DEV__ !== false && globals.invariant.error(
|
|
470
|
+
globalThis.__DEV__ !== false && globals.invariant.error(21, err);
|
|
471
471
|
},
|
|
472
472
|
});
|
|
473
473
|
this.subscriptions.add(subscription);
|
|
@@ -566,7 +566,7 @@ var ObservableQuery = (function (_super) {
|
|
|
566
566
|
if (pollingInfo && pollingInfo.interval === pollInterval) {
|
|
567
567
|
return;
|
|
568
568
|
}
|
|
569
|
-
globals.invariant(pollInterval,
|
|
569
|
+
globals.invariant(pollInterval, 22);
|
|
570
570
|
var info = pollingInfo || (this.pollingInfo = {});
|
|
571
571
|
info.interval = pollInterval;
|
|
572
572
|
var maybeFetch = function () {
|
|
@@ -731,11 +731,11 @@ function reobserveCacheFirst(obsQuery) {
|
|
|
731
731
|
return obsQuery.reobserve();
|
|
732
732
|
}
|
|
733
733
|
function defaultSubscriptionObserverErrorCallback(error) {
|
|
734
|
-
globalThis.__DEV__ !== false && globals.invariant.error(
|
|
734
|
+
globalThis.__DEV__ !== false && globals.invariant.error(23, error.message, error.stack);
|
|
735
735
|
}
|
|
736
736
|
function logMissingFieldErrors(missing) {
|
|
737
737
|
if (globalThis.__DEV__ !== false && missing) {
|
|
738
|
-
globalThis.__DEV__ !== false && globals.invariant.debug(
|
|
738
|
+
globalThis.__DEV__ !== false && globals.invariant.debug(24, missing);
|
|
739
739
|
}
|
|
740
740
|
}
|
|
741
741
|
function skipCacheDataFor(fetchPolicy) {
|
|
@@ -920,7 +920,7 @@ var LocalState = (function () {
|
|
|
920
920
|
}
|
|
921
921
|
else {
|
|
922
922
|
fragment = fragmentMap[selection.name.value];
|
|
923
|
-
globals.invariant(fragment,
|
|
923
|
+
globals.invariant(fragment, 18, selection.name.value);
|
|
924
924
|
}
|
|
925
925
|
if (fragment && fragment.typeCondition) {
|
|
926
926
|
typeCondition = fragment.typeCondition.name.value;
|
|
@@ -1033,7 +1033,7 @@ var LocalState = (function () {
|
|
|
1033
1033
|
},
|
|
1034
1034
|
FragmentSpread: function (spread, _, __, ___, ancestors) {
|
|
1035
1035
|
var fragment = fragmentMap[spread.name.value];
|
|
1036
|
-
globals.invariant(fragment,
|
|
1036
|
+
globals.invariant(fragment, 19, spread.name.value);
|
|
1037
1037
|
var fragmentSelections = collectByDefinition(fragment);
|
|
1038
1038
|
if (fragmentSelections.size > 0) {
|
|
1039
1039
|
ancestors.forEach(function (node) {
|
|
@@ -1331,7 +1331,7 @@ var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
|
1331
1331
|
var QueryManager = (function () {
|
|
1332
1332
|
function QueryManager(_a) {
|
|
1333
1333
|
var _this = this;
|
|
1334
|
-
var cache = _a.cache, link = _a.link, defaultOptions = _a.defaultOptions, documentTransform = _a.documentTransform, _b = _a.queryDeduplication, queryDeduplication = _b === void 0 ? false : _b, onBroadcast = _a.onBroadcast, _c = _a.ssrMode, ssrMode = _c === void 0 ? false : _c, _d = _a.clientAwareness, clientAwareness = _d === void 0 ? {} : _d, localState = _a.localState, _e = _a.assumeImmutableResults, assumeImmutableResults = _e === void 0 ? !!cache.assumeImmutableResults : _e;
|
|
1334
|
+
var cache = _a.cache, link = _a.link, defaultOptions = _a.defaultOptions, documentTransform = _a.documentTransform, _b = _a.queryDeduplication, queryDeduplication = _b === void 0 ? false : _b, onBroadcast = _a.onBroadcast, _c = _a.ssrMode, ssrMode = _c === void 0 ? false : _c, _d = _a.clientAwareness, clientAwareness = _d === void 0 ? {} : _d, localState = _a.localState, _e = _a.assumeImmutableResults, assumeImmutableResults = _e === void 0 ? !!cache.assumeImmutableResults : _e, defaultContext = _a.defaultContext;
|
|
1335
1335
|
this.clientAwareness = {};
|
|
1336
1336
|
this.queries = new Map();
|
|
1337
1337
|
this.fetchCancelFns = new Map();
|
|
@@ -1354,6 +1354,7 @@ var QueryManager = (function () {
|
|
|
1354
1354
|
.concat(documentTransform)
|
|
1355
1355
|
.concat(defaultDocumentTransform)
|
|
1356
1356
|
: defaultDocumentTransform;
|
|
1357
|
+
this.defaultContext = defaultContext || Object.create(null);
|
|
1357
1358
|
if ((this.onBroadcast = onBroadcast)) {
|
|
1358
1359
|
this.mutationStore = Object.create(null);
|
|
1359
1360
|
}
|
|
@@ -1363,7 +1364,7 @@ var QueryManager = (function () {
|
|
|
1363
1364
|
this.queries.forEach(function (_info, queryId) {
|
|
1364
1365
|
_this.stopQueryNoBroadcast(queryId);
|
|
1365
1366
|
});
|
|
1366
|
-
this.cancelPendingFetches(globals.newInvariantError(
|
|
1367
|
+
this.cancelPendingFetches(globals.newInvariantError(25));
|
|
1367
1368
|
};
|
|
1368
1369
|
QueryManager.prototype.cancelPendingFetches = function (error) {
|
|
1369
1370
|
this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
|
|
@@ -1377,8 +1378,8 @@ var QueryManager = (function () {
|
|
|
1377
1378
|
return tslib.__generator(this, function (_h) {
|
|
1378
1379
|
switch (_h.label) {
|
|
1379
1380
|
case 0:
|
|
1380
|
-
globals.invariant(mutation,
|
|
1381
|
-
globals.invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache",
|
|
1381
|
+
globals.invariant(mutation, 26);
|
|
1382
|
+
globals.invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 27);
|
|
1382
1383
|
mutationId = this.generateMutationId();
|
|
1383
1384
|
mutation = this.cache.transformForLink(this.transform(mutation));
|
|
1384
1385
|
hasClientExports = this.getDocumentInfo(mutation).hasClientExports;
|
|
@@ -1699,10 +1700,10 @@ var QueryManager = (function () {
|
|
|
1699
1700
|
QueryManager.prototype.query = function (options, queryId) {
|
|
1700
1701
|
var _this = this;
|
|
1701
1702
|
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
1702
|
-
globals.invariant(options.query,
|
|
1703
|
-
globals.invariant(options.query.kind === "Document",
|
|
1704
|
-
globals.invariant(!options.returnPartialData,
|
|
1705
|
-
globals.invariant(!options.pollInterval,
|
|
1703
|
+
globals.invariant(options.query, 28);
|
|
1704
|
+
globals.invariant(options.query.kind === "Document", 29);
|
|
1705
|
+
globals.invariant(!options.returnPartialData, 30);
|
|
1706
|
+
globals.invariant(!options.pollInterval, 31);
|
|
1706
1707
|
return this.fetchQuery(queryId, tslib.__assign(tslib.__assign({}, options), { query: this.transform(options.query) })).finally(function () { return _this.stopQuery(queryId); });
|
|
1707
1708
|
};
|
|
1708
1709
|
QueryManager.prototype.generateQueryId = function () {
|
|
@@ -1727,7 +1728,7 @@ var QueryManager = (function () {
|
|
|
1727
1728
|
if (options === void 0) { options = {
|
|
1728
1729
|
discardWatches: true,
|
|
1729
1730
|
}; }
|
|
1730
|
-
this.cancelPendingFetches(globals.newInvariantError(
|
|
1731
|
+
this.cancelPendingFetches(globals.newInvariantError(32));
|
|
1731
1732
|
this.queries.forEach(function (queryInfo) {
|
|
1732
1733
|
if (queryInfo.observableQuery) {
|
|
1733
1734
|
queryInfo.networkStatus = exports.NetworkStatus.loading;
|
|
@@ -1803,7 +1804,7 @@ var QueryManager = (function () {
|
|
|
1803
1804
|
if (globalThis.__DEV__ !== false && queryNamesAndDocs.size) {
|
|
1804
1805
|
queryNamesAndDocs.forEach(function (included, nameOrDoc) {
|
|
1805
1806
|
if (!included) {
|
|
1806
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(typeof nameOrDoc === "string" ?
|
|
1807
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(typeof nameOrDoc === "string" ? 33 : 34, nameOrDoc);
|
|
1807
1808
|
}
|
|
1808
1809
|
});
|
|
1809
1810
|
}
|
|
@@ -1959,7 +1960,7 @@ var QueryManager = (function () {
|
|
|
1959
1960
|
QueryManager.prototype.getResultsFromLink = function (queryInfo, cacheWriteBehavior, options) {
|
|
1960
1961
|
var requestId = (queryInfo.lastRequestId = this.generateRequestId());
|
|
1961
1962
|
var linkDocument = this.cache.transformForLink(options.query);
|
|
1962
|
-
return utilities.asyncMap(this.getObservableFromLink(linkDocument, options.context, options.variables), function (result) {
|
|
1963
|
+
return utilities.asyncMap(this.getObservableFromLink(linkDocument, utilities.compact(this.defaultContext, options.context), options.variables), function (result) {
|
|
1963
1964
|
var graphQLErrors = utilities.getGraphQLErrorsFromResult(result);
|
|
1964
1965
|
var hasErrors = graphQLErrors.length > 0;
|
|
1965
1966
|
if (requestId >= queryInfo.lastRequestId) {
|
|
@@ -2240,11 +2241,11 @@ var ApolloClient = (function () {
|
|
|
2240
2241
|
this.resetStoreCallbacks = [];
|
|
2241
2242
|
this.clearStoreCallbacks = [];
|
|
2242
2243
|
if (!options.cache) {
|
|
2243
|
-
throw globals.newInvariantError(
|
|
2244
|
+
throw globals.newInvariantError(15);
|
|
2244
2245
|
}
|
|
2245
2246
|
var uri = options.uri, credentials = options.credentials, headers = options.headers, cache = options.cache, documentTransform = options.documentTransform, _a = options.ssrMode, ssrMode = _a === void 0 ? false : _a, _b = options.ssrForceFetchDelay, ssrForceFetchDelay = _b === void 0 ? 0 : _b, _c = options.connectToDevTools, connectToDevTools = _c === void 0 ? typeof window === "object" &&
|
|
2246
2247
|
!window.__APOLLO_CLIENT__ &&
|
|
2247
|
-
globalThis.__DEV__ !== false : _c, _d = options.queryDeduplication, queryDeduplication = _d === void 0 ? true : _d, defaultOptions = options.defaultOptions, _e = options.assumeImmutableResults, assumeImmutableResults = _e === void 0 ? cache.assumeImmutableResults : _e, resolvers = options.resolvers, typeDefs = options.typeDefs, fragmentMatcher = options.fragmentMatcher, clientAwarenessName = options.name, clientAwarenessVersion = options.version;
|
|
2248
|
+
globalThis.__DEV__ !== false : _c, _d = options.queryDeduplication, queryDeduplication = _d === void 0 ? true : _d, defaultOptions = options.defaultOptions, defaultContext = options.defaultContext, _e = options.assumeImmutableResults, assumeImmutableResults = _e === void 0 ? cache.assumeImmutableResults : _e, resolvers = options.resolvers, typeDefs = options.typeDefs, fragmentMatcher = options.fragmentMatcher, clientAwarenessName = options.name, clientAwarenessVersion = options.version;
|
|
2248
2249
|
var link = options.link;
|
|
2249
2250
|
if (!link) {
|
|
2250
2251
|
link = uri
|
|
@@ -2276,6 +2277,7 @@ var ApolloClient = (function () {
|
|
|
2276
2277
|
cache: this.cache,
|
|
2277
2278
|
link: this.link,
|
|
2278
2279
|
defaultOptions: this.defaultOptions,
|
|
2280
|
+
defaultContext: defaultContext,
|
|
2279
2281
|
documentTransform: documentTransform,
|
|
2280
2282
|
queryDeduplication: queryDeduplication,
|
|
2281
2283
|
ssrMode: ssrMode,
|
|
@@ -2365,7 +2367,7 @@ var ApolloClient = (function () {
|
|
|
2365
2367
|
if (this.defaultOptions.query) {
|
|
2366
2368
|
options = utilities.mergeOptions(this.defaultOptions.query, options);
|
|
2367
2369
|
}
|
|
2368
|
-
globals.invariant(options.fetchPolicy !== "cache-and-network",
|
|
2370
|
+
globals.invariant(options.fetchPolicy !== "cache-and-network", 16);
|
|
2369
2371
|
if (this.disableNetworkFetches && options.fetchPolicy === "network-only") {
|
|
2370
2372
|
options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: "cache-first" });
|
|
2371
2373
|
}
|
|
@@ -2458,7 +2460,7 @@ var ApolloClient = (function () {
|
|
|
2458
2460
|
result.queries = queries;
|
|
2459
2461
|
result.results = results;
|
|
2460
2462
|
result.catch(function (error) {
|
|
2461
|
-
globalThis.__DEV__ !== false && globals.invariant.debug(
|
|
2463
|
+
globalThis.__DEV__ !== false && globals.invariant.debug(17, error);
|
|
2462
2464
|
});
|
|
2463
2465
|
return result;
|
|
2464
2466
|
};
|
|
@@ -2487,6 +2489,13 @@ var ApolloClient = (function () {
|
|
|
2487
2489
|
ApolloClient.prototype.setLink = function (newLink) {
|
|
2488
2490
|
this.link = this.queryManager.link = newLink;
|
|
2489
2491
|
};
|
|
2492
|
+
Object.defineProperty(ApolloClient.prototype, "defaultContext", {
|
|
2493
|
+
get: function () {
|
|
2494
|
+
return this.queryManager.defaultContext;
|
|
2495
|
+
},
|
|
2496
|
+
enumerable: false,
|
|
2497
|
+
configurable: true
|
|
2498
|
+
});
|
|
2490
2499
|
return ApolloClient;
|
|
2491
2500
|
}());
|
|
2492
2501
|
|