@apollo/client 3.9.0-beta.0 → 3.9.0-beta.1
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/.changeset/chatty-comics-yawn.md +8 -0
- package/.changeset/curvy-seas-hope.md +13 -0
- package/.changeset/late-rabbits-protect.md +7 -0
- package/.changeset/pre.json +6 -0
- package/.changeset/smooth-plums-shout.md +5 -0
- package/.changeset/spicy-drinks-camp.md +5 -0
- package/.changeset/wise-news-grab.md +7 -0
- package/CHANGELOG.md +33 -0
- package/apollo-client.cjs +9 -7
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/core/ApolloClient.d.ts +74 -1
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.js +8 -4
- package/core/ObservableQuery.js.map +1 -1
- package/core/core.cjs +9 -5
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +9 -5
- package/dev/dev.cjs +1 -1
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +1 -1
- package/link/retry/retry.cjs +15 -74
- package/link/retry/retry.cjs.map +1 -1
- package/link/retry/retry.cjs.native.js +15 -74
- package/link/retry/retryLink.js +15 -93
- package/link/retry/retryLink.js.map +1 -1
- package/package.json +1 -1
- package/react/components/Mutation.d.ts +6 -0
- package/react/components/Mutation.js +6 -0
- package/react/components/Mutation.js.map +1 -1
- package/react/components/Query.d.ts +6 -0
- package/react/components/Query.js +6 -0
- package/react/components/Query.js.map +1 -1
- package/react/components/Subscription.d.ts +6 -0
- package/react/components/Subscription.js +6 -0
- package/react/components/Subscription.js.map +1 -1
- package/react/components/components.cjs.map +1 -1
- package/react/hoc/graphql.d.ts +5 -0
- package/react/hoc/graphql.js +5 -0
- package/react/hoc/graphql.js.map +1 -1
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/mutation-hoc.d.ts +5 -0
- package/react/hoc/mutation-hoc.js +5 -0
- package/react/hoc/mutation-hoc.js.map +1 -1
- package/react/hoc/query-hoc.d.ts +5 -0
- package/react/hoc/query-hoc.js +5 -0
- package/react/hoc/query-hoc.js.map +1 -1
- package/react/hoc/subscription-hoc.d.ts +5 -0
- package/react/hoc/subscription-hoc.js +5 -0
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/hoc/withApollo.d.ts +5 -0
- package/react/hoc/withApollo.js +5 -0
- package/react/hoc/withApollo.js.map +1 -1
- package/react/hooks/hooks.cjs +23 -292
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +23 -292
- package/react/hooks/useBackgroundQuery.d.ts +1 -1
- package/react/hooks/useBackgroundQuery.js +1 -3
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +1 -1
- package/react/hooks/useLoadableQuery.js +1 -3
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.d.ts +1 -1
- package/react/hooks/useQueryRefHandlers.js +1 -1
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +1 -1
- package/react/hooks/useReadQuery.js +1 -1
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +1 -1
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/{cache → internal/cache}/QueryReference.d.ts +2 -2
- package/react/{cache → internal/cache}/QueryReference.js +2 -2
- package/react/internal/cache/QueryReference.js.map +1 -0
- package/react/{cache → internal/cache}/SuspenseCache.d.ts +1 -1
- package/react/{cache → internal/cache}/SuspenseCache.js +1 -1
- package/react/internal/cache/SuspenseCache.js.map +1 -0
- package/react/{cache → internal/cache}/getSuspenseCache.d.ts +3 -3
- package/react/internal/cache/getSuspenseCache.js.map +1 -0
- package/react/internal/cache/types.js.map +1 -0
- package/react/internal/index.d.ts +6 -0
- package/react/internal/index.js +3 -0
- package/react/internal/index.js.map +1 -0
- package/react/internal/internal.cjs +283 -0
- package/react/internal/internal.cjs.map +1 -0
- package/react/internal/internal.cjs.native.js +283 -0
- package/react/internal/package.json +8 -0
- package/react/query-preloader/createQueryPreloader.d.ts +1 -1
- package/react/query-preloader/createQueryPreloader.js +1 -1
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/react.cjs +3 -238
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +3 -238
- package/react/types/types.d.ts +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/internal/ObservableStream.js +16 -8
- package/testing/internal/ObservableStream.js.map +1 -1
- package/testing/internal/scenarios/index.js +5 -3
- package/testing/internal/scenarios/index.js.map +1 -1
- package/testing/matchers/toBeDisposed.js +1 -1
- package/testing/matchers/toBeDisposed.js.map +1 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.js +1 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
- package/utilities/caching/sizes.d.ts +107 -57
- package/utilities/caching/sizes.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/version.js +1 -1
- package/react/cache/QueryReference.js.map +0 -1
- package/react/cache/SuspenseCache.js.map +0 -1
- package/react/cache/getSuspenseCache.js.map +0 -1
- package/react/cache/index.d.ts +0 -3
- package/react/cache/index.js +0 -2
- package/react/cache/index.js.map +0 -1
- package/react/cache/types.js.map +0 -1
- /package/react/{cache → internal/cache}/getSuspenseCache.js +0 -0
- /package/react/{cache → internal/cache}/types.d.ts +0 -0
- /package/react/{cache → internal/cache}/types.js +0 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var trie = require('@wry/trie');
|
|
6
|
+
var utilities = require('../../utilities');
|
|
7
|
+
var tslib = require('tslib');
|
|
8
|
+
var equality = require('@wry/equality');
|
|
9
|
+
|
|
10
|
+
var QUERY_REFERENCE_SYMBOL = Symbol();
|
|
11
|
+
var PROMISE_SYMBOL = Symbol();
|
|
12
|
+
function wrapQueryRef(internalQueryRef) {
|
|
13
|
+
var _a;
|
|
14
|
+
var ref = (_a = {
|
|
15
|
+
toPromise: function () {
|
|
16
|
+
return getWrappedPromise(ref).then(function () { return ref; });
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
_a[QUERY_REFERENCE_SYMBOL] = internalQueryRef,
|
|
20
|
+
_a[PROMISE_SYMBOL] = internalQueryRef.promise,
|
|
21
|
+
_a);
|
|
22
|
+
return ref;
|
|
23
|
+
}
|
|
24
|
+
function getWrappedPromise(queryRef) {
|
|
25
|
+
var internalQueryRef = unwrapQueryRef(queryRef);
|
|
26
|
+
return internalQueryRef.promise.status === "fulfilled" ?
|
|
27
|
+
internalQueryRef.promise
|
|
28
|
+
: queryRef[PROMISE_SYMBOL];
|
|
29
|
+
}
|
|
30
|
+
function unwrapQueryRef(queryRef) {
|
|
31
|
+
return queryRef[QUERY_REFERENCE_SYMBOL];
|
|
32
|
+
}
|
|
33
|
+
function updateWrappedQueryRef(queryRef, promise) {
|
|
34
|
+
queryRef[PROMISE_SYMBOL] = promise;
|
|
35
|
+
}
|
|
36
|
+
var OBSERVED_CHANGED_OPTIONS = [
|
|
37
|
+
"canonizeResults",
|
|
38
|
+
"context",
|
|
39
|
+
"errorPolicy",
|
|
40
|
+
"fetchPolicy",
|
|
41
|
+
"refetchWritePolicy",
|
|
42
|
+
"returnPartialData",
|
|
43
|
+
];
|
|
44
|
+
var InternalQueryReference = (function () {
|
|
45
|
+
function InternalQueryReference(observable, options) {
|
|
46
|
+
var _this = this;
|
|
47
|
+
this.key = {};
|
|
48
|
+
this.listeners = new Set();
|
|
49
|
+
this.references = 0;
|
|
50
|
+
this.handleNext = this.handleNext.bind(this);
|
|
51
|
+
this.handleError = this.handleError.bind(this);
|
|
52
|
+
this.dispose = this.dispose.bind(this);
|
|
53
|
+
this.observable = observable;
|
|
54
|
+
if (options.onDispose) {
|
|
55
|
+
this.onDispose = options.onDispose;
|
|
56
|
+
}
|
|
57
|
+
this.setResult();
|
|
58
|
+
this.subscribeToQuery();
|
|
59
|
+
var startDisposeTimer = function () {
|
|
60
|
+
var _a;
|
|
61
|
+
if (!_this.references) {
|
|
62
|
+
_this.autoDisposeTimeoutId = setTimeout(_this.dispose, (_a = options.autoDisposeTimeoutMs) !== null && _a !== void 0 ? _a : 30000);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
this.promise.then(startDisposeTimer, startDisposeTimer);
|
|
66
|
+
}
|
|
67
|
+
Object.defineProperty(InternalQueryReference.prototype, "disposed", {
|
|
68
|
+
get: function () {
|
|
69
|
+
return this.subscription.closed;
|
|
70
|
+
},
|
|
71
|
+
enumerable: false,
|
|
72
|
+
configurable: true
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(InternalQueryReference.prototype, "watchQueryOptions", {
|
|
75
|
+
get: function () {
|
|
76
|
+
return this.observable.options;
|
|
77
|
+
},
|
|
78
|
+
enumerable: false,
|
|
79
|
+
configurable: true
|
|
80
|
+
});
|
|
81
|
+
InternalQueryReference.prototype.reinitialize = function () {
|
|
82
|
+
var observable = this.observable;
|
|
83
|
+
var originalFetchPolicy = this.watchQueryOptions.fetchPolicy;
|
|
84
|
+
try {
|
|
85
|
+
if (originalFetchPolicy !== "no-cache") {
|
|
86
|
+
observable.resetLastResults();
|
|
87
|
+
observable.silentSetOptions({ fetchPolicy: "cache-first" });
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
observable.silentSetOptions({ fetchPolicy: "standby" });
|
|
91
|
+
}
|
|
92
|
+
this.subscribeToQuery();
|
|
93
|
+
if (originalFetchPolicy === "no-cache") {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
observable.resetDiff();
|
|
97
|
+
this.setResult();
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
observable.silentSetOptions({ fetchPolicy: originalFetchPolicy });
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
InternalQueryReference.prototype.retain = function () {
|
|
104
|
+
var _this = this;
|
|
105
|
+
this.references++;
|
|
106
|
+
clearTimeout(this.autoDisposeTimeoutId);
|
|
107
|
+
var disposed = false;
|
|
108
|
+
return function () {
|
|
109
|
+
if (disposed) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
disposed = true;
|
|
113
|
+
_this.references--;
|
|
114
|
+
setTimeout(function () {
|
|
115
|
+
if (!_this.references) {
|
|
116
|
+
_this.dispose();
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
InternalQueryReference.prototype.didChangeOptions = function (watchQueryOptions) {
|
|
122
|
+
var _this = this;
|
|
123
|
+
return OBSERVED_CHANGED_OPTIONS.some(function (option) {
|
|
124
|
+
return !equality.equal(_this.watchQueryOptions[option], watchQueryOptions[option]);
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
InternalQueryReference.prototype.applyOptions = function (watchQueryOptions) {
|
|
128
|
+
var _a = this.watchQueryOptions, currentFetchPolicy = _a.fetchPolicy, currentCanonizeResults = _a.canonizeResults;
|
|
129
|
+
if (currentFetchPolicy === "standby" &&
|
|
130
|
+
currentFetchPolicy !== watchQueryOptions.fetchPolicy) {
|
|
131
|
+
this.initiateFetch(this.observable.reobserve(watchQueryOptions));
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
this.observable.silentSetOptions(watchQueryOptions);
|
|
135
|
+
if (currentCanonizeResults !== watchQueryOptions.canonizeResults) {
|
|
136
|
+
this.result = tslib.__assign(tslib.__assign({}, this.result), this.observable.getCurrentResult());
|
|
137
|
+
this.promise = utilities.createFulfilledPromise(this.result);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return this.promise;
|
|
141
|
+
};
|
|
142
|
+
InternalQueryReference.prototype.listen = function (listener) {
|
|
143
|
+
var _this = this;
|
|
144
|
+
this.listeners.add(listener);
|
|
145
|
+
return function () {
|
|
146
|
+
_this.listeners.delete(listener);
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
InternalQueryReference.prototype.refetch = function (variables) {
|
|
150
|
+
return this.initiateFetch(this.observable.refetch(variables));
|
|
151
|
+
};
|
|
152
|
+
InternalQueryReference.prototype.fetchMore = function (options) {
|
|
153
|
+
return this.initiateFetch(this.observable.fetchMore(options));
|
|
154
|
+
};
|
|
155
|
+
InternalQueryReference.prototype.dispose = function () {
|
|
156
|
+
this.subscription.unsubscribe();
|
|
157
|
+
this.onDispose();
|
|
158
|
+
};
|
|
159
|
+
InternalQueryReference.prototype.onDispose = function () {
|
|
160
|
+
};
|
|
161
|
+
InternalQueryReference.prototype.handleNext = function (result) {
|
|
162
|
+
var _a;
|
|
163
|
+
switch (this.promise.status) {
|
|
164
|
+
case "pending": {
|
|
165
|
+
if (result.data === void 0) {
|
|
166
|
+
result.data = this.result.data;
|
|
167
|
+
}
|
|
168
|
+
this.result = result;
|
|
169
|
+
(_a = this.resolve) === null || _a === void 0 ? void 0 : _a.call(this, result);
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
default: {
|
|
173
|
+
if (result.data === this.result.data) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (result.data === void 0) {
|
|
177
|
+
result.data = this.result.data;
|
|
178
|
+
}
|
|
179
|
+
this.result = result;
|
|
180
|
+
this.promise = utilities.createFulfilledPromise(result);
|
|
181
|
+
this.deliver(this.promise);
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
InternalQueryReference.prototype.handleError = function (error) {
|
|
187
|
+
var _a;
|
|
188
|
+
this.subscription.unsubscribe();
|
|
189
|
+
this.subscription = this.observable.resubscribeAfterError(this.handleNext, this.handleError);
|
|
190
|
+
switch (this.promise.status) {
|
|
191
|
+
case "pending": {
|
|
192
|
+
(_a = this.reject) === null || _a === void 0 ? void 0 : _a.call(this, error);
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
default: {
|
|
196
|
+
this.promise = utilities.createRejectedPromise(error);
|
|
197
|
+
this.deliver(this.promise);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
InternalQueryReference.prototype.deliver = function (promise) {
|
|
202
|
+
this.listeners.forEach(function (listener) { return listener(promise); });
|
|
203
|
+
};
|
|
204
|
+
InternalQueryReference.prototype.initiateFetch = function (returnedPromise) {
|
|
205
|
+
var _this = this;
|
|
206
|
+
this.promise = this.createPendingPromise();
|
|
207
|
+
this.promise.catch(function () { });
|
|
208
|
+
returnedPromise
|
|
209
|
+
.then(function (result) {
|
|
210
|
+
var _a;
|
|
211
|
+
if (_this.promise.status === "pending") {
|
|
212
|
+
_this.result = result;
|
|
213
|
+
(_a = _this.resolve) === null || _a === void 0 ? void 0 : _a.call(_this, result);
|
|
214
|
+
}
|
|
215
|
+
})
|
|
216
|
+
.catch(function () { });
|
|
217
|
+
return returnedPromise;
|
|
218
|
+
};
|
|
219
|
+
InternalQueryReference.prototype.subscribeToQuery = function () {
|
|
220
|
+
var _this = this;
|
|
221
|
+
this.subscription = this.observable
|
|
222
|
+
.filter(function (result) { return !equality.equal(result.data, {}) && !equality.equal(result, _this.result); })
|
|
223
|
+
.subscribe(this.handleNext, this.handleError);
|
|
224
|
+
};
|
|
225
|
+
InternalQueryReference.prototype.setResult = function () {
|
|
226
|
+
var result = this.observable.getCurrentResult(false);
|
|
227
|
+
if (equality.equal(result, this.result)) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
this.result = result;
|
|
231
|
+
this.promise =
|
|
232
|
+
(result.data &&
|
|
233
|
+
(!result.partial || this.watchQueryOptions.returnPartialData)) ?
|
|
234
|
+
utilities.createFulfilledPromise(result)
|
|
235
|
+
: this.createPendingPromise();
|
|
236
|
+
};
|
|
237
|
+
InternalQueryReference.prototype.createPendingPromise = function () {
|
|
238
|
+
var _this = this;
|
|
239
|
+
return utilities.wrapPromiseWithState(new Promise(function (resolve, reject) {
|
|
240
|
+
_this.resolve = resolve;
|
|
241
|
+
_this.reject = reject;
|
|
242
|
+
}));
|
|
243
|
+
};
|
|
244
|
+
return InternalQueryReference;
|
|
245
|
+
}());
|
|
246
|
+
|
|
247
|
+
var SuspenseCache = (function () {
|
|
248
|
+
function SuspenseCache(options) {
|
|
249
|
+
if (options === void 0) { options = Object.create(null); }
|
|
250
|
+
this.queryRefs = new trie.Trie(utilities.canUseWeakMap);
|
|
251
|
+
this.options = options;
|
|
252
|
+
}
|
|
253
|
+
SuspenseCache.prototype.getQueryRef = function (cacheKey, createObservable) {
|
|
254
|
+
var ref = this.queryRefs.lookupArray(cacheKey);
|
|
255
|
+
if (!ref.current) {
|
|
256
|
+
ref.current = new InternalQueryReference(createObservable(), {
|
|
257
|
+
autoDisposeTimeoutMs: this.options.autoDisposeTimeoutMs,
|
|
258
|
+
onDispose: function () {
|
|
259
|
+
delete ref.current;
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
return ref.current;
|
|
264
|
+
};
|
|
265
|
+
return SuspenseCache;
|
|
266
|
+
}());
|
|
267
|
+
|
|
268
|
+
var suspenseCacheSymbol = Symbol.for("apollo.suspenseCache");
|
|
269
|
+
function getSuspenseCache(client) {
|
|
270
|
+
var _a;
|
|
271
|
+
if (!client[suspenseCacheSymbol]) {
|
|
272
|
+
client[suspenseCacheSymbol] = new SuspenseCache((_a = client.defaultOptions.react) === null || _a === void 0 ? void 0 : _a.suspense);
|
|
273
|
+
}
|
|
274
|
+
return client[suspenseCacheSymbol];
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
exports.InternalQueryReference = InternalQueryReference;
|
|
278
|
+
exports.getSuspenseCache = getSuspenseCache;
|
|
279
|
+
exports.getWrappedPromise = getWrappedPromise;
|
|
280
|
+
exports.unwrapQueryRef = unwrapQueryRef;
|
|
281
|
+
exports.updateWrappedQueryRef = updateWrappedQueryRef;
|
|
282
|
+
exports.wrapQueryRef = wrapQueryRef;
|
|
283
|
+
//# sourceMappingURL=internal.cjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ApolloClient, DefaultContext, DocumentNode, ErrorPolicy, OperationVariables, RefetchWritePolicy, TypedDocumentNode, WatchQueryFetchPolicy } from "../../core/index.js";
|
|
2
2
|
import type { DeepPartial, OnlyRequiredProperties } from "../../utilities/index.js";
|
|
3
|
-
import type { QueryReference } from "../
|
|
3
|
+
import type { QueryReference } from "../internal/index.js";
|
|
4
4
|
import type { NoInfer } from "../index.js";
|
|
5
5
|
type VariablesOption<TVariables extends OperationVariables> = [
|
|
6
6
|
TVariables
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
|
-
import { InternalQueryReference, wrapQueryRef
|
|
2
|
+
import { InternalQueryReference, wrapQueryRef } from "../internal/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* A higher order function that returns a `preloadQuery` function which
|
|
5
5
|
* can be used to begin loading a query with the given `client`. This is useful
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createQueryPreloader.js","sourceRoot":"","sources":["../../../src/react/query-preloader/createQueryPreloader.ts"],"names":[],"mappings":";AAeA,OAAO,
|
|
1
|
+
{"version":3,"file":"createQueryPreloader.js","sourceRoot":"","sources":["../../../src/react/query-preloader/createQueryPreloader.ts"],"names":[],"mappings":";AAeA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAsI5E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAyB;IAEzB,OAAO,SAAS,YAAY,CAI1B,KAA0D,EAC1D,OACmD;;QADnD,wBAAA,EAAA,UACgC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;QAEnD,IAAM,QAAQ,GAAG,IAAI,sBAAsB,CACzC,MAAM,CAAC,UAAU,CAAC,sBACb,OAAO,KACV,KAAK,OAAA,GACyB,CAAC,EACjC;YACE,oBAAoB,EAClB,MAAA,MAAA,MAAM,CAAC,cAAc,CAAC,KAAK,0CAAE,QAAQ,0CAAE,oBAAoB;SAC9D,CACF,CAAC;QAEF,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ApolloClient,\n DefaultContext,\n DocumentNode,\n ErrorPolicy,\n OperationVariables,\n RefetchWritePolicy,\n TypedDocumentNode,\n WatchQueryFetchPolicy,\n WatchQueryOptions,\n} from \"../../core/index.js\";\nimport type {\n DeepPartial,\n OnlyRequiredProperties,\n} from \"../../utilities/index.js\";\nimport { InternalQueryReference, wrapQueryRef } from \"../internal/index.js\";\nimport type { QueryReference } from \"../internal/index.js\";\nimport type { NoInfer } from \"../index.js\";\n\ntype VariablesOption<TVariables extends OperationVariables> =\n [TVariables] extends [never] ?\n {\n /** {@inheritDoc @apollo/client!QueryOptions#variables:member} */\n variables?: Record<string, never>;\n }\n : {} extends OnlyRequiredProperties<TVariables> ?\n {\n /** {@inheritDoc @apollo/client!QueryOptions#variables:member} */\n variables?: TVariables;\n }\n : {\n /** {@inheritDoc @apollo/client!QueryOptions#variables:member} */\n variables: TVariables;\n };\n\nexport type PreloadQueryFetchPolicy = Extract<\n WatchQueryFetchPolicy,\n \"cache-first\" | \"network-only\" | \"no-cache\" | \"cache-and-network\"\n>;\n\nexport type PreloadQueryOptions<\n TVariables extends OperationVariables = OperationVariables,\n> = {\n /** {@inheritDoc @apollo/client!QueryOptions#canonizeResults:member} */\n canonizeResults?: boolean;\n /** {@inheritDoc @apollo/client!QueryOptions#context:member} */\n context?: DefaultContext;\n /** {@inheritDoc @apollo/client!QueryOptions#errorPolicy:member} */\n errorPolicy?: ErrorPolicy;\n /** {@inheritDoc @apollo/client!QueryOptions#fetchPolicy:member} */\n fetchPolicy?: PreloadQueryFetchPolicy;\n /** {@inheritDoc @apollo/client!QueryOptions#returnPartialData:member} */\n returnPartialData?: boolean;\n /** {@inheritDoc @apollo/client!WatchQueryOptions#refetchWritePolicy:member} */\n refetchWritePolicy?: RefetchWritePolicy;\n} & VariablesOption<TVariables>;\n\ntype PreloadQueryOptionsArg<\n TVariables extends OperationVariables,\n TOptions = unknown,\n> = [TVariables] extends [never] ?\n [options?: PreloadQueryOptions<never> & TOptions]\n: {} extends OnlyRequiredProperties<TVariables> ?\n [\n options?: PreloadQueryOptions<NoInfer<TVariables>> &\n Omit<TOptions, \"variables\">,\n ]\n: [\n options: PreloadQueryOptions<NoInfer<TVariables>> &\n Omit<TOptions, \"variables\">,\n ];\n\n/**\n * A function that will begin loading a query when called. It's result can be\n * read by {@link useReadQuery} which will suspend until the query is loaded.\n * This is useful when you want to start loading a query as early as possible\n * outside of a React component.\n *\n * @example\n * ```js\n * const preloadQuery = createQueryPreloader(client);\n * const queryRef = preloadQuery(query, { variables, ...otherOptions });\n *\n * function App() {\n * return (\n * <Suspense fallback={<div>Loading</div>}>\n * <MyQuery />\n * </Suspense>\n * );\n * }\n *\n * function MyQuery() {\n * const { data } = useReadQuery(queryRef);\n *\n * // do something with `data`\n * }\n * ```\n */\nexport interface PreloadQueryFunction {\n /** {@inheritDoc @apollo/client!PreloadQueryFunction:interface} */\n <\n TData,\n TVariables extends OperationVariables,\n TOptions extends Omit<PreloadQueryOptions, \"variables\">,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: PreloadQueryOptionsArg<NoInfer<TVariables>, TOptions>\n ): QueryReference<\n TOptions[\"errorPolicy\"] extends \"ignore\" | \"all\" ?\n TOptions[\"returnPartialData\"] extends true ?\n DeepPartial<TData> | undefined\n : TData | undefined\n : TOptions[\"returnPartialData\"] extends true ? DeepPartial<TData>\n : TData,\n TVariables\n >;\n\n /** {@inheritDoc @apollo/client!PreloadQueryFunction:interface} */\n <TData = unknown, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: PreloadQueryOptions<NoInfer<TVariables>> & {\n returnPartialData: true;\n errorPolicy: \"ignore\" | \"all\";\n }\n ): QueryReference<DeepPartial<TData> | undefined, TVariables>;\n\n /** {@inheritDoc @apollo/client!PreloadQueryFunction:interface} */\n <TData = unknown, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: PreloadQueryOptions<NoInfer<TVariables>> & {\n errorPolicy: \"ignore\" | \"all\";\n }\n ): QueryReference<TData | undefined, TVariables>;\n\n /** {@inheritDoc @apollo/client!PreloadQueryFunction:interface} */\n <TData = unknown, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: PreloadQueryOptions<NoInfer<TVariables>> & {\n returnPartialData: true;\n }\n ): QueryReference<DeepPartial<TData>, TVariables>;\n\n /** {@inheritDoc @apollo/client!PreloadQueryFunction:interface} */\n <TData = unknown, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: PreloadQueryOptionsArg<NoInfer<TVariables>>\n ): QueryReference<TData, TVariables>;\n}\n\n/**\n * A higher order function that returns a `preloadQuery` function which\n * can be used to begin loading a query with the given `client`. This is useful\n * when you want to start loading a query as early as possible outside of a\n * React component.\n *\n * @param client - The ApolloClient instance that will be used to load queries\n * from the returned `preloadQuery` function.\n * @returns The `preloadQuery` function.\n *\n * @example\n * ```js\n * const preloadQuery = createQueryPreloader(client);\n * ```\n * @experimental\n */\nexport function createQueryPreloader(\n client: ApolloClient<any>\n): PreloadQueryFunction {\n return function preloadQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: PreloadQueryOptions<NoInfer<TVariables>> &\n VariablesOption<TVariables> = Object.create(null)\n ): QueryReference<TData, TVariables> {\n const queryRef = new InternalQueryReference(\n client.watchQuery({\n ...options,\n query,\n } as WatchQueryOptions<any, any>),\n {\n autoDisposeTimeoutMs:\n client.defaultOptions.react?.suspense?.autoDisposeTimeoutMs,\n }\n );\n\n return wrapQueryRef(queryRef);\n };\n}\n"]}
|
package/react/react.cjs
CHANGED
|
@@ -7,251 +7,16 @@ var context = require('./context');
|
|
|
7
7
|
var hooks = require('./hooks');
|
|
8
8
|
var parser = require('./parser');
|
|
9
9
|
var tslib = require('tslib');
|
|
10
|
-
var
|
|
11
|
-
var utilities = require('../utilities');
|
|
12
|
-
|
|
13
|
-
var QUERY_REFERENCE_SYMBOL = Symbol();
|
|
14
|
-
var PROMISE_SYMBOL = Symbol();
|
|
15
|
-
function wrapQueryRef(internalQueryRef) {
|
|
16
|
-
var _a;
|
|
17
|
-
var ref = (_a = {
|
|
18
|
-
toPromise: function () {
|
|
19
|
-
return getWrappedPromise(ref).then(function () { return ref; });
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
_a[QUERY_REFERENCE_SYMBOL] = internalQueryRef,
|
|
23
|
-
_a[PROMISE_SYMBOL] = internalQueryRef.promise,
|
|
24
|
-
_a);
|
|
25
|
-
return ref;
|
|
26
|
-
}
|
|
27
|
-
function getWrappedPromise(queryRef) {
|
|
28
|
-
var internalQueryRef = unwrapQueryRef(queryRef);
|
|
29
|
-
return internalQueryRef.promise.status === "fulfilled" ?
|
|
30
|
-
internalQueryRef.promise
|
|
31
|
-
: queryRef[PROMISE_SYMBOL];
|
|
32
|
-
}
|
|
33
|
-
function unwrapQueryRef(queryRef) {
|
|
34
|
-
return queryRef[QUERY_REFERENCE_SYMBOL];
|
|
35
|
-
}
|
|
36
|
-
var OBSERVED_CHANGED_OPTIONS = [
|
|
37
|
-
"canonizeResults",
|
|
38
|
-
"context",
|
|
39
|
-
"errorPolicy",
|
|
40
|
-
"fetchPolicy",
|
|
41
|
-
"refetchWritePolicy",
|
|
42
|
-
"returnPartialData",
|
|
43
|
-
];
|
|
44
|
-
var InternalQueryReference = (function () {
|
|
45
|
-
function InternalQueryReference(observable, options) {
|
|
46
|
-
var _this = this;
|
|
47
|
-
this.key = {};
|
|
48
|
-
this.listeners = new Set();
|
|
49
|
-
this.references = 0;
|
|
50
|
-
this.handleNext = this.handleNext.bind(this);
|
|
51
|
-
this.handleError = this.handleError.bind(this);
|
|
52
|
-
this.dispose = this.dispose.bind(this);
|
|
53
|
-
this.observable = observable;
|
|
54
|
-
if (options.onDispose) {
|
|
55
|
-
this.onDispose = options.onDispose;
|
|
56
|
-
}
|
|
57
|
-
this.setResult();
|
|
58
|
-
this.subscribeToQuery();
|
|
59
|
-
var startDisposeTimer = function () {
|
|
60
|
-
var _a;
|
|
61
|
-
if (!_this.references) {
|
|
62
|
-
_this.autoDisposeTimeoutId = setTimeout(_this.dispose, (_a = options.autoDisposeTimeoutMs) !== null && _a !== void 0 ? _a : 30000);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
this.promise.then(startDisposeTimer, startDisposeTimer);
|
|
66
|
-
}
|
|
67
|
-
Object.defineProperty(InternalQueryReference.prototype, "disposed", {
|
|
68
|
-
get: function () {
|
|
69
|
-
return this.subscription.closed;
|
|
70
|
-
},
|
|
71
|
-
enumerable: false,
|
|
72
|
-
configurable: true
|
|
73
|
-
});
|
|
74
|
-
Object.defineProperty(InternalQueryReference.prototype, "watchQueryOptions", {
|
|
75
|
-
get: function () {
|
|
76
|
-
return this.observable.options;
|
|
77
|
-
},
|
|
78
|
-
enumerable: false,
|
|
79
|
-
configurable: true
|
|
80
|
-
});
|
|
81
|
-
InternalQueryReference.prototype.reinitialize = function () {
|
|
82
|
-
var observable = this.observable;
|
|
83
|
-
var originalFetchPolicy = this.watchQueryOptions.fetchPolicy;
|
|
84
|
-
try {
|
|
85
|
-
if (originalFetchPolicy !== "no-cache") {
|
|
86
|
-
observable.resetLastResults();
|
|
87
|
-
observable.silentSetOptions({ fetchPolicy: "cache-first" });
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
observable.silentSetOptions({ fetchPolicy: "standby" });
|
|
91
|
-
}
|
|
92
|
-
this.subscribeToQuery();
|
|
93
|
-
if (originalFetchPolicy === "no-cache") {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
observable.resetDiff();
|
|
97
|
-
this.setResult();
|
|
98
|
-
}
|
|
99
|
-
finally {
|
|
100
|
-
observable.silentSetOptions({ fetchPolicy: originalFetchPolicy });
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
InternalQueryReference.prototype.retain = function () {
|
|
104
|
-
var _this = this;
|
|
105
|
-
this.references++;
|
|
106
|
-
clearTimeout(this.autoDisposeTimeoutId);
|
|
107
|
-
var disposed = false;
|
|
108
|
-
return function () {
|
|
109
|
-
if (disposed) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
disposed = true;
|
|
113
|
-
_this.references--;
|
|
114
|
-
setTimeout(function () {
|
|
115
|
-
if (!_this.references) {
|
|
116
|
-
_this.dispose();
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
InternalQueryReference.prototype.didChangeOptions = function (watchQueryOptions) {
|
|
122
|
-
var _this = this;
|
|
123
|
-
return OBSERVED_CHANGED_OPTIONS.some(function (option) {
|
|
124
|
-
return !equality.equal(_this.watchQueryOptions[option], watchQueryOptions[option]);
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
InternalQueryReference.prototype.applyOptions = function (watchQueryOptions) {
|
|
128
|
-
var _a = this.watchQueryOptions, currentFetchPolicy = _a.fetchPolicy, currentCanonizeResults = _a.canonizeResults;
|
|
129
|
-
if (currentFetchPolicy === "standby" &&
|
|
130
|
-
currentFetchPolicy !== watchQueryOptions.fetchPolicy) {
|
|
131
|
-
this.initiateFetch(this.observable.reobserve(watchQueryOptions));
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
this.observable.silentSetOptions(watchQueryOptions);
|
|
135
|
-
if (currentCanonizeResults !== watchQueryOptions.canonizeResults) {
|
|
136
|
-
this.result = tslib.__assign(tslib.__assign({}, this.result), this.observable.getCurrentResult());
|
|
137
|
-
this.promise = utilities.createFulfilledPromise(this.result);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return this.promise;
|
|
141
|
-
};
|
|
142
|
-
InternalQueryReference.prototype.listen = function (listener) {
|
|
143
|
-
var _this = this;
|
|
144
|
-
this.listeners.add(listener);
|
|
145
|
-
return function () {
|
|
146
|
-
_this.listeners.delete(listener);
|
|
147
|
-
};
|
|
148
|
-
};
|
|
149
|
-
InternalQueryReference.prototype.refetch = function (variables) {
|
|
150
|
-
return this.initiateFetch(this.observable.refetch(variables));
|
|
151
|
-
};
|
|
152
|
-
InternalQueryReference.prototype.fetchMore = function (options) {
|
|
153
|
-
return this.initiateFetch(this.observable.fetchMore(options));
|
|
154
|
-
};
|
|
155
|
-
InternalQueryReference.prototype.dispose = function () {
|
|
156
|
-
this.subscription.unsubscribe();
|
|
157
|
-
this.onDispose();
|
|
158
|
-
};
|
|
159
|
-
InternalQueryReference.prototype.onDispose = function () {
|
|
160
|
-
};
|
|
161
|
-
InternalQueryReference.prototype.handleNext = function (result) {
|
|
162
|
-
var _a;
|
|
163
|
-
switch (this.promise.status) {
|
|
164
|
-
case "pending": {
|
|
165
|
-
if (result.data === void 0) {
|
|
166
|
-
result.data = this.result.data;
|
|
167
|
-
}
|
|
168
|
-
this.result = result;
|
|
169
|
-
(_a = this.resolve) === null || _a === void 0 ? void 0 : _a.call(this, result);
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
default: {
|
|
173
|
-
if (result.data === this.result.data) {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
if (result.data === void 0) {
|
|
177
|
-
result.data = this.result.data;
|
|
178
|
-
}
|
|
179
|
-
this.result = result;
|
|
180
|
-
this.promise = utilities.createFulfilledPromise(result);
|
|
181
|
-
this.deliver(this.promise);
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
InternalQueryReference.prototype.handleError = function (error) {
|
|
187
|
-
var _a;
|
|
188
|
-
this.subscription.unsubscribe();
|
|
189
|
-
this.subscription = this.observable.resubscribeAfterError(this.handleNext, this.handleError);
|
|
190
|
-
switch (this.promise.status) {
|
|
191
|
-
case "pending": {
|
|
192
|
-
(_a = this.reject) === null || _a === void 0 ? void 0 : _a.call(this, error);
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
default: {
|
|
196
|
-
this.promise = utilities.createRejectedPromise(error);
|
|
197
|
-
this.deliver(this.promise);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
InternalQueryReference.prototype.deliver = function (promise) {
|
|
202
|
-
this.listeners.forEach(function (listener) { return listener(promise); });
|
|
203
|
-
};
|
|
204
|
-
InternalQueryReference.prototype.initiateFetch = function (returnedPromise) {
|
|
205
|
-
var _this = this;
|
|
206
|
-
this.promise = this.createPendingPromise();
|
|
207
|
-
this.promise.catch(function () { });
|
|
208
|
-
returnedPromise
|
|
209
|
-
.then(function (result) {
|
|
210
|
-
var _a;
|
|
211
|
-
if (_this.promise.status === "pending") {
|
|
212
|
-
_this.result = result;
|
|
213
|
-
(_a = _this.resolve) === null || _a === void 0 ? void 0 : _a.call(_this, result);
|
|
214
|
-
}
|
|
215
|
-
})
|
|
216
|
-
.catch(function () { });
|
|
217
|
-
return returnedPromise;
|
|
218
|
-
};
|
|
219
|
-
InternalQueryReference.prototype.subscribeToQuery = function () {
|
|
220
|
-
var _this = this;
|
|
221
|
-
this.subscription = this.observable
|
|
222
|
-
.filter(function (result) { return !equality.equal(result.data, {}) && !equality.equal(result, _this.result); })
|
|
223
|
-
.subscribe(this.handleNext, this.handleError);
|
|
224
|
-
};
|
|
225
|
-
InternalQueryReference.prototype.setResult = function () {
|
|
226
|
-
var result = this.observable.getCurrentResult(false);
|
|
227
|
-
if (equality.equal(result, this.result)) {
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
this.result = result;
|
|
231
|
-
this.promise =
|
|
232
|
-
(result.data &&
|
|
233
|
-
(!result.partial || this.watchQueryOptions.returnPartialData)) ?
|
|
234
|
-
utilities.createFulfilledPromise(result)
|
|
235
|
-
: this.createPendingPromise();
|
|
236
|
-
};
|
|
237
|
-
InternalQueryReference.prototype.createPendingPromise = function () {
|
|
238
|
-
var _this = this;
|
|
239
|
-
return utilities.wrapPromiseWithState(new Promise(function (resolve, reject) {
|
|
240
|
-
_this.resolve = resolve;
|
|
241
|
-
_this.reject = reject;
|
|
242
|
-
}));
|
|
243
|
-
};
|
|
244
|
-
return InternalQueryReference;
|
|
245
|
-
}());
|
|
10
|
+
var internal = require('./internal');
|
|
246
11
|
|
|
247
12
|
function createQueryPreloader(client) {
|
|
248
13
|
return function preloadQuery(query, options) {
|
|
249
14
|
var _a, _b;
|
|
250
15
|
if (options === void 0) { options = Object.create(null); }
|
|
251
|
-
var queryRef = new InternalQueryReference(client.watchQuery(tslib.__assign(tslib.__assign({}, options), { query: query })), {
|
|
16
|
+
var queryRef = new internal.InternalQueryReference(client.watchQuery(tslib.__assign(tslib.__assign({}, options), { query: query })), {
|
|
252
17
|
autoDisposeTimeoutMs: (_b = (_a = client.defaultOptions.react) === null || _a === void 0 ? void 0 : _a.suspense) === null || _b === void 0 ? void 0 : _b.autoDisposeTimeoutMs,
|
|
253
18
|
});
|
|
254
|
-
return wrapQueryRef(queryRef);
|
|
19
|
+
return internal.wrapQueryRef(queryRef);
|
|
255
20
|
};
|
|
256
21
|
}
|
|
257
22
|
|
package/react/react.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.cjs","sources":["cache/QueryReference.js","query-preloader/createQueryPreloader.js"],"sourcesContent":["import { __assign } from \"tslib\";\nimport { equal } from \"@wry/equality\";\nimport { createFulfilledPromise, createRejectedPromise, } from \"../../utilities/index.js\";\nimport { wrapPromiseWithState } from \"../../utilities/index.js\";\nvar QUERY_REFERENCE_SYMBOL = Symbol();\nvar PROMISE_SYMBOL = Symbol();\nexport function wrapQueryRef(internalQueryRef) {\n var _a;\n var ref = (_a = {\n toPromise: function () {\n // We avoid resolving this promise with the query data because we want to\n // discourage using the server data directly from the queryRef. Instead,\n // the data should be accessed through `useReadQuery`. When the server\n // data is needed, its better to use `client.query()` directly.\n //\n // Here we resolve with the ref itself to make using this in React Router\n // or TanStack Router `loader` functions a bit more ergonomic e.g.\n //\n // function loader() {\n // return { queryRef: await preloadQuery(query).toPromise() }\n // }\n return getWrappedPromise(ref).then(function () { return ref; });\n }\n },\n _a[QUERY_REFERENCE_SYMBOL] = internalQueryRef,\n _a[PROMISE_SYMBOL] = internalQueryRef.promise,\n _a);\n return ref;\n}\nexport function getWrappedPromise(queryRef) {\n var internalQueryRef = unwrapQueryRef(queryRef);\n return internalQueryRef.promise.status === \"fulfilled\" ?\n internalQueryRef.promise\n : queryRef[PROMISE_SYMBOL];\n}\nexport function unwrapQueryRef(queryRef) {\n return queryRef[QUERY_REFERENCE_SYMBOL];\n}\nexport function updateWrappedQueryRef(queryRef, promise) {\n queryRef[PROMISE_SYMBOL] = promise;\n}\nvar OBSERVED_CHANGED_OPTIONS = [\n \"canonizeResults\",\n \"context\",\n \"errorPolicy\",\n \"fetchPolicy\",\n \"refetchWritePolicy\",\n \"returnPartialData\",\n];\nvar InternalQueryReference = /** @class */ (function () {\n function InternalQueryReference(observable, options) {\n var _this = this;\n this.key = {};\n this.listeners = new Set();\n this.references = 0;\n this.handleNext = this.handleNext.bind(this);\n this.handleError = this.handleError.bind(this);\n this.dispose = this.dispose.bind(this);\n this.observable = observable;\n if (options.onDispose) {\n this.onDispose = options.onDispose;\n }\n this.setResult();\n this.subscribeToQuery();\n // Start a timer that will automatically dispose of the query if the\n // suspended resource does not use this queryRef in the given time. This\n // helps prevent memory leaks when a component has unmounted before the\n // query has finished loading.\n var startDisposeTimer = function () {\n var _a;\n if (!_this.references) {\n _this.autoDisposeTimeoutId = setTimeout(_this.dispose, (_a = options.autoDisposeTimeoutMs) !== null && _a !== void 0 ? _a : 30000);\n }\n };\n // We wait until the request has settled to ensure we don't dispose of the\n // query ref before the request finishes, otherwise we would leave the\n // promise in a pending state rendering the suspense boundary indefinitely.\n this.promise.then(startDisposeTimer, startDisposeTimer);\n }\n Object.defineProperty(InternalQueryReference.prototype, \"disposed\", {\n get: function () {\n return this.subscription.closed;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(InternalQueryReference.prototype, \"watchQueryOptions\", {\n get: function () {\n return this.observable.options;\n },\n enumerable: false,\n configurable: true\n });\n InternalQueryReference.prototype.reinitialize = function () {\n var observable = this.observable;\n var originalFetchPolicy = this.watchQueryOptions.fetchPolicy;\n try {\n if (originalFetchPolicy !== \"no-cache\") {\n observable.resetLastResults();\n observable.silentSetOptions({ fetchPolicy: \"cache-first\" });\n }\n else {\n observable.silentSetOptions({ fetchPolicy: \"standby\" });\n }\n this.subscribeToQuery();\n if (originalFetchPolicy === \"no-cache\") {\n return;\n }\n observable.resetDiff();\n this.setResult();\n }\n finally {\n observable.silentSetOptions({ fetchPolicy: originalFetchPolicy });\n }\n };\n InternalQueryReference.prototype.retain = function () {\n var _this = this;\n this.references++;\n clearTimeout(this.autoDisposeTimeoutId);\n var disposed = false;\n return function () {\n if (disposed) {\n return;\n }\n disposed = true;\n _this.references--;\n // Wait before fully disposing in case the app is running in strict mode.\n setTimeout(function () {\n if (!_this.references) {\n _this.dispose();\n }\n });\n };\n };\n InternalQueryReference.prototype.didChangeOptions = function (watchQueryOptions) {\n var _this = this;\n return OBSERVED_CHANGED_OPTIONS.some(function (option) {\n return !equal(_this.watchQueryOptions[option], watchQueryOptions[option]);\n });\n };\n InternalQueryReference.prototype.applyOptions = function (watchQueryOptions) {\n var _a = this.watchQueryOptions, currentFetchPolicy = _a.fetchPolicy, currentCanonizeResults = _a.canonizeResults;\n // \"standby\" is used when `skip` is set to `true`. Detect when we've\n // enabled the query (i.e. `skip` is `false`) to execute a network request.\n if (currentFetchPolicy === \"standby\" &&\n currentFetchPolicy !== watchQueryOptions.fetchPolicy) {\n this.initiateFetch(this.observable.reobserve(watchQueryOptions));\n }\n else {\n this.observable.silentSetOptions(watchQueryOptions);\n if (currentCanonizeResults !== watchQueryOptions.canonizeResults) {\n this.result = __assign(__assign({}, this.result), this.observable.getCurrentResult());\n this.promise = createFulfilledPromise(this.result);\n }\n }\n return this.promise;\n };\n InternalQueryReference.prototype.listen = function (listener) {\n var _this = this;\n this.listeners.add(listener);\n return function () {\n _this.listeners.delete(listener);\n };\n };\n InternalQueryReference.prototype.refetch = function (variables) {\n return this.initiateFetch(this.observable.refetch(variables));\n };\n InternalQueryReference.prototype.fetchMore = function (options) {\n return this.initiateFetch(this.observable.fetchMore(options));\n };\n InternalQueryReference.prototype.dispose = function () {\n this.subscription.unsubscribe();\n this.onDispose();\n };\n InternalQueryReference.prototype.onDispose = function () {\n // noop. overridable by options\n };\n InternalQueryReference.prototype.handleNext = function (result) {\n var _a;\n switch (this.promise.status) {\n case \"pending\": {\n // Maintain the last successful `data` value if the next result does not\n // have one.\n if (result.data === void 0) {\n result.data = this.result.data;\n }\n this.result = result;\n (_a = this.resolve) === null || _a === void 0 ? void 0 : _a.call(this, result);\n break;\n }\n default: {\n // This occurs when switching to a result that is fully cached when this\n // class is instantiated. ObservableQuery will run reobserve when\n // subscribing, which delivers a result from the cache.\n if (result.data === this.result.data) {\n return;\n }\n // Maintain the last successful `data` value if the next result does not\n // have one.\n if (result.data === void 0) {\n result.data = this.result.data;\n }\n this.result = result;\n this.promise = createFulfilledPromise(result);\n this.deliver(this.promise);\n break;\n }\n }\n };\n InternalQueryReference.prototype.handleError = function (error) {\n var _a;\n this.subscription.unsubscribe();\n this.subscription = this.observable.resubscribeAfterError(this.handleNext, this.handleError);\n switch (this.promise.status) {\n case \"pending\": {\n (_a = this.reject) === null || _a === void 0 ? void 0 : _a.call(this, error);\n break;\n }\n default: {\n this.promise = createRejectedPromise(error);\n this.deliver(this.promise);\n }\n }\n };\n InternalQueryReference.prototype.deliver = function (promise) {\n this.listeners.forEach(function (listener) { return listener(promise); });\n };\n InternalQueryReference.prototype.initiateFetch = function (returnedPromise) {\n var _this = this;\n this.promise = this.createPendingPromise();\n this.promise.catch(function () { });\n // If the data returned from the fetch is deeply equal to the data already\n // in the cache, `handleNext` will not be triggered leaving the promise we\n // created in a pending state forever. To avoid this situtation, we attempt\n // to resolve the promise if `handleNext` hasn't been run to ensure the\n // promise is resolved correctly.\n returnedPromise\n .then(function (result) {\n var _a;\n if (_this.promise.status === \"pending\") {\n _this.result = result;\n (_a = _this.resolve) === null || _a === void 0 ? void 0 : _a.call(_this, result);\n }\n })\n .catch(function () { });\n return returnedPromise;\n };\n InternalQueryReference.prototype.subscribeToQuery = function () {\n var _this = this;\n this.subscription = this.observable\n .filter(function (result) { return !equal(result.data, {}) && !equal(result, _this.result); })\n .subscribe(this.handleNext, this.handleError);\n };\n InternalQueryReference.prototype.setResult = function () {\n // Don't save this result as last result to prevent delivery of last result\n // when first subscribing\n var result = this.observable.getCurrentResult(false);\n if (equal(result, this.result)) {\n return;\n }\n this.result = result;\n this.promise =\n (result.data &&\n (!result.partial || this.watchQueryOptions.returnPartialData)) ?\n createFulfilledPromise(result)\n : this.createPendingPromise();\n };\n InternalQueryReference.prototype.createPendingPromise = function () {\n var _this = this;\n return wrapPromiseWithState(new Promise(function (resolve, reject) {\n _this.resolve = resolve;\n _this.reject = reject;\n }));\n };\n return InternalQueryReference;\n}());\nexport { InternalQueryReference };\n//# sourceMappingURL=QueryReference.js.map","import { __assign } from \"tslib\";\nimport { InternalQueryReference, wrapQueryRef, } from \"../cache/QueryReference.js\";\n/**\n * A higher order function that returns a `preloadQuery` function which\n * can be used to begin loading a query with the given `client`. This is useful\n * when you want to start loading a query as early as possible outside of a\n * React component.\n *\n * @param client - The ApolloClient instance that will be used to load queries\n * from the returned `preloadQuery` function.\n * @returns The `preloadQuery` function.\n *\n * @example\n * ```js\n * const preloadQuery = createQueryPreloader(client);\n * ```\n * @experimental\n */\nexport function createQueryPreloader(client) {\n return function preloadQuery(query, options) {\n var _a, _b;\n if (options === void 0) { options = Object.create(null); }\n var queryRef = new InternalQueryReference(client.watchQuery(__assign(__assign({}, options), { query: query })), {\n autoDisposeTimeoutMs: (_b = (_a = client.defaultOptions.react) === null || _a === void 0 ? void 0 : _a.suspense) === null || _b === void 0 ? void 0 : _b.autoDisposeTimeoutMs,\n });\n return wrapQueryRef(queryRef);\n };\n}\n//# sourceMappingURL=createQueryPreloader.js.map"],"names":["equal","__assign","createFulfilledPromise","createRejectedPromise","wrapPromiseWithState"],"mappings":";;;;;;;;;;;;AAIA,IAAI,sBAAsB,GAAG,MAAM,EAAE,CAAC;AACtC,IAAI,cAAc,GAAG,MAAM,EAAE,CAAC;AACvB,SAAS,YAAY,CAAC,gBAAgB,EAAE;AAC/C,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,IAAI,GAAG,IAAI,EAAE,GAAG;AACpB,YAAY,SAAS,EAAE,YAAY;AAYnC,gBAAgB,OAAO,iBAAiB,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,GAAG,CAAC,EAAE,CAAC,CAAC;AAChF,aAAa;AACb,SAAS;AACT,QAAQ,EAAE,CAAC,sBAAsB,CAAC,GAAG,gBAAgB;AACrD,QAAQ,EAAE,CAAC,cAAc,CAAC,GAAG,gBAAgB,CAAC,OAAO;AACrD,QAAQ,EAAE,CAAC,CAAC;AACZ,IAAI,OAAO,GAAG,CAAC;AACf,CAAC;AACM,SAAS,iBAAiB,CAAC,QAAQ,EAAE;AAC5C,IAAI,IAAI,gBAAgB,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;AACpD,IAAI,OAAO,gBAAgB,CAAC,OAAO,CAAC,MAAM,KAAK,WAAW;AAC1D,QAAQ,gBAAgB,CAAC,OAAO;AAChC,UAAU,QAAQ,CAAC,cAAc,CAAC,CAAC;AACnC,CAAC;AACM,SAAS,cAAc,CAAC,QAAQ,EAAE;AACzC,IAAI,OAAO,QAAQ,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,CAAC;;ACjQG,SAAS,oBAAoB,CAAC,MAAM,EAAE;AAC7C,IAAI,OAAO,SAAS,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE;AACjD,QAAQ,IAAI,EAAE,EAAE,EAAE,CAAC;AACnB,QAAQ,IAAI,OAAO,KAAK,KAAK,CAAC,EAAE,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE;AAClE,QAAQ,IAAI,QAAQ,GAAG,IAAI,sBAAsB,CAAC,MAAM,CAAC,UAAU,CAACH,cAAQ,CAACA,cAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE;AACxH,YAAY,oBAAoB,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,QAAQ,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,oBAAoB;AACzL,SAAS,CAAC,CAAC;AACX,QAAQ,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC;AACtC,KAAK,CAAC;AACN;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"react.cjs","sources":["query-preloader/createQueryPreloader.js"],"sourcesContent":["import { __assign } from \"tslib\";\nimport { InternalQueryReference, wrapQueryRef } from \"../internal/index.js\";\n/**\n * A higher order function that returns a `preloadQuery` function which\n * can be used to begin loading a query with the given `client`. This is useful\n * when you want to start loading a query as early as possible outside of a\n * React component.\n *\n * @param client - The ApolloClient instance that will be used to load queries\n * from the returned `preloadQuery` function.\n * @returns The `preloadQuery` function.\n *\n * @example\n * ```js\n * const preloadQuery = createQueryPreloader(client);\n * ```\n * @experimental\n */\nexport function createQueryPreloader(client) {\n return function preloadQuery(query, options) {\n var _a, _b;\n if (options === void 0) { options = Object.create(null); }\n var queryRef = new InternalQueryReference(client.watchQuery(__assign(__assign({}, options), { query: query })), {\n autoDisposeTimeoutMs: (_b = (_a = client.defaultOptions.react) === null || _a === void 0 ? void 0 : _a.suspense) === null || _b === void 0 ? void 0 : _b.autoDisposeTimeoutMs,\n });\n return wrapQueryRef(queryRef);\n };\n}\n//# sourceMappingURL=createQueryPreloader.js.map"],"names":["InternalQueryReference","__assign","wrapQueryRef"],"mappings":";;;;;;;;;;;AAkBO,SAAS,oBAAoB,CAAC,MAAM,EAAE;AAC7C,IAAI,OAAO,SAAS,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE;AACjD,QAAQ,IAAI,EAAE,EAAE,EAAE,CAAC;AACnB,QAAQ,IAAI,OAAO,KAAK,KAAK,CAAC,EAAE,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE;AAClE,QAAQ,IAAI,QAAQ,GAAG,IAAIA,+BAAsB,CAAC,MAAM,CAAC,UAAU,CAACC,cAAQ,CAACA,cAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE;AACxH,YAAY,oBAAoB,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,QAAQ,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,oBAAoB;AACzL,SAAS,CAAC,CAAC;AACX,QAAQ,OAAOC,qBAAY,CAAC,QAAQ,CAAC,CAAC;AACtC,KAAK,CAAC;AACN;;;;;;;;;;;;;;"}
|