Skip to content

Commit 9c5ba6e

Browse files
committed
Simplify collectFields for @defer & @stream
1 parent e081838 commit 9c5ba6e

File tree

6 files changed

+322
-465
lines changed

6 files changed

+322
-465
lines changed

src/execution/IncrementalPublisher.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type {
88
GraphQLFormattedError,
99
} from '../error/GraphQLError.js';
1010

11-
import type { GroupedFieldSet } from './collectFields.js';
11+
import type { DeferUsage, GroupedFieldSet } from './collectFields.js';
1212

1313
interface IncrementalUpdate<TData = unknown, TExtensions = ObjMap<unknown>> {
1414
pending: ReadonlyArray<PendingResult>;
@@ -763,7 +763,6 @@ export class DeferredGroupedFieldSetRecord {
763763
path: ReadonlyArray<string | number>;
764764
deferredFragmentRecords: ReadonlyArray<DeferredFragmentRecord>;
765765
groupedFieldSet: GroupedFieldSet;
766-
shouldInitiateDefer: boolean;
767766
errors: Array<GraphQLError>;
768767
data: ObjMap<unknown> | undefined;
769768
sent: boolean;
@@ -772,12 +771,10 @@ export class DeferredGroupedFieldSetRecord {
772771
path: Path | undefined;
773772
deferredFragmentRecords: ReadonlyArray<DeferredFragmentRecord>;
774773
groupedFieldSet: GroupedFieldSet;
775-
shouldInitiateDefer: boolean;
776774
}) {
777775
this.path = pathToArray(opts.path);
778776
this.deferredFragmentRecords = opts.deferredFragmentRecords;
779777
this.groupedFieldSet = opts.groupedFieldSet;
780-
this.shouldInitiateDefer = opts.shouldInitiateDefer;
781778
this.errors = [];
782779
this.sent = false;
783780
}
@@ -786,6 +783,7 @@ export class DeferredGroupedFieldSetRecord {
786783
/** @internal */
787784
export class DeferredFragmentRecord {
788785
path: ReadonlyArray<string | number>;
786+
deferUsage: DeferUsage;
789787
label: string | undefined;
790788
id: string | undefined;
791789
children: Set<SubsequentResultRecord>;
@@ -795,9 +793,10 @@ export class DeferredFragmentRecord {
795793
pendingSent?: boolean;
796794
_pending: Set<DeferredGroupedFieldSetRecord>;
797795

798-
constructor(opts: { path: Path | undefined; label: string | undefined }) {
796+
constructor(opts: { path: Path | undefined; deferUsage: DeferUsage }) {
799797
this.path = pathToArray(opts.path);
800-
this.label = opts.label;
798+
this.label = opts.deferUsage.label;
799+
this.deferUsage = opts.deferUsage;
801800
this.children = new Set();
802801
this.filtered = false;
803802
this.deferredGroupedFieldSetRecords = new Set();

0 commit comments

Comments
 (0)