Skip to content

Commit 14498bd

Browse files
committed
Ensure we apply diff result when data is only missing at defer boundary
1 parent e7c380b commit 14498bd

2 files changed

Lines changed: 186 additions & 189 deletions

File tree

src/core/QueryInfo.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -382,19 +382,22 @@ export class QueryInfo<
382382
data: diff.result,
383383
dataState: "complete",
384384
};
385-
} else if (
386-
this.hasNext &&
387-
returnPartialData &&
388-
diff.result !== null
389-
) {
390-
result = {
391-
...result,
392-
data: diff.result,
393-
dataState:
394-
isStreamingPartial(diff, query, variables) ? "partial" : (
395-
"streaming"
396-
),
397-
};
385+
} else if (this.hasNext && diff.result !== null) {
386+
const isPartial = isStreamingPartial(diff, query, variables);
387+
388+
// If we tolerate partial results always apply `diff.result` to
389+
// ensure we return the result of any transforms in cache read
390+
// functions or custom scalars. If we don't tolerate partial
391+
// results, we only want to apply the diff result if the only hole
392+
// in the data is at a defer boundary (e.g.
393+
// `diff.complete === false && isStreamingPartial === false`)
394+
if (returnPartialData || !isPartial) {
395+
result = {
396+
...result,
397+
data: diff.result,
398+
dataState: isPartial ? "partial" : "streaming",
399+
};
400+
}
398401
}
399402
},
400403
});

0 commit comments

Comments
 (0)