@apollo/client 4.3.0-alpha.3 → 4.3.0-alpha.4
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/CHANGELOG.md +14 -0
- package/__cjs/cache/core/types/Cache.d.cts +25 -0
- package/__cjs/cache/index.cjs.map +1 -1
- package/__cjs/cache/index.d.cts +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.cjs +4 -0
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +7 -3
- package/__cjs/cache/inmemory/readFromStore.cjs +453 -42
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/readFromStore.d.cts +11 -2
- package/__cjs/cache/inmemory/types.d.cts +11 -1
- package/__cjs/cache/inmemory/writeToStore.cjs +1 -5
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/core/QueryInfo.cjs +86 -172
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +8 -2
- package/__cjs/core/QueryManager.cjs +3 -1
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
- package/__cjs/incremental/handlers/defer20220824.d.cts +2 -4
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs +20 -12
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +1 -1
- package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +5 -5
- package/__cjs/incremental/types.d.cts +16 -3
- package/__cjs/utilities/caching/sizes.cjs.map +1 -1
- package/__cjs/utilities/caching/sizes.d.cts +39 -1
- package/__cjs/utilities/internal/StreamArrayState.cjs +27 -0
- package/__cjs/utilities/internal/StreamArrayState.cjs.map +1 -0
- package/__cjs/utilities/internal/StreamArrayState.d.cts +12 -0
- package/__cjs/utilities/internal/constants.cjs +20 -1
- package/__cjs/utilities/internal/constants.cjs.map +1 -1
- package/__cjs/utilities/internal/constants.d.cts +19 -0
- package/__cjs/utilities/internal/getFragmentFromSelection.cjs +1 -1
- package/__cjs/utilities/internal/getFragmentFromSelection.cjs.map +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.cjs +6 -0
- package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.d.cts +4 -0
- package/__cjs/utilities/internal/index.cjs +9 -4
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +5 -3
- package/__cjs/utilities/internal/isDeferredFragment.cjs +19 -4
- package/__cjs/utilities/internal/isDeferredFragment.cjs.map +1 -1
- package/__cjs/utilities/internal/isDeferredFragment.d.cts +6 -1
- package/__cjs/utilities/internal/isStreamField.cjs +37 -0
- package/__cjs/utilities/internal/isStreamField.cjs.map +1 -0
- package/__cjs/utilities/internal/isStreamField.d.cts +9 -0
- package/__cjs/utilities/internal/makeStreamInfoTrie.cjs +17 -0
- package/__cjs/utilities/internal/makeStreamInfoTrie.cjs.map +1 -0
- package/__cjs/utilities/internal/makeStreamInfoTrie.d.cts +8 -0
- package/__cjs/utilities/internal/types/DeferInfo.cjs +3 -0
- package/__cjs/utilities/internal/types/DeferInfo.cjs.map +1 -0
- package/__cjs/utilities/internal/types/DeferInfo.d.cts +10 -0
- package/__cjs/utilities/internal/types/StreamInfoTrie.d.cts +2 -0
- package/__cjs/version.cjs +1 -1
- package/cache/core/types/Cache.d.ts +25 -0
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/index.d.ts +1 -1
- package/cache/index.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +7 -3
- package/cache/inmemory/inMemoryCache.js +5 -1
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +11 -2
- package/cache/inmemory/readFromStore.js +454 -43
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +12 -2
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.js +2 -6
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/QueryInfo.d.ts +8 -2
- package/core/QueryInfo.js +87 -173
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.js +3 -1
- package/core/QueryManager.js.map +1 -1
- package/incremental/handlers/defer20220824.d.ts +2 -4
- package/incremental/handlers/defer20220824.js.map +1 -1
- package/incremental/handlers/graphql17Alpha9.d.ts +5 -5
- package/incremental/handlers/graphql17Alpha9.js +21 -13
- package/incremental/handlers/graphql17Alpha9.js.map +1 -1
- package/incremental/types.d.ts +16 -3
- package/incremental/types.js.map +1 -1
- package/package.json +1 -1
- package/utilities/caching/sizes.d.ts +39 -1
- package/utilities/caching/sizes.js.map +1 -1
- package/utilities/internal/StreamArrayState.d.ts +12 -0
- package/utilities/internal/StreamArrayState.js +23 -0
- package/utilities/internal/StreamArrayState.js.map +1 -0
- package/utilities/internal/constants.d.ts +19 -0
- package/utilities/internal/constants.js +19 -0
- package/utilities/internal/constants.js.map +1 -1
- package/utilities/internal/getFragmentFromSelection.js +1 -1
- package/utilities/internal/getFragmentFromSelection.js.map +1 -1
- package/utilities/internal/getMemoryInternals.d.ts +4 -0
- package/utilities/internal/getMemoryInternals.js +6 -0
- package/utilities/internal/getMemoryInternals.js.map +1 -1
- package/utilities/internal/index.d.ts +5 -3
- package/utilities/internal/index.js +4 -2
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/isDeferredFragment.d.ts +7 -2
- package/utilities/internal/isDeferredFragment.js +19 -4
- package/utilities/internal/isDeferredFragment.js.map +1 -1
- package/utilities/internal/isStreamField.d.ts +9 -0
- package/utilities/internal/isStreamField.js +34 -0
- package/utilities/internal/isStreamField.js.map +1 -0
- package/utilities/internal/makeStreamInfoTrie.d.ts +8 -0
- package/utilities/internal/makeStreamInfoTrie.js +14 -0
- package/utilities/internal/makeStreamInfoTrie.js.map +1 -0
- package/utilities/internal/types/DeferInfo.d.ts +10 -0
- package/utilities/internal/types/DeferInfo.js +2 -0
- package/utilities/internal/types/DeferInfo.js.map +1 -0
- package/utilities/internal/types/StreamInfoTrie.d.ts +2 -0
- package/utilities/internal/types/StreamInfoTrie.js.map +1 -1
- package/version.js +1 -1
- package/__cjs/utilities/internal/collectSiblingFields.cjs +0 -61
- package/__cjs/utilities/internal/collectSiblingFields.cjs.map +0 -1
- package/__cjs/utilities/internal/collectSiblingFields.d.cts +0 -21
- package/utilities/internal/collectSiblingFields.d.ts +0 -21
- package/utilities/internal/collectSiblingFields.js +0 -58
- package/utilities/internal/collectSiblingFields.js.map +0 -1
package/core/QueryInfo.d.ts
CHANGED
|
@@ -4,10 +4,11 @@ import type { ApolloLink } from "@apollo/client/link";
|
|
|
4
4
|
import type { Unmasked } from "@apollo/client/masking";
|
|
5
5
|
import type { ExtensionsWithStreamInfo } from "@apollo/client/utilities/internal";
|
|
6
6
|
import type { ApolloClient } from "./ApolloClient.js";
|
|
7
|
+
import { NetworkStatus } from "./networkStatus.js";
|
|
7
8
|
import type { ObservableQuery } from "./ObservableQuery.js";
|
|
8
9
|
import type { QueryManager } from "./QueryManager.js";
|
|
9
10
|
import type { DataValue, DefaultContext, InternalRefetchQueriesInclude, MutationUpdaterFunction, NormalizedExecutionResult, OnQueryUpdated, OperationVariables, TypedDocumentNode } from "./types.js";
|
|
10
|
-
import type { ErrorPolicy } from "./watchQueryOptions.js";
|
|
11
|
+
import type { ErrorPolicy, WatchQueryFetchPolicy } from "./watchQueryOptions.js";
|
|
11
12
|
type UpdateQueries<TData> = ApolloClient.MutateOptions<TData, any, any>["updateQueries"];
|
|
12
13
|
export declare const enum CacheWriteBehavior {
|
|
13
14
|
FORBID = 0,
|
|
@@ -50,7 +51,12 @@ export declare class QueryInfo<TData, TVariables extends OperationVariables = Op
|
|
|
50
51
|
private shouldWrite;
|
|
51
52
|
get hasNext(): boolean;
|
|
52
53
|
private maybeHandleIncrementalResult;
|
|
53
|
-
markQueryResult(incoming: ApolloLink.Result<TData>, { document: query, variables, errorPolicy, cacheWriteBehavior, returnPartialData, }: OperationInfo<TData, TVariables>
|
|
54
|
+
markQueryResult(incoming: ApolloLink.Result<TData>, { document: query, variables, errorPolicy, cacheWriteBehavior, returnPartialData, fetchPolicy, networkStatus, }: OperationInfo<TData, TVariables> & {
|
|
55
|
+
fetchPolicy: WatchQueryFetchPolicy;
|
|
56
|
+
networkStatus: NetworkStatus;
|
|
57
|
+
}): MarkQueryResult<DataValue.Complete<TData> | DataValue.Streaming<TData>, ExtensionsWithStreamInfo>;
|
|
58
|
+
private getIncrementalInfo;
|
|
59
|
+
private getDiff;
|
|
54
60
|
markMutationResult(incoming: ApolloLink.Result<TData>, mutation: OperationInfo<TData, TVariables, CacheWriteBehavior.FORBID | CacheWriteBehavior.MERGE> & {
|
|
55
61
|
context?: DefaultContext;
|
|
56
62
|
updateQueries: UpdateQueries<TData>;
|
package/core/QueryInfo.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { equal } from "@wry/equality";
|
|
2
|
-
import {
|
|
2
|
+
import { Trie } from "@wry/trie";
|
|
3
|
+
import { getOperationName, graphQLResultHasError, handleIncrementalSymbol, hasDirectives, streamInfoSymbol, } from "@apollo/client/utilities/internal";
|
|
3
4
|
import { invariant } from "@apollo/client/utilities/invariant";
|
|
5
|
+
import { NetworkStatus } from "./networkStatus.js";
|
|
4
6
|
const IGNORE = {};
|
|
5
7
|
const destructiveMethodCounts = new WeakMap();
|
|
6
8
|
function wrapDestructiveCacheMethod(cache, methodName) {
|
|
@@ -95,38 +97,50 @@ export class QueryInfo {
|
|
|
95
97
|
}
|
|
96
98
|
return incoming;
|
|
97
99
|
}
|
|
98
|
-
markQueryResult(incoming, { document: query, variables, errorPolicy, cacheWriteBehavior, returnPartialData, }) {
|
|
100
|
+
markQueryResult(incoming, { document: query, variables, errorPolicy, cacheWriteBehavior, returnPartialData, fetchPolicy, networkStatus, }) {
|
|
99
101
|
const diffOptions = {
|
|
100
102
|
query,
|
|
101
103
|
variables,
|
|
102
|
-
returnPartialData: true,
|
|
103
104
|
optimistic: true,
|
|
104
105
|
};
|
|
105
106
|
// Cancel the pending notify timeout (if it exists) to prevent extraneous network
|
|
106
107
|
// requests. To allow future notify timeouts, diff and dirty are reset as well.
|
|
107
108
|
this.observableQuery?.["resetNotifications"]();
|
|
108
109
|
const skipCache = cacheWriteBehavior === 0 /* CacheWriteBehavior.FORBID */;
|
|
109
|
-
const lastDiff = skipCache ? undefined : this.
|
|
110
|
+
const lastDiff = skipCache ? undefined : (this.getDiff({
|
|
111
|
+
...diffOptions,
|
|
112
|
+
// Always request partial data to ensure the network incremental
|
|
113
|
+
// result is merged with all existing data (especially true to
|
|
114
|
+
// maintain @stream arrays with partial list items in the right order)
|
|
115
|
+
returnPartialData: true,
|
|
116
|
+
}));
|
|
110
117
|
const incrementalResult = this.maybeHandleIncrementalResult(lastDiff?.result, incoming, query);
|
|
111
118
|
let result = {
|
|
112
119
|
...incrementalResult,
|
|
113
|
-
dataState: incrementalResult.data == null ? "empty"
|
|
114
|
-
: this.hasNext ? "streaming"
|
|
115
|
-
: "complete",
|
|
120
|
+
dataState: incrementalResult.data == null ? "empty" : "complete",
|
|
116
121
|
};
|
|
117
122
|
if (skipCache) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
123
|
+
const hasPendingDefer = this.incremental?.pending?.some((pending) => this.incremental?.getPendingType?.(pending.id) === "defer");
|
|
124
|
+
if (hasPendingDefer ||
|
|
125
|
+
// The Defer20220824Handler cannot track pending/completed incremental
|
|
126
|
+
// chunks due to its data format so we naively set dataState to
|
|
127
|
+
// streaming if we are still processing chunks. The only case where
|
|
128
|
+
// streaming is incorrect and should actually be complete is when
|
|
129
|
+
// both a @defer and @stream boundary is present and the @defer chunk
|
|
130
|
+
// has completed before the `@stream` array.
|
|
131
|
+
//
|
|
132
|
+
// Assigning the naive "streaming" value avoids a much more expensive
|
|
133
|
+
// pass over `result.data` that would otherwise need to traverse the
|
|
134
|
+
// selection sets and evaluate the data object at each defer boundary
|
|
135
|
+
// to see if it fulfills the selection set. For such a narrow case where
|
|
136
|
+
// its incorrect on a format that is now outdated is not worth the
|
|
137
|
+
// fix so we are ok with reporting a `streaming` here.
|
|
138
|
+
(!this.incremental?.pending &&
|
|
139
|
+
this.hasNext &&
|
|
140
|
+
hasDirectives(["defer"], query))) {
|
|
141
|
+
result.dataState = "streaming";
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
130
144
|
}
|
|
131
145
|
if (shouldWriteResult(result, errorPolicy)) {
|
|
132
146
|
// Using a transaction here so we have a chance to read the result
|
|
@@ -144,7 +158,8 @@ export class QueryInfo {
|
|
|
144
158
|
}
|
|
145
159
|
},
|
|
146
160
|
update: (cache) => {
|
|
147
|
-
|
|
161
|
+
const shouldWrite = this.shouldWrite(result, variables);
|
|
162
|
+
if (shouldWrite) {
|
|
148
163
|
cache.writeQuery({
|
|
149
164
|
query,
|
|
150
165
|
data: result.data,
|
|
@@ -204,34 +219,17 @@ export class QueryInfo {
|
|
|
204
219
|
// If the previous this.diff was incomplete, fall through to
|
|
205
220
|
// re-reading the latest data with cache.diff, below.
|
|
206
221
|
}
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
else if (this.hasNext && diff.result !== null) {
|
|
221
|
-
const isPartial = isStreamingPartial(diff, query, variables);
|
|
222
|
-
// If we tolerate partial results always apply `diff.result` to
|
|
223
|
-
// ensure we return the result of any transforms in cache read
|
|
224
|
-
// functions or custom scalars. If we don't tolerate partial
|
|
225
|
-
// results, we only want to apply the diff result if the only hole
|
|
226
|
-
// in the data is at a defer boundary (e.g.
|
|
227
|
-
// `diff.complete === false && isStreamingPartial === false`)
|
|
228
|
-
if (returnPartialData || !isPartial) {
|
|
229
|
-
result = {
|
|
230
|
-
...result,
|
|
231
|
-
data: diff.result,
|
|
232
|
-
dataState: isPartial ? "partial" : "streaming",
|
|
233
|
-
};
|
|
234
|
-
}
|
|
222
|
+
const isNetworkOnly = fetchPolicy === "network-only" &&
|
|
223
|
+
networkStatus !== NetworkStatus.refetch;
|
|
224
|
+
const { dataState, result: diffResult } = this.getDiff({
|
|
225
|
+
...diffOptions,
|
|
226
|
+
// Never deliver partial data for network-only requests
|
|
227
|
+
returnPartialData: returnPartialData && !isNetworkOnly,
|
|
228
|
+
}, this.getIncrementalInfo(result, { isNetworkOnly }));
|
|
229
|
+
if (dataState === "complete" ||
|
|
230
|
+
(returnPartialData && dataState === "partial" && shouldWrite) ||
|
|
231
|
+
(this.hasNext && dataState === "streaming")) {
|
|
232
|
+
result = { ...result, data: diffResult, dataState };
|
|
235
233
|
}
|
|
236
234
|
},
|
|
237
235
|
});
|
|
@@ -241,6 +239,47 @@ export class QueryInfo {
|
|
|
241
239
|
}
|
|
242
240
|
return result;
|
|
243
241
|
}
|
|
242
|
+
getIncrementalInfo(result, { isNetworkOnly }) {
|
|
243
|
+
const pending = this.incremental?.pending ?? [];
|
|
244
|
+
const streamInfo = result.extensions?.[streamInfoSymbol]?.deref();
|
|
245
|
+
const incrementalInfo = { streamInfo };
|
|
246
|
+
// We don't want to deliver stream items or complete defer boundaries
|
|
247
|
+
// for a network-only request if they haven't yet streamed from the
|
|
248
|
+
// network. We record all the still-pending paths so that cache.diff
|
|
249
|
+
// can prune complete defer/stream boundaries at those paths.
|
|
250
|
+
if (isNetworkOnly) {
|
|
251
|
+
for (const item of pending) {
|
|
252
|
+
const type = this.incremental?.getPendingType?.(item.id);
|
|
253
|
+
if (type === "defer") {
|
|
254
|
+
incrementalInfo.deferInfo ||= new Trie(true, () => true);
|
|
255
|
+
incrementalInfo.deferInfo.lookupArray(item.path);
|
|
256
|
+
}
|
|
257
|
+
else if (streamInfo && type === "stream") {
|
|
258
|
+
streamInfo.lookupArray(item.path).state.truncate = true;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return incrementalInfo;
|
|
263
|
+
}
|
|
264
|
+
getDiff(options, incrementalInfo) {
|
|
265
|
+
if (this.cache[handleIncrementalSymbol]) {
|
|
266
|
+
return this.cache.diff({
|
|
267
|
+
...options,
|
|
268
|
+
[handleIncrementalSymbol]: incrementalInfo || true,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
// returnPartialData is overridden for backwards compatibility with caches
|
|
272
|
+
// that don't handle incremental results. Without this, in-flight
|
|
273
|
+
// incremental cache data would come back null when returnPartialData is
|
|
274
|
+
// false due to the partial result.
|
|
275
|
+
const diff = this.cache.diff({ ...options, returnPartialData: true });
|
|
276
|
+
return {
|
|
277
|
+
...diff,
|
|
278
|
+
dataState: diff.complete ? "complete"
|
|
279
|
+
: diff.result === null ? "empty"
|
|
280
|
+
: "partial",
|
|
281
|
+
};
|
|
282
|
+
}
|
|
244
283
|
markMutationResult(incoming, mutation, cache = this.cache) {
|
|
245
284
|
const cacheWrites = [];
|
|
246
285
|
const skipCache = mutation.cacheWriteBehavior === 0 /* CacheWriteBehavior.FORBID */;
|
|
@@ -443,129 +482,4 @@ function shouldWriteResult(result, errorPolicy = "none") {
|
|
|
443
482
|
}
|
|
444
483
|
return writeWithErrors;
|
|
445
484
|
}
|
|
446
|
-
function isStreamingPartial(diff, document, variables) {
|
|
447
|
-
if (!diff.missing)
|
|
448
|
-
return false;
|
|
449
|
-
const fragmentMap = createFragmentMap(getFragmentDefinitions(document));
|
|
450
|
-
return isPartialInSelectionSet(getMainDefinition(document).selectionSet, diff.missing.missing, { fragmentMap, variables });
|
|
451
|
-
}
|
|
452
|
-
function isPartialInSelectionSet(selectionSet, missingTree, context) {
|
|
453
|
-
if (typeof missingTree === "string")
|
|
454
|
-
return true;
|
|
455
|
-
if (missingTree === undefined)
|
|
456
|
-
return false;
|
|
457
|
-
const missingKeys = Object.keys(missingTree);
|
|
458
|
-
if (missingKeys.length > 0 && missingKeys.every(isArrayIndex)) {
|
|
459
|
-
return missingKeys.some((key) => {
|
|
460
|
-
if (typeof missingTree[key] === "string")
|
|
461
|
-
return true;
|
|
462
|
-
return isPartialInSelectionSet(selectionSet, missingTree[key], context);
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
const { fragmentMap, variables } = context;
|
|
466
|
-
for (const selection of selectionSet.selections) {
|
|
467
|
-
if (isField(selection)) {
|
|
468
|
-
if (isTypenameField(selection))
|
|
469
|
-
continue;
|
|
470
|
-
const missing = missingTree[resultKeyNameFromField(selection)];
|
|
471
|
-
// If a missing entry is absent, we have a value for this field
|
|
472
|
-
if (missing === undefined)
|
|
473
|
-
continue;
|
|
474
|
-
if (!selection.selectionSet ||
|
|
475
|
-
isPartialInSelectionSet(selection.selectionSet, missing, context)) {
|
|
476
|
-
return true;
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
else {
|
|
480
|
-
const fragment = getFragmentFromSelection(selection, fragmentMap);
|
|
481
|
-
if (!fragment)
|
|
482
|
-
continue;
|
|
483
|
-
if (isDeferredFragment(selection, variables)) {
|
|
484
|
-
// We need to know the non-deferred fields that might overlap with the
|
|
485
|
-
// deferred selection set so that we accurately report the right
|
|
486
|
-
// dataState when all the non-deferred fields are satisfied and only the
|
|
487
|
-
// selections inside the fragment are missing.
|
|
488
|
-
// For example:
|
|
489
|
-
//
|
|
490
|
-
// {
|
|
491
|
-
// recipient {
|
|
492
|
-
// name
|
|
493
|
-
// }
|
|
494
|
-
// ... @defer {
|
|
495
|
-
// recipient {
|
|
496
|
-
// name
|
|
497
|
-
// email
|
|
498
|
-
// }
|
|
499
|
-
// }
|
|
500
|
-
// }
|
|
501
|
-
//
|
|
502
|
-
// dataState should be `streaming`, not `partial` if `name` is present,
|
|
503
|
-
// but `email` is absent since `name` is not deferred.
|
|
504
|
-
if (isPartialDeferBoundary(fragment.selectionSet, missingTree, collectSiblingFields(selectionSet, {
|
|
505
|
-
...context,
|
|
506
|
-
exclude: selection,
|
|
507
|
-
}), fragmentMap)) {
|
|
508
|
-
return true;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
else if (isPartialInSelectionSet(fragment.selectionSet, missingTree, context)) {
|
|
512
|
-
return true;
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
return false;
|
|
517
|
-
}
|
|
518
|
-
function isPartialDeferBoundary(selectionSet, missing, nonDeferredFields, fragmentMap) {
|
|
519
|
-
// This flag tracks whether all fields in this selection set should contain
|
|
520
|
-
// values or should all be missing. A defer boundary is only partial if some
|
|
521
|
-
// fields are missing. The first selection node will set this value and all
|
|
522
|
-
// sibling fields should match after that. As soon as we get a mismatch, we
|
|
523
|
-
// have a partial defer boundary.
|
|
524
|
-
let shouldContainValues;
|
|
525
|
-
for (const selection of selectionSet.selections) {
|
|
526
|
-
if (isField(selection)) {
|
|
527
|
-
if (isTypenameField(selection))
|
|
528
|
-
continue;
|
|
529
|
-
const name = resultKeyNameFromField(selection);
|
|
530
|
-
const nonDeferredField = nonDeferredFields?.[name];
|
|
531
|
-
// If this field is not exclusive to this selection set, we don't care
|
|
532
|
-
// what the value is as far as the defer boundary is concerned. Ignore it
|
|
533
|
-
// and continue checking other siblings.
|
|
534
|
-
if (nonDeferredField === true)
|
|
535
|
-
continue;
|
|
536
|
-
// The value of missing means different things:
|
|
537
|
-
// - undefined: The field is fully satisfied (i.e. it has a value for the field)
|
|
538
|
-
// - string: the field is fully unsatisfied (no scalar value, or object is
|
|
539
|
-
// missing all fields)
|
|
540
|
-
// - object: The field has a selection set and is partially satisfied.
|
|
541
|
-
const missingField = missing[name];
|
|
542
|
-
if (typeof missingField !== "object") {
|
|
543
|
-
const hasValue = missingField === undefined;
|
|
544
|
-
if (shouldContainValues === undefined) {
|
|
545
|
-
shouldContainValues = hasValue;
|
|
546
|
-
}
|
|
547
|
-
if (hasValue !== shouldContainValues) {
|
|
548
|
-
return true;
|
|
549
|
-
}
|
|
550
|
-
continue;
|
|
551
|
-
}
|
|
552
|
-
if (selection.selectionSet &&
|
|
553
|
-
isPartialDeferBoundary(selection.selectionSet, missingField, nonDeferredField, fragmentMap)) {
|
|
554
|
-
return true;
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
else {
|
|
558
|
-
const fragment = getFragmentFromSelection(selection, fragmentMap);
|
|
559
|
-
if (!fragment)
|
|
560
|
-
continue;
|
|
561
|
-
if (isPartialDeferBoundary(fragment.selectionSet, missing, nonDeferredFields, fragmentMap)) {
|
|
562
|
-
return true;
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
return false;
|
|
567
|
-
}
|
|
568
|
-
function isArrayIndex(key) {
|
|
569
|
-
return /^\d+$/.test(key);
|
|
570
|
-
}
|
|
571
485
|
//# sourceMappingURL=QueryInfo.js.map
|