Skip to content

Commit f561274

Browse files
committed
Just write the correct returnPartialData from options
1 parent 887a5b1 commit f561274

4 files changed

Lines changed: 9 additions & 25 deletions

File tree

src/cache/core/cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export abstract class ApolloCache {
201201
TVariables extends OperationVariables = OperationVariables,
202202
>(
203203
query: Cache.DiffOptions<TData, TVariables> & {
204-
[handleIncrementalSymbol]: DiffIncrementalInfo;
204+
[handleIncrementalSymbol]: DiffIncrementalInfo | undefined;
205205
}
206206
): Cache.InternalDiffResultWithDataState<TData> | Cache.DiffResult<TData>;
207207

src/cache/inmemory/readFromStore.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,11 @@ export class StoreReader {
315315
query,
316316
rootId = "ROOT_QUERY",
317317
variables,
318+
returnPartialData = true,
318319
[handleIncrementalSymbol]: handleIncremental,
319-
...options
320320
}: DiffQueryAgainstStoreOptions): Cache.DiffResult<T> & {
321321
dataState?: "empty" | "partial" | "streaming" | "complete";
322322
} {
323-
const returnPartialData =
324-
handleIncremental?.returnPartialData ?? options.returnPartialData ?? true;
325323
const policies = this.config.cache.policies;
326324

327325
variables = {

src/cache/inmemory/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ export type ReadQueryOptions = {
136136

137137
/** @internal */
138138
export interface DiffIncrementalInfo {
139-
returnPartialData: boolean | undefined;
140139
streamInfo?: StreamInfoTrie;
141140
deferInfo?: DeferInfoTrie;
142141
}

src/core/QueryInfo.ts

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,12 @@ export class QueryInfo<
389389
networkStatus !== NetworkStatus.refetch;
390390

391391
const { dataState, result: diffResult } = this.getDiff(
392-
diffOptions,
393-
this.getIncrementalInfo(result, {
392+
{
393+
...diffOptions,
394394
// Never deliver partial data for network-only requests
395395
returnPartialData: returnPartialData && !isNetworkOnly,
396-
isNetworkOnly,
397-
})
396+
},
397+
this.getIncrementalInfo(result, { isNetworkOnly })
398398
);
399399

400400
if (
@@ -415,17 +415,11 @@ export class QueryInfo<
415415

416416
private getIncrementalInfo(
417417
result: MarkQueryResult<any, ExtensionsWithStreamInfo>,
418-
{
419-
isNetworkOnly,
420-
returnPartialData,
421-
}: { isNetworkOnly: boolean; returnPartialData: boolean | undefined }
418+
{ isNetworkOnly }: { isNetworkOnly: boolean }
422419
) {
423420
const pending = this.incremental?.pending ?? [];
424421
const streamInfo = result.extensions?.[streamInfoSymbol]?.deref();
425-
const incrementalInfo: DiffIncrementalInfo = {
426-
streamInfo,
427-
returnPartialData,
428-
};
422+
const incrementalInfo: DiffIncrementalInfo = { streamInfo };
429423

430424
// We don't want to deliver stream items or complete defer boundaries
431425
// for a network-only request if they haven't yet streamed from the
@@ -453,14 +447,7 @@ export class QueryInfo<
453447
): Cache.InternalDiffResultWithDataState<TData> {
454448
const diff = this.cache.diff({
455449
...options,
456-
// returnPartialData is overridden for backwards compatibility with caches
457-
// that don't handle incremental results. Without this, in-flight
458-
// incremental cache data would come back null when returnPartialData is
459-
// false due to the partial result.
460-
returnPartialData: true,
461-
[handleIncrementalSymbol]: incrementalInfo || {
462-
returnPartialData: options.returnPartialData,
463-
},
450+
[handleIncrementalSymbol]: incrementalInfo,
464451
});
465452

466453
if ("dataState" in diff) {

0 commit comments

Comments
 (0)