Skip to content

Commit

Permalink
introduce IncrementalPublisher helper type
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacovCR committed May 16, 2023
1 parent 314f6b8 commit d106636
Showing 1 changed file with 11 additions and 24 deletions.
35 changes: 11 additions & 24 deletions src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ const collectSubfields = memoize3(
* 3) inline fragment "spreads" e.g. `...on Type { a }`
*/

type IncrementalPublisher = Publisher<
IncrementalDataRecord,
SubsequentIncrementalExecutionResult
>;

/**
* Data that must be available at all points during query execution.
*
Expand All @@ -122,10 +127,7 @@ export interface ExecutionContext {
typeResolver: GraphQLTypeResolver<any, any>;
subscribeFieldResolver: GraphQLFieldResolver<any, any>;
errors: Array<GraphQLError>;
publisher: Publisher<
IncrementalDataRecord,
SubsequentIncrementalExecutionResult
>;
publisher: IncrementalPublisher;
}

/**
Expand Down Expand Up @@ -2169,10 +2171,7 @@ function matchesPath(

function getIncrementalResult(
completedRecords: ReadonlySet<IncrementalDataRecord>,
publisher: Publisher<
IncrementalDataRecord,
SubsequentIncrementalExecutionResult
>,
publisher: IncrementalPublisher,
): SubsequentIncrementalExecutionResult | undefined {
const incrementalResults: Array<IncrementalResult> = [];
let encounteredCompletedAsyncIterator = false;
Expand Down Expand Up @@ -2235,19 +2234,13 @@ class DeferredFragmentRecord {
parentContext: IncrementalDataRecord | undefined;
children: Set<IncrementalDataRecord>;
isCompleted: boolean;
_publisher: Publisher<
IncrementalDataRecord,
SubsequentIncrementalExecutionResult
>;
_publisher: IncrementalPublisher;

constructor(opts: {
label: string | undefined;
path: Path | undefined;
parentContext: IncrementalDataRecord | undefined;
publisher: Publisher<
IncrementalDataRecord,
SubsequentIncrementalExecutionResult
>;
publisher: IncrementalPublisher;
}) {
this.type = 'defer';
this.label = opts.label;
Expand Down Expand Up @@ -2291,20 +2284,14 @@ class StreamItemsRecord {
asyncIterator: AsyncIterator<unknown> | undefined;
isCompletedAsyncIterator?: boolean;
isCompleted: boolean;
_publisher: Publisher<
IncrementalDataRecord,
SubsequentIncrementalExecutionResult
>;
_publisher: IncrementalPublisher;

constructor(opts: {
label: string | undefined;
path: Path | undefined;
asyncIterator?: AsyncIterator<unknown>;
parentContext: IncrementalDataRecord | undefined;
publisher: Publisher<
IncrementalDataRecord,
SubsequentIncrementalExecutionResult
>;
publisher: IncrementalPublisher;
}) {
this.type = 'stream';
this.items = null;
Expand Down

0 comments on commit d106636

Please sign in to comment.